desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Update CPU stats using the input method.'
| @GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self):
| self.reset()
if (self.input_method == 'local'):
self.update_local()
elif (self.input_method == 'snmp'):
self.update_snmp()
return self.stats
|
'Update CPU stats using PSUtil.'
| def update_local(self):
| self.stats['total'] = cpu_percent.get()
cpu_times_percent = psutil.cpu_times_percent(interval=0.0)
for stat in ['user', 'system', 'idle', 'nice', 'iowait', 'irq', 'softirq', 'steal', 'guest', 'guest_nice']:
if hasattr(cpu_times_percent, stat):
self.stats[stat] = getattr(cpu_times_percent... |
'Update CPU stats using SNMP.'
| def update_snmp(self):
| if (self.short_system_name in ('windows', 'esxi')):
try:
cpu_stats = self.get_stats_snmp(snmp_oid=snmp_oid[self.short_system_name], bulk=True)
except KeyError:
self.reset()
self.stats['nb_log_core'] = 0
self.stats['idle'] = 0
for c in cpu_stats:
... |
'Update stats views.'
| def update_views(self):
| super(Plugin, self).update_views()
for key in ['user', 'system', 'iowait']:
if (key in self.stats):
self.views[key]['decoration'] = self.get_alert_log(self.stats[key], header=key)
for key in ['steal', 'total']:
if (key in self.stats):
self.views[key]['decoration'] = s... |
'Return the list to display in the UI.'
| def msg_curse(self, args=None):
| ret = []
if ((not self.stats) or self.is_disable()):
return ret
idle_tag = ('user' not in self.stats)
msg = '{}'.format('CPU')
ret.append(self.curse_add_line(msg, 'TITLE'))
trend_user = self.get_trend('user')
trend_system = self.get_trend('system')
if ((trend_user is None) or (tr... |
'Init the plugin.'
| def __init__(self, args=None):
| super(Plugin, self).__init__(args=args)
self.args = args
self.display_curse = True
self.docker_client = False
self.thread_list = {}
self.reset()
|
'Overwrite the exit method to close threads'
| def exit(self):
| for t in itervalues(self.thread_list):
t.stop()
super(Plugin, self).exit()
|
'Return the key of the list.'
| def get_key(self):
| return 'name'
|
'Overwrite the default export method.
- Only exports containers
- The key is the first container name'
| def get_export(self):
| ret = []
try:
ret = self.stats['containers']
except KeyError as e:
logger.debug('docker plugin - Docker export error {}'.format(e))
return ret
|
'Connect to the Docker server with the \'old school\' method'
| def __connect_old(self, version):
| if hasattr(docker, 'APIClient'):
init_docker = docker.APIClient
elif hasattr(docker, 'Client'):
init_docker = docker.Client
else:
logger.error('docker plugin - Can not found any way to init the Docker API')
return None
try:
if W... |
'Connect to the Docker server.'
| def connect(self, version=None):
| if (hasattr(docker, 'from_env') and (version is not None)):
ret = docker.from_env()
else:
ret = self.__connect_old(version=version)
try:
ret.version()
except requests.exceptions.ConnectionError as e:
logger.debug(("docker plugin - Can't connect to the ... |
'Reset/init the stats.'
| def reset(self):
| self.stats = {}
|
'Update Docker stats using the input method.'
| @GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self):
| global docker_tag
self.reset()
if (not self.docker_client):
try:
self.docker_client = self.connect()
except Exception:
docker_tag = False
else:
if (self.docker_client is None):
docker_tag = False
if (not docker_tag):
ret... |
'Return the container CPU usage.
Input: id is the full container id
all_stats is the output of the stats method of the Docker API
Output: a dict {\'total\': 1.49}'
| def get_docker_cpu(self, container_id, all_stats):
| cpu_new = {}
ret = {'total': 0.0}
try:
cpu_new['total'] = all_stats['cpu_stats']['cpu_usage']['total_usage']
cpu_new['system'] = all_stats['cpu_stats']['system_cpu_usage']
cpu_new['nb_core'] = len((all_stats['cpu_stats']['cpu_usage']['percpu_usage'] or []))
except KeyError as e:
... |
'Return the container MEMORY.
Input: id is the full container id
all_stats is the output of the stats method of the Docker API
Output: a dict {\'rss\': 1015808, \'cache\': 356352, \'usage\': ..., \'max_usage\': ...}'
| def get_docker_memory(self, container_id, all_stats):
| ret = {}
try:
ret['usage'] = all_stats['memory_stats']['usage']
ret['limit'] = all_stats['memory_stats']['limit']
ret['max_usage'] = all_stats['memory_stats']['max_usage']
except (KeyError, TypeError) as e:
logger.debug('docker plugin - Cannot grab MEM usage... |
'Return the container network usage using the Docker API (v1.0 or higher).
Input: id is the full container id
Output: a dict {\'time_since_update\': 3000, \'rx\': 10, \'tx\': 65}.
with:
time_since_update: number of seconds elapsed between the latest grab
rx: Number of byte received
tx: Number of byte transmited'
| def get_docker_network(self, container_id, all_stats):
| network_new = {}
try:
netcounters = all_stats['networks']
except KeyError as e:
logger.debug('docker plugin - Cannot grab NET usage for container {} ({})'.format(container_id, e))
logger.debug(all_stats)
return network_new
if (not hasattr(sel... |
'Return the container IO usage using the Docker API (v1.0 or higher).
Input: id is the full container id
Output: a dict {\'time_since_update\': 3000, \'ior\': 10, \'iow\': 65}.
with:
time_since_update: number of seconds elapsed between the latest grab
ior: Number of byte readed
iow: Number of byte written'
| def get_docker_io(self, container_id, all_stats):
| io_new = {}
try:
iocounters = all_stats['blkio_stats']
except KeyError as e:
logger.debug('docker plugin - Cannot grab block IO usage for container {} ({})'.format(container_id, e))
logger.debug(all_stats)
return io_new
if (not hasattr(sel... |
'Return the user ticks by reading the environment variable.'
| def get_user_ticks(self):
| return os.sysconf(os.sysconf_names['SC_CLK_TCK'])
|
'Return stats for the action
Docker will return self.stats[\'containers\']'
| def get_stats_action(self):
| return self.stats['containers']
|
'Update stats views.'
| def update_views(self):
| super(Plugin, self).update_views()
if ('containers' not in self.stats):
return False
for i in self.stats['containers']:
self.views[i[self.get_key()]] = {'cpu': {}, 'mem': {}}
if (('cpu' in i) and ('total' in i['cpu'])):
alert = self.get_alert(i['cpu']['total'], header=(i[... |
'Return the dict to display in the curse interface.'
| def msg_curse(self, args=None):
| ret = []
if ((not self.stats) or (len(self.stats['containers']) == 0) or self.is_disable()):
return ret
msg = '{}'.format('CONTAINERS')
ret.append(self.curse_add_line(msg, 'TITLE'))
msg = ' {}'.format(len(self.stats['containers']))
ret.append(self.curse_add_line(msg))
msg = ' (... |
'Analyse the container status.'
| def container_alert(self, status):
| if ('Paused' in status):
return 'CAREFUL'
else:
return 'OK'
|
'Init the class:
docker_client: instance of Docker-py client
container_id: Id of the container'
| def __init__(self, docker_client, container_id):
| logger.debug('docker plugin - Create thread for container {}'.format(container_id[:12]))
super(ThreadDockerGrabber, self).__init__()
self._stopper = threading.Event()
self._container_id = container_id
self._stats_stream = docker_client.stats(container_id, decode=True)
self._... |
'Function called to grab stats.
Infinite loop, should be stopped by calling the stop() method'
| def run(self):
| for i in self._stats_stream:
self._stats = i
time.sleep(0.1)
if self.stopped():
break
|
'Stats getter'
| @property
def stats(self):
| return self._stats
|
'Stats setter'
| @stats.setter
def stats(self, value):
| self._stats = value
|
'Stop the thread'
| def stop(self, timeout=None):
| logger.debug('docker plugin - Close thread for container {}'.format(self._container_id[:12]))
self._stopper.set()
|
'Return True is the thread is stopped'
| def stopped(self):
| return self._stopper.isSet()
|
'Init the plugin.'
| def __init__(self, args=None):
| super(Plugin, self).__init__(args=args)
self.display_curse = True
self.align = 'right'
self.uptime = (datetime.now() - datetime.fromtimestamp(psutil.boot_time()))
self.reset()
|
'Reset/init the stats.'
| def reset(self):
| self.stats = {}
|
'Overwrite the default export method.
Export uptime in seconds.'
| def get_export(self):
| return {'seconds': int(self.uptime.total_seconds())}
|
'Update uptime stat using the input method.'
| @GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self):
| self.reset()
if (self.input_method == 'local'):
self.uptime = (datetime.now() - datetime.fromtimestamp(psutil.boot_time()))
self.stats = str(self.uptime).split('.')[0]
elif (self.input_method == 'snmp'):
uptime = self.get_stats_snmp(snmp_oid=snmp_oid)['_uptime']
try:
... |
'Return the string to display in the curse interface.'
| def msg_curse(self, args=None):
| return [self.curse_add_line('Uptime: {}'.format(self.stats))]
|
'Init the plugin.'
| def __init__(self, args=None):
| super(Plugin, self).__init__(args=args)
self.display_curse = True
self.irq = GlancesIRQ()
self.reset()
|
'Return the key of the list.'
| def get_key(self):
| return self.irq.get_key()
|
'Reset/init the stats.'
| def reset(self):
| self.stats = []
|
'Update the IRQ stats'
| @GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self):
| self.reset()
if (not LINUX):
return self.stats
if (self.input_method == 'local'):
self.stats = self.irq.get()
elif (self.input_method == 'snmp'):
pass
self.stats = sorted(self.stats, key=operator.itemgetter('irq_rate'), reverse=True)[:5]
return self.stats
|
'Update stats views.'
| def update_views(self):
| super(Plugin, self).update_views()
|
'Return the dict to display in the curse interface.'
| def msg_curse(self, args=None, max_width=None):
| ret = []
if ((not LINUX) or (not self.stats) or (not self.args.enable_irq)):
return ret
if ((max_width is not None) and (max_width >= 23)):
irq_max_width = (max_width - 14)
else:
irq_max_width = 9
msg = '{:{width}}'.format('IRQ', width=irq_max_width)
ret.append(self.curse... |
'Init the class
The stat are stored in a internal list of dict'
| def __init__(self):
| self.lasts = {}
self.reset()
|
'Reset the stats'
| def reset(self):
| self.stats = []
self.cpu_number = 0
|
'Return the current IRQ stats'
| def get(self):
| return self.__update()
|
'Return the key of the dict.'
| def get_key(self):
| return 'irq_line'
|
'The header contain the number of CPU
CPU0 CPU1 CPU2 CPU3
0: 21 0 0 0 IO-APIC 2-edge timer'
| def __header(self, line):
| self.cpu_number = len(line.split())
return self.cpu_number
|
'Get a line and
Return the IRQ name, alias or number (choose the best for human)
IRQ line samples:
1: 44487 341 44 72 IO-APIC 1-edge i8042
LOC: 33549868 22394684 32474570 21855077 Local timer interrupts'
| def __humanname(self, line):
| splitted_line = line.split()
irq_line = splitted_line[0].replace(':', '')
if irq_line.isdigit():
irq_line += '_{}'.format(splitted_line[(-1)])
return irq_line
|
'Get a line and
Return the IRQ sum number
IRQ line samples:
1: 44487 341 44 72 IO-APIC 1-edge i8042
LOC: 33549868 22394684 32474570 21855077 Local timer interrupts
FIQ: usb_fiq'
| def __sum(self, line):
| splitted_line = line.split()
try:
ret = sum(map(int, splitted_line[1:(self.cpu_number + 1)]))
except ValueError:
ret = 0
return ret
|
'Load the IRQ file and update the internal dict'
| def __update(self):
| self.reset()
if (not os.path.exists(self.IRQ_FILE)):
return self.stats
try:
with open(self.IRQ_FILE) as irq_proc:
time_since_update = getTimeSinceLastUpdate('irq')
self.__header(irq_proc.readline())
for line in irq_proc.readlines():
irq_lin... |
'Init the plugin.'
| def __init__(self, args=None):
| super(Plugin, self).__init__(args=args, items_history_list=items_history_list)
self.display_curse = True
self.reset()
|
'Return the key of the list.'
| def get_key(self):
| return 'disk_name'
|
'Reset/init the stats.'
| def reset(self):
| self.stats = []
|
'Update disk I/O stats using the input method.'
| @GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self):
| self.reset()
if (self.input_method == 'local'):
try:
diskiocounters = psutil.disk_io_counters(perdisk=True)
except Exception:
return self.stats
if (not hasattr(self, 'diskio_old')):
try:
self.diskio_old = diskiocounters
exce... |
'Update stats views.'
| def update_views(self):
| super(Plugin, self).update_views()
for i in self.stats:
disk_real_name = i['disk_name']
self.views[i[self.get_key()]]['read_bytes']['decoration'] = self.get_alert(int((i['read_bytes'] // i['time_since_update'])), header=(disk_real_name + '_rx'))
self.views[i[self.get_key()]]['write_bytes... |
'Return the dict to display in the curse interface.'
| def msg_curse(self, args=None):
| ret = []
if ((not self.stats) or self.is_disable()):
return ret
msg = '{:9}'.format('DISK I/O')
ret.append(self.curse_add_line(msg, 'TITLE'))
if args.diskio_iops:
msg = '{:>7}'.format('IOR/s')
ret.append(self.curse_add_line(msg))
msg = '{:>7}'.format('IOW/s')
... |
'Init the plugin.'
| def __init__(self, args=None):
| super(Plugin, self).__init__(args=args)
self.glancesgrabsensors = GlancesGrabSensors()
self.hddtemp_plugin = HddTempPlugin(args=args)
self.batpercent_plugin = BatPercentPlugin(args=args)
self.display_curse = True
self.reset()
|
'Return the key of the list.'
| def get_key(self):
| return 'label'
|
'Reset/init the stats.'
| def reset(self):
| self.stats = []
|
'Update sensors stats using the input method.'
| @GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self):
| self.reset()
if (self.input_method == 'local'):
self.stats = []
try:
temperature = self.__set_type(self.glancesgrabsensors.get('temperature_core'), 'temperature_core')
except Exception as e:
logger.error(('Cannot grab sensors temperatures (%s)' % e))
... |
'Set the plugin type.
4 types of stats is possible in the sensors plugin:
- Core temperature: \'temperature_core\'
- Fan speed: \'fan_speed\'
- HDD temperature: \'temperature_hdd\'
- Battery capacity: \'battery\''
| def __set_type(self, stats, sensor_type):
| for i in stats:
i.update({'type': sensor_type})
i.update({'key': self.get_key()})
return stats
|
'Update stats views.'
| def update_views(self):
| super(Plugin, self).update_views()
for i in self.stats:
if (not i['value']):
continue
if (i['type'] == 'battery'):
self.views[i[self.get_key()]]['value']['decoration'] = self.get_alert((100 - i['value']), header=i['type'])
else:
self.views[i[self.get_k... |
'Return the dict to display in the curse interface.'
| def msg_curse(self, args=None):
| ret = []
if ((not self.stats) or args.disable_sensors):
return ret
msg = '{:18}'.format('SENSORS')
ret.append(self.curse_add_line(msg, 'TITLE'))
for i in self.stats:
if ((i['type'] == 'battery') and (i['value'] == [])):
continue
ret.append(self.curse_new_line())
... |
'Init sensors stats.'
| def __init__(self):
| self.init_temp = False
self.stemps = {}
try:
self.stemps = psutil.sensors_temperatures()
except AttributeError:
logger.warning('PsUtil 5.1.0 or higher is needed to grab temperatures sensors')
except OSError as e:
logger.error('Can not grab ... |
'Reset/init the stats.'
| def reset(self):
| self.sensors_list = []
|
'Update the stats.'
| def __update__(self):
| self.reset()
if (not self.init_temp):
return self.sensors_list
self.sensors_list.extend(self.build_sensors_list(SENSOR_TEMP_UNIT))
self.sensors_list.extend(self.build_sensors_list(SENSOR_FAN_UNIT))
return self.sensors_list
|
'Build the sensors list depending of the type.
type: SENSOR_TEMP_UNIT or SENSOR_FAN_UNIT
output: a list'
| def build_sensors_list(self, type):
| ret = []
if ((type == SENSOR_TEMP_UNIT) and self.init_temp):
input_list = self.stemps
self.stemps = psutil.sensors_temperatures()
elif ((type == SENSOR_FAN_UNIT) and self.init_fan):
input_list = self.sfans
self.sfans = psutil.sensors_fans()
else:
return ret
fo... |
'Get sensors list.'
| def get(self, sensor_type='temperature_core'):
| self.__update__()
if (sensor_type == 'temperature_core'):
ret = [s for s in self.sensors_list if (s['unit'] == SENSOR_TEMP_UNIT)]
elif (sensor_type == 'fan_speed'):
ret = [s for s in self.sensors_list if (s['unit'] == SENSOR_FAN_UNIT)]
else:
logger.debug(('Unknown sensor ty... |
'Init the plugin.'
| def __init__(self, args=None):
| super(Plugin, self).__init__(args=args, items_history_list=items_history_list)
self.display_curse = True
self.reset()
try:
self.nb_log_core = CorePlugin(args=self.args).update()['log']
except Exception:
self.nb_log_core = 1
|
'Reset/init the stats.'
| def reset(self):
| self.stats = {}
|
'Update load stats.'
| @GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self):
| self.reset()
if (self.input_method == 'local'):
try:
load = os.getloadavg()
except (OSError, AttributeError):
self.stats = {}
else:
self.stats = {'min1': load[0], 'min5': load[1], 'min15': load[2], 'cpucore': self.nb_log_core}
elif (self.input_meth... |
'Update stats views.'
| def update_views(self):
| super(Plugin, self).update_views()
try:
self.views['min15']['decoration'] = self.get_alert_log(self.stats['min15'], maximum=(100 * self.stats['cpucore']))
self.views['min5']['decoration'] = self.get_alert(self.stats['min5'], maximum=(100 * self.stats['cpucore']))
except KeyError:
pas... |
'Return the dict to display in the curse interface.'
| def msg_curse(self, args=None):
| ret = []
if ((not self.stats) or (self.stats == {}) or self.is_disable()):
return ret
msg = '{:8}'.format('LOAD')
ret.append(self.curse_add_line(msg, 'TITLE'))
if (('cpucore' in self.stats) and (self.stats['cpucore'] > 0)):
msg = '{}-core'.format(int(self.stats['cpucore']))
r... |
'Init the plugin.'
| def __init__(self, args=None):
| super(Plugin, self).__init__(args=args)
self.display_curse = True
self.reset()
|
'Return the key of the list.
:returns: string -- SSID is the dict key'
| def get_key(self):
| return 'ssid'
|
'Reset/init the stats to an empty list.
:returns: None'
| def reset(self):
| self.stats = []
|
'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)'
| @GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self):
| self.reset()
if (not wifi_tag):
return self.stats
if (self.input_method == 'local'):
try:
netiocounters = psutil.net_io_counters(pernic=True)
except UnicodeDecodeError:
return self.stats
for net in netiocounters:
if self.is_hide(net):
... |
'Overwrite the default get_alert method.
Alert is on signal quality where lower is better...
:returns: string -- Signal alert'
| def get_alert(self, value):
| ret = 'OK'
try:
if (value <= self.get_limit('critical', stat_name=self.plugin_name)):
ret = 'CRITICAL'
elif (value <= self.get_limit('warning', stat_name=self.plugin_name)):
ret = 'WARNING'
elif (value <= self.get_limit('careful', stat_name=self.plugin_name)):
... |
'Update stats views.'
| def update_views(self):
| super(Plugin, self).update_views()
for i in self.stats:
self.views[i[self.get_key()]]['signal']['decoration'] = self.get_alert(i['signal'])
self.views[i[self.get_key()]]['quality']['decoration'] = self.views[i[self.get_key()]]['signal']['decoration']
|
'Return the dict to display in the curse interface.'
| def msg_curse(self, args=None, max_width=None):
| ret = []
if ((not self.stats) or args.disable_wifi or (not wifi_tag)):
return ret
if ((max_width is not None) and (max_width >= 23)):
ifname_max_width = (max_width - 5)
else:
ifname_max_width = 16
msg = '{:{width}}'.format('WIFI', width=ifname_max_width)
ret.append(self.c... |
'Init the plugin.'
| def __init__(self, args=None):
| super(Plugin, self).__init__(args=args)
self.display_curse = True
self.align = 'bottom'
self.reset()
|
'Reset/init the stats.'
| def reset(self):
| self.stats = []
|
'Nothing to do here. Just return the global glances_log.'
| def update(self):
| self.stats = glances_logs.get()
|
'Return the dict to display in the curse interface.'
| def msg_curse(self, args=None):
| ret = []
if ((not self.stats) and self.is_disable()):
return ret
ret.append(self.curse_add_line(global_message(), 'TITLE'))
if self.stats:
for alert in self.stats:
ret.append(self.curse_new_line())
msg = str(datetime.fromtimestamp(alert[0]))
ret.append... |
'Compare a with b using the tolerance (if numerical).'
| def approx_equal(self, a, b, tolerance=0.0):
| if (str(int(a)).isdigit() and str(int(b)).isdigit()):
return (abs((a - b)) <= (max(abs(a), abs(b)) * tolerance))
else:
return (a == b)
|
'Init the plugin.'
| def __init__(self, args=None, config=None):
| super(Plugin, self).__init__(args=args)
self.config = config
self.display_curse = True
self.view_data = {}
self.generate_view_data()
|
'No stats. It is just a plugin to display the help.'
| def reset(self):
| pass
|
'No stats. It is just a plugin to display the help.'
| def update(self):
| pass
|
'Return the list to display in the curse interface.'
| def msg_curse(self, args=None):
| ret = []
ret.append(self.curse_add_line(self.view_data['version'], 'TITLE'))
ret.append(self.curse_add_line(self.view_data['psutil_version']))
ret.append(self.curse_new_line())
if ('configuration_file' in self.view_data):
ret.append(self.curse_new_line())
ret.append(self.curse_add_li... |
'Init the quicklook plugin.'
| def __init__(self, args=None):
| super(Plugin, self).__init__(args=args)
self.display_curse = True
self.reset()
|
'Reset/init the stats.'
| def reset(self):
| self.stats = {}
|
'Update quicklook stats using the input method.'
| @GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self):
| self.reset()
if (self.input_method == 'local'):
self.stats['cpu'] = cpu_percent.get()
self.stats['percpu'] = cpu_percent.get(percpu=True)
self.stats['mem'] = psutil.virtual_memory().percent
self.stats['swap'] = psutil.swap_memory().percent
elif (self.input_method == 'snmp'):
... |
'Update stats views.'
| def update_views(self):
| super(Plugin, self).update_views()
for key in ['cpu', 'mem', 'swap']:
if (key in self.stats):
self.views[key]['decoration'] = self.get_alert(self.stats[key], header=key)
|
'Return the list to display in the UI.'
| def msg_curse(self, args=None, max_width=10):
| ret = []
if ((not self.stats) or self.is_disable()):
return ret
bar = Bar(max_width)
if (('cpu_name' in self.stats) and ('cpu_hz_current' in self.stats) and ('cpu_hz' in self.stats)):
msg_name = '{} - '.format(self.stats['cpu_name'])
msg_freq = '{:.2f}/{:.2f}GHz'.format(sel... |
'Create a new line to the Quickview'
| def _msg_create_line(self, msg, bar, key):
| ret = []
ret.append(self.curse_add_line(msg))
ret.append(self.curse_add_line(bar.pre_char, decoration='BOLD'))
ret.append(self.curse_add_line(str(bar), self.get_views(key=key, option='decoration')))
ret.append(self.curse_add_line(bar.post_char, decoration='BOLD'))
ret.append(self.curse_add_line(... |
'Convert Hz to Ghz'
| def _hz_to_ghz(self, hz):
| return (hz / 1000000000.0)
|
'Init the plugin.'
| def __init__(self, args=None):
| super(Plugin, self).__init__(args=args)
self.display_curse = True
self.reset()
|
'Reset/init the stats.'
| def reset(self):
| self.stats = {}
|
'Update the host/system info using the input method.
Return the stats (dict)'
| @GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self):
| self.reset()
if (self.input_method == 'local'):
self.stats['os_name'] = platform.system()
self.stats['hostname'] = platform.node()
self.stats['platform'] = platform.architecture()[0]
if (self.stats['os_name'] == 'Linux'):
try:
linux_distro = platform.l... |
'Return the string to display in the curse interface.'
| def msg_curse(self, args=None):
| ret = []
if args.client:
if (args.cs_status.lower() == 'connected'):
msg = 'Connected to '
ret.append(self.curse_add_line(msg, 'OK'))
elif (args.cs_status.lower() == 'snmp'):
msg = 'SNMP from '
ret.append(self.curse_add_line(msg, 'OK'))... |
'Init the plugin.'
| def __init__(self, args=None):
| super(Plugin, self).__init__(args=args)
self.display_curse = False
self.reset()
|
'Reset/init the stat using the input method.'
| def reset(self):
| self.stats = {}
|
'Update core stats.
Stats is a dict (with both physical and log cpu number) instead of a integer.'
| def update(self):
| self.reset()
if (self.input_method == 'local'):
try:
self.stats['phys'] = psutil.cpu_count(logical=False)
self.stats['log'] = psutil.cpu_count()
except NameError:
self.reset()
elif (self.input_method == 'snmp'):
pass
return self.stats
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.