Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@GlancesPlugin._log_result_decorator
def update(self):
"""Update the foldered list."""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local':
# Folder list only available in a full Glances environment
# Check if the glances_folder instance is init
if self.glances_folders is None:
return self.stats
# Update the foldered list (result of command)
self.glances_folders.update()
# Put it on the stats var
stats = self.glances_folders.get()
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self):
"""Update CPU stats using the input method."""
# Grab stats into self.stats
if self.input_method == 'local':
stats = self.update_local()
elif self.input_method == 'snmp':
stats = self.update_snmp()
else:
stats = self.get_init_value()
# Update the stats
self.stats = stats
return self.stats
#
# Glances is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see .
"""psutil plugin."""
from glances import psutil_version_info
from glances.plugins.glances_plugin import GlancesPlugin
class Plugin(GlancesPlugin):
"""Get the psutil version for client/server purposes.
stats is a tuple
"""
def __init__(self, args=None, config=None):
"""Init the plugin."""
super(Plugin, self).__init__(args=args, config=config)
self.reset()
def reset(self):
"""Reset/init the stats."""
self.stats = None
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self):
"""Update Wifi stats using the input method.
Stats is a list of dict (one dict per hotspot)
:returns: list -- Stats is a list of dict (hotspot)
"""
# Init new stats
stats = self.get_init_value()
# Exist if we can not grab the stats
if import_error_tag:
return stats
if self.input_method == 'local':
# Update stats using the standard system lib
try:
from wifi.scan import Cell
from wifi.exceptions import InterfaceError
except ImportError as e:
import_error_tag = True
logger.warning("Missing Python Lib ({}), Wifi plugin is disabled".format(e))
else:
import_error_tag = False
# Python 3 is not supported (see issue #1377)
if PY3:
import_error_tag = True
logger.warning("Wifi lib is not compliant with Python 3, Wifi plugin is disabled")
class Plugin(GlancesPlugin):
"""Glances Wifi plugin.
Get stats of the current Wifi hotspots.
"""
def __init__(self, args=None, config=None):
"""Init the plugin."""
super(Plugin, self).__init__(args=args,
config=config,
stats_init_value=[])
# We want to display the stat in the curse interface
self.display_curse = True
def get_key(self):
"""Return the key of the list.
'netapp': {'system': '1.3.6.1.4.1.789.1.2.1.3.0',
'idle': '1.3.6.1.4.1.789.1.2.1.5.0',
'nb_log_core': '1.3.6.1.4.1.789.1.2.1.6.0'}}
# Define the history items list
# - 'name' define the stat identifier
# - 'y_unit' define the Y label
items_history_list = [{'name': 'user',
'description': 'User CPU usage',
'y_unit': '%'},
{'name': 'system',
'description': 'System CPU usage',
'y_unit': '%'}]
class Plugin(GlancesPlugin):
"""Glances CPU plugin.
'stats' is a dictionary that contains the system-wide CPU utilization as a
percentage.
"""
def __init__(self, args=None, config=None):
"""Init the CPU plugin."""
super(Plugin, self).__init__(args=args,
config=config,
items_history_list=items_history_list)
# We want to display the stat in the curse interface
self.display_curse = True
# Call CorePlugin in order to display the core number
except ImportError:
logger.debug("batinfo library not found. Fallback to psutil.")
batinfo_tag = False
# Availability:
# Linux, Windows, FreeBSD (psutil>=5.1.0)
# macOS (psutil>=5.4.2)
psutil_tag = True
try:
psutil.sensors_battery()
except Exception as e:
logger.error("Cannot grab battery status {}.".format(e))
psutil_tag = False
class Plugin(GlancesPlugin):
"""Glances battery capacity plugin.
stats is a list
"""
def __init__(self, args=None, config=None):
"""Init the plugin."""
super(Plugin, self).__init__(args=args,
config=config,
stats_init_value=[])
# Init the sensor class
self.glancesgrabbat = GlancesGrabBat()
# We do not want to display the stat in a dedicated area
# The HDD temp is displayed within the sensors plugin
# All items in this list will be historised if the --enable-history tag is set
items_history_list = [{'name': 'cpu',
'description': 'CPU percent usage',
'y_unit': '%'},
{'name': 'percpu',
'description': 'PERCPU percent usage',
'y_unit': '%'},
{'name': 'mem',
'description': 'MEM percent usage',
'y_unit': '%'},
{'name': 'swap',
'description': 'SWAP percent usage',
'y_unit': '%'}]
class Plugin(GlancesPlugin):
"""Glances quicklook plugin.
'stats' is a dictionary.
"""
def __init__(self, args=None, config=None):
"""Init the quicklook plugin."""
super(Plugin, self).__init__(args=args,
config=config,
items_history_list=items_history_list)
# We want to display the stat in the curse interface
self.display_curse = True
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self):