summaryrefslogtreecommitdiffstats
path: root/glances/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'glances/plugins')
-rw-r--r--glances/plugins/glances_alert.py19
-rw-r--r--glances/plugins/glances_batpercent.py26
-rw-r--r--glances/plugins/glances_cpu.py91
-rw-r--r--glances/plugins/glances_diskio.py16
-rw-r--r--glances/plugins/glances_fs.py88
-rw-r--r--glances/plugins/glances_help.py77
-rw-r--r--glances/plugins/glances_load.py49
-rw-r--r--glances/plugins/glances_mem.py93
-rw-r--r--glances/plugins/glances_memswap.py62
-rw-r--r--glances/plugins/glances_monitor.py11
-rw-r--r--glances/plugins/glances_network.py56
-rw-r--r--glances/plugins/glances_now.py7
-rw-r--r--glances/plugins/glances_percpu.py6
-rw-r--r--glances/plugins/glances_plugin.py217
-rw-r--r--glances/plugins/glances_processcount.py29
-rw-r--r--glances/plugins/glances_processlist.py204
-rw-r--r--glances/plugins/glances_sensors.py42
-rw-r--r--glances/plugins/glances_system.py35
-rw-r--r--glances/plugins/glances_uptime.py8
19 files changed, 765 insertions, 371 deletions
diff --git a/glances/plugins/glances_alert.py b/glances/plugins/glances_alert.py
index a334398c..25eff22a 100644
--- a/glances/plugins/glances_alert.py
+++ b/glances/plugins/glances_alert.py
@@ -20,6 +20,7 @@
"""Alert plugin."""
# Import system lib
+import types
from datetime import datetime
# Import Glances libs
@@ -40,12 +41,9 @@ class Plugin(GlancesPlugin):
# We want to display the stat in the curse interface
self.display_curse = True
+
# Set the message position
- # It is NOT the curse position but the Glances column/line
- # Enter -1 to right align
- self.column_curse = 1
- # Enter -1 to diplay bottom
- self.line_curse = -1
+ self.set_align('bottom')
# Init the stats
self.reset()
@@ -107,7 +105,7 @@ class Plugin(GlancesPlugin):
msg = str(alert[3])
ret.append(self.curse_add_line(msg, decoration=alert[2]))
# Min / Mean / Max
- if alert[6] == alert[4]:
+ if self.approx_equal(alert[6], alert[4], tolerance=0.1):
msg = ' ({0:.1f})'.format(alert[5])
else:
msg = _(" (Min:{0:.1f} Mean:{1:.1f} Max:{2:.1f})").format(alert[6], alert[5], alert[4])
@@ -122,3 +120,12 @@ class Plugin(GlancesPlugin):
# ret.append(self.curse_add_line(msg))
return ret
+
+ def approx_equal(self, a, b, tolerance=0.0):
+ """
+ Compare a with b using the tolerance (if numerical)
+ """
+ if str(int(a)).isdigit() and str(int(b)).isdigit():
+ return abs(a-b) <= max(abs(a), abs(b)) * tolerance
+ else:
+ return a == b
diff --git a/glances/plugins/glances_batpercent.py b/glances/plugins/glances_batpercent.py
index d083e78d..edb269db 100644
--- a/glances/plugins/glances_batpercent.py
+++ b/glances/plugins/glances_batpercent.py
@@ -19,14 +19,15 @@
"""Battery plugin."""
+# Import Glances libs
+from glances.core.glances_globals import logger
+from glances.plugins.glances_plugin import GlancesPlugin
+
# Batinfo library (optional; Linux-only)
try:
import batinfo
except ImportError:
- pass
-
-# Import Glances libs
-from glances.plugins.glances_plugin import GlancesPlugin
+ logger.debug(_("Cannot grab battery sensor. Missing BatInfo library."))
class Plugin(GlancesPlugin):
@@ -84,18 +85,12 @@ class GlancesGrabBat(object):
self.bat_list = []
self.update()
except Exception:
- # print(_("Warning: Cannot grab battery sensor. Missing BatInfo library."))
self.initok = False
def update(self):
"""Update the stats."""
if self.initok:
- reply = self.bat.update()
- if reply is not None:
- self.bat_list = []
- new_item = {'label': _("Battery (%)"),
- 'value': self.getcapacitypercent()}
- self.bat_list.append(new_item)
+ self.bat_list = [{'label': _("Battery (%)"), 'value': self.getcapacitypercent()}]
else:
self.bat_list = []
@@ -108,15 +103,14 @@ class GlancesGrabBat(object):
if not self.initok or self.bat.stat == []:
return []
- # Init the bsum (sum of percent) and bcpt (number of batteries)
+ # Init the bsum (sum of percent)
# and Loop over batteries (yes a computer could have more than 1 battery)
bsum = 0
- for bcpt in range(len(self.bat.stat)):
+ for b in self.bat.stat:
try:
- bsum = bsum + int(self.bat.stat[bcpt].capacity)
+ bsum = bsum + int(b.capacity)
except ValueError:
return []
- bcpt = bcpt + 1
# Return the global percent
- return int(bsum / bcpt)
+ return int(bsum / len(self.bat.stat))
diff --git a/glances/plugins/glances_cpu.py b/glances/plugins/glances_cpu.py
index 479e6358..db4a7a43 100644
--- a/glances/plugins/glances_cpu.py
+++ b/glances/plugins/glances_cpu.py
@@ -27,13 +27,20 @@ import psutil
# percentage of user CPU time: .1.3.6.1.4.1.2021.11.9.0
# percentages of system CPU time: .1.3.6.1.4.1.2021.11.10.0
# percentages of idle CPU time: .1.3.6.1.4.1.2021.11.11.0
-snmp_oid = {'user': '1.3.6.1.4.1.2021.11.9.0',
- 'system': '1.3.6.1.4.1.2021.11.10.0',
- 'idle': '1.3.6.1.4.1.2021.11.11.0'}
+snmp_oid = {'default': {'user': '1.3.6.1.4.1.2021.11.9.0',
+ 'system': '1.3.6.1.4.1.2021.11.10.0',
+ 'idle': '1.3.6.1.4.1.2021.11.11.0'},
+ 'windows': {'percent': '1.3.6.1.2.1.25.3.3.1.2'},
+ 'esxi': {'percent': '1.3.6.1.2.1.25.3.3.1.2'}}
+# Define the history items list
+# 'color' define the graph color in #RGB format
+# All items in this list will be historised if the --enable-history tag is set
+items_history_list = [{'name': 'user', 'color': '#00FF00'},
+ {'name': 'system', 'color': '#FF0000'}]
-class Plugin(GlancesPlugin):
+class Plugin(GlancesPlugin):
"""
Glances' CPU plugin.
@@ -42,16 +49,10 @@ class Plugin(GlancesPlugin):
def __init__(self, args=None):
"""Init the CPU plugin."""
- GlancesPlugin.__init__(self, args=args)
+ GlancesPlugin.__init__(self, args=args, items_history_list=items_history_list)
# We want to display the stat in the curse interface
self.display_curse = True
- # Set the message position
- # It is NOT the curse position but the Glances column/line
- # Enter -1 to right align
- self.column_curse = 0
- # Enter -1 to diplay bottom
- self.line_curse = 1
# Init stats
self.first_call = True
@@ -91,14 +92,45 @@ class Plugin(GlancesPlugin):
self.stats[cpu] = getattr(cputimespercent, cpu)
elif self.get_input() == 'snmp':
# Update stats using SNMP
- self.stats = self.set_stats_snmp(snmp_oid=snmp_oid)
-
- if self.stats['user'] == '':
- self.reset()
- return self.stats
- for key in self.stats.iterkeys():
- self.stats[key] = float(self.stats[key])
+ if self.get_short_system_name() in ('windows', 'esxi'):
+ # Windows or VMWare ESXi
+ # You can find the CPU utilization of windows system by querying the oid
+ # Give also the number of core (number of element in the table)
+ try:
+ cpu_stats = self.set_stats_snmp(snmp_oid=snmp_oid[self.get_short_system_name()],
+ bulk=True)
+ except KeyError:
+ self.reset()
+
+ # Iter through CPU and compute the idle CPU stats
+ self.stats['nb_log_core'] = 0
+ self.stats['idle'] = 0
+ for c in cpu_stats:
+ if c.startswith('percent'):
+ self.stats['idle'] += float(cpu_stats['percent.3'])
+ self.stats['nb_log_core'] += 1
+ if self.stats['nb_log_core'] > 0:
+ self.stats['idle'] = self.stats['idle'] / self.stats['nb_log_core']
+ self.stats['idle'] = 100 - self.stats['idle']
+
+ else:
+ # Default behavor
+ try:
+ self.stats = self.set_stats_snmp(snmp_oid=snmp_oid[self.get_short_system_name()])
+ except KeyError:
+ self.stats = self.set_stats_snmp(snmp_oid=snmp_oid['default'])
+
+ if self.stats['idle'] == '':
+ self.reset()
+ return self.stats
+
+ # Convert SNMP stats to float
+ for key in list(self.stats.keys()):
+ self.stats[key] = float(self.stats[key])
+
+ # Update the history list
+ self.update_stats_history()
return self.stats
@@ -112,12 +144,17 @@ class Plugin(GlancesPlugin):
return ret
# Build the string message
+ # If user stat is not here, display only idle / total CPU usage (for exemple on Windows OS)
+ idle_tag = 'user' not in self.stats
# Header
msg = '{0:8}'.format(_("CPU"))
ret.append(self.curse_add_line(msg, "TITLE"))
# Total CPU usage
msg = '{0:>6.1%}'.format((100 - self.stats['idle']) / 100)
- ret.append(self.curse_add_line(msg))
+ if idle_tag:
+ ret.append(self.curse_add_line(msg, self.get_alert_log((100 - self.stats['idle']) / 100, header="system")))
+ else:
+ ret.append(self.curse_add_line(msg))
# Nice CPU
if 'nice' in self.stats:
msg = ' {0:8}'.format(_("nice:"))
@@ -131,7 +168,12 @@ class Plugin(GlancesPlugin):
msg = '{0:8}'.format(_("user:"))
ret.append(self.curse_add_line(msg))
msg = '{0:>6.1%}'.format(self.stats['user'] / 100)
- ret.append(self.curse_add_line(msg, self.get_alert_log(self.stats['user'], header="user")))
+ ret.append(self.curse_add_line(msg, self.get_alert_log(self.stats['user'], header="user")))
+ elif 'idle' in self.stats:
+ msg = '{0:8}'.format(_("idle:"))
+ ret.append(self.curse_add_line(msg))
+ msg = '{0:>6.1%}'.format(self.stats['idle'] / 100)
+ ret.append(self.curse_add_line(msg))
# IRQ CPU
if 'irq' in self.stats:
msg = ' {0:8}'.format(_("irq:"))
@@ -141,11 +183,16 @@ class Plugin(GlancesPlugin):
# New line
ret.append(self.curse_new_line())
# System CPU
- if 'system' in self.stats:
+ if 'system' in self.stats and not idle_tag:
msg = '{0:8}'.format(_("system:"))
ret.append(self.curse_add_line(msg))
msg = '{0:>6.1%}'.format(self.stats['system'] / 100)
ret.append(self.curse_add_line(msg, self.get_alert_log(self.stats['system'], header="system")))
+ else:
+ msg = '{0:8}'.format(_("core:"))
+ ret.append(self.curse_add_line(msg))
+ msg = '{0:>6}'.format(self.stats['nb_log_core'])
+ ret.append(self.curse_add_line(msg))
# IOWait CPU
if 'iowait' in self.stats:
msg = ' {0:8}'.format(_("iowait:"))
@@ -155,7 +202,7 @@ class Plugin(GlancesPlugin):
# New line
ret.append(self.curse_new_line())
# Idle CPU
- if 'idle' in self.stats:
+ if 'idle' in self.stats and not idle_tag:
msg = '{0:8}'.format(_("idle:"))
ret.append(self.curse_add_line(msg))
msg = '{0:>6.1%}'.format(self.stats['idle'] / 100)
diff --git a/glances/plugins/glances_diskio.py b/glances/plugins/glances_diskio.py
index b42226b4..5997570f 100644
--- a/glances/plugins/glances_diskio.py
+++ b/glances/plugins/glances_diskio.py
@@ -39,12 +39,6 @@ class Plugin(GlancesPlugin):
# We want to display the stat in the curse interface
self.display_curse = True
- # Set the message position
- # It is NOT the curse position but the Glances column/line
- # Enter -1 to right align
- self.column_curse = 0
- # Enter -1 to diplay bottom
- self.line_curse = 3
# Init the stats
self.reset()
@@ -134,13 +128,15 @@ class Plugin(GlancesPlugin):
# Do not display hidden interfaces
if self.is_hide(i['disk_name']):
continue
+ # Is there an alias for the disk name ?
+ disk_name = self.has_alias(i['disk_name'])
+ if disk_name is None:
+ disk_name = i['disk_name']
# New line
ret.append(self.curse_new_line())
- if len(i['disk_name']) > 9:
+ if len(disk_name) > 9:
# Cut disk name if it is too long
- disk_name = '_' + i['disk_name'][-8:]
- else:
- disk_name = i['disk_name']
+ disk_name = '_' + disk_name[-8:]
msg = '{0:9}'.format(disk_name)
ret.append(self.curse_add_line(msg))
txps = self.auto_unit(int(i['read_bytes'] // i['time_since_update']))
diff --git a/glances/plugins/glances_fs.py b/glances/plugins/glances_fs.py
index c4f7d322..3a12e089 100644
--- a/glances/plugins/glances_fs.py
+++ b/glances/plugins/glances_fs.py
@@ -19,8 +19,14 @@
"""File system plugin."""
+# System libs
+import base64
+
+# Glances libs
+from glances.core.glances_globals import version, logger
from glances.plugins.glances_plugin import GlancesPlugin
+# PSutil lib for local grab
import psutil
# SNMP OID
@@ -37,11 +43,16 @@ import psutil
# Used space on the disk: .1.3.6.1.4.1.2021.9.1.8.1
# Percentage of space used on disk: .1.3.6.1.4.1.2021.9.1.9.1
# Percentage of inodes used on disk: .1.3.6.1.4.1.2021.9.1.10.1
-snmp_oid = {'mnt_point': '1.3.6.1.4.1.2021.9.1.2',
- 'device_name': '1.3.6.1.4.1.2021.9.1.3',
- 'size': '1.3.6.1.4.1.2021.9.1.6',
- 'used': '1.3.6.1.4.1.2021.9.1.8',
- 'percent': '1.3.6.1.4.1.2021.9.1.9'}
+snmp_oid = {'default': {'mnt_point': '1.3.6.1.4.1.2021.9.1.2',
+ 'device_name': '1.3.6.1.4.1.2021.9.1.3',
+ 'size': '1.3.6.1.4.1.2021.9.1.6',
+ 'used': '1.3.6.1.4.1.2021.9.1.8',
+ 'percent': '1.3.6.1.4.1.2021.9.1.9'},
+ 'windows': {'mnt_point': '1.3.6.1.2.1.25.2.3.1.3',
+ 'alloc_unit': '1.3.6.1.2.1.25.2.3.1.4',
+ 'size': '1.3.6.1.2.1.25.2.3.1.5',
+ 'used': '1.3.6.1.2.1.25.2.3.1.6'}}
+snmp_oid['esxi'] = snmp_oid['windows']
class Plugin(GlancesPlugin):
@@ -57,12 +68,6 @@ class Plugin(GlancesPlugin):
# We want to display the stat in the curse interface
self.display_curse = True
- # Set the message position
- # It is NOT the curse position but the Glances column/line
- # Enter -1 to right align
- self.column_curse = 0
- # Enter -1 to diplay bottom
- self.line_curse = 4
# Init the stats
self.reset()
@@ -109,22 +114,42 @@ class Plugin(GlancesPlugin):
elif self.get_input() == 'snmp':
# Update stats using SNMP
- # SNMP bulk command to get all file system in one shot
- fs_stat = self.set_stats_snmp(snmp_oid=snmp_oid, bulk=True)
+ # SNMP bulk command to get all file system in one shot
+ try:
+ fs_stat = self.set_stats_snmp(snmp_oid=snmp_oid[self.get_short_system_name()],
+ bulk=True)
+ except KeyError:
+ fs_stat = self.set_stats_snmp(snmp_oid=snmp_oid['default'],
+ bulk=True)
# Loop over fs
- for fs in fs_stat:
- fs_current = {}
- fs_current['device_name'] = fs_stat[fs]['device_name']
- fs_current['mnt_point'] = fs
- fs_current['size'] = int(fs_stat[fs]['size']) * 1024
- fs_current['used'] = int(fs_stat[fs]['used']) * 1024
- fs_current['percent'] = float(fs_stat[fs]['percent'])
- self.stats.append(fs_current)
+ if self.get_short_system_name() in ('windows', 'esxi'):
+ # Windows or ESXi tips
+ for fs in fs_stat:
+ # Memory stats are grabed in the same OID table (ignore it)
+ if fs == 'Virtual Memory' or fs == 'Physical Memory' or fs == 'Real Memory':
+ continue
+ fs_current = {}
+ fs_current['device_name'] = ''
+ fs_current['mnt_point'] = fs.partition(' ')[0]
+ fs_current['size'] = int(fs_stat[fs]['size']) * int(fs_stat[fs]['alloc_unit'])
+ fs_current['used'] = int(fs_stat[fs]['used']) * int(fs_stat[fs]['alloc_unit'])
+ fs_current['percent'] = float(fs_current['used'] * 100 / fs_current['size'])
+ self.stats.append(fs_current)
+ else:
+ # Default behavor
+ for fs in fs_stat:
+ fs_current = {}
+ fs_current['device_name'] = fs_stat[fs]['device_name']
+ fs_current['mnt_point'] = fs
+ fs_current['size'] = int(fs_stat[fs]['size']) * 1024
+ fs_current['used'] = int(fs_stat[fs]['used']) * 1024
+ fs_current['percent'] = float(fs_stat[fs]['percent'])
+ self.stats.append(fs_current)
return self.stats
- def msg_curse(self, args=None):
+ def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
@@ -133,9 +158,16 @@ class Plugin(GlancesPlugin):
if self.stats == [] or args.disable_fs:
return ret
+ # Max size for the fsname name
+ if max_width is not None and max_width >= 23:
+ # Interface size name = max_width - space for interfaces bitrate
+ fsname_max_width = max_width - 14
+ else:
+ fsname_max_width = 9
+
# Build the string message
# Header
- msg = '{0:9}'.format(_("FILE SYS"))
+ msg = '{0:{width}}'.format(_("FILE SYS"), width=fsname_max_width)
ret.append(self.curse_add_line(msg, "TITLE"))
msg = '{0:>7}'.format(_("Used"))
ret.append(self.curse_add_line(msg))
@@ -146,15 +178,17 @@ class Plugin(GlancesPlugin):
for i in sorted(self.stats, key=lambda fs: fs['mnt_point']):
# New line
ret.append(self.curse_new_line())
- if len(i['mnt_point']) + len(i['device_name'].split('/')[-1]) <= 6:
+ if i['device_name'] == '' or i['device_name'] == 'none':
+ mnt_point = i['mnt_point'][-fsname_max_width+1:]
+ elif len(i['mnt_point']) + len(i['device_name'].split('/')[-1]) <= fsname_max_width - 3:
# If possible concatenate mode info... Glances touch inside :)
mnt_point = i['mnt_point'] + ' (' + i['device_name'].split('/')[-1] + ')'
- elif len(i['mnt_point']) > 9:
+ elif len(i['mnt_point']) > fsname_max_width:
# Cut mount point name if it is too long
- mnt_point = '_' + i['mnt_point'][-8:]
+ mnt_point = '_' + i['mnt_point'][-fsname_max_width+1:]
else:
mnt_point = i['mnt_point']
- msg = '{0:9}'.format(mnt_point)
+ msg = '{0:{width}}'.format(mnt_point, width=fsname_max_width)
ret.append(self.curse_add_line(msg))
msg = '{0:>7}'.format(self.auto_unit(i['used']))
ret.append(self.curse_add_line(msg, self.get_alert(i['used'], max=i['size'])))
diff --git a/glances/plugins/glances_help.py b/glances/plugins/glances_help.py
index d824f194..0daa886a 100644
--- a/glances/plugins/glances_help.py
+++ b/glances/plugins/glances_help.py
@@ -32,18 +32,15 @@ class Plugin(GlancesPlugin):
"""Glances' help plugin."""
- def __init__(self, args=None):
+ def __init__(self, args=None, config=None):
"""Init the plugin."""
GlancesPlugin.__init__(self, args=args)
+ # Set the config instance
+ self.config = config
+
# We want to display the stat in the curse interface
self.display_curse = True
- # Set the message position
- # It is NOT the curse position but the Glances column/line
- # Enter -1 to right align
- self.column_curse = 0
- # Enter -1 to diplay bottom
- self.line_curse = 0
def update(self):
"""No stats. It is just a plugin to display the help."""
@@ -58,62 +55,88 @@ class Plugin(GlancesPlugin):
# Header
msg = '{0} {1}'.format(appname.title(), version)
ret.append(self.curse_add_line(msg, "TITLE"))
- msg = _(" with psutil {0}").format(psutil_version)
+ msg = _(" with PSutil {0}").format(psutil_version)
ret.append(self.curse_add_line(msg))
ret.append(self.curse_new_line())
+ # Configuration file path
+ try:
+ msg = '{0}: {1}'.format(_("Configuration file"), self.config.get_loaded_config_file())
+ except AttributeError as e:
+ pass
+ else:
+ ret.append(self.curse_new_line())
+ ret.append(self.curse_add_line(msg))
+ ret.append(self.curse_new_line())
+
# Keys
msg_col = ' {0:1} {1:35}'
msg_col2 = ' {0:1} {1:35}'
ret.append(self.curse_new_line())
- msg = msg_col.format(_("a"), _("Sort processes automatically"))
+ msg = msg_col.format("a", _("Sort processes automatically"))
ret.append(self.curse_add_line(msg))
- msg = msg_col2.format(_("b"), _("Bytes or bits for network I/O"))
+ msg = msg_col2.format("b", _("Bytes or bits for network I/O"))
ret.append(self.curse_add_line(msg))
ret.append(self.curse_new_line())
- msg = msg_col.format(_("c"), _("Sort processes by CPU%"))
+ msg = msg_col.format("c", _("Sort processes by CPU%"))
ret.append(self.curse_add_line(msg))
- msg = msg_col2.format(_("l"), _("Show/hide logs (alerts)"))
+ msg = msg_col2.format("l", _("Show/hide logs (alerts)"))
ret.append(self.curse_add_line(msg))
ret.append(self.curse_new_line())
- msg = msg_col.format(_("m"), _("Sort processes by MEM%"))
+ msg = msg_col.format("m", _("Sort processes by MEM%"))
ret.append(self.curse_add_line(msg))
- msg = msg_col2.format(_("w"), _("Delete warning alerts"))
+ msg = msg_col2.format("w", _("Delete warning alerts"))
ret.append(self.curse_add_line(msg))
ret.append(self.curse_new_line())
- msg = msg_col.format(_("p"), _("Sort processes by name"))
+ msg = msg_col.format("p", _("Sort processes by name"))
ret.append(self.curse_add_line(msg))
- msg = msg_col2.format(_("x"), _("Delete warning and critical alerts"))
+ msg = msg_col2.format("x", _("Delete warning and critical alerts"))
ret.append(self.curse_add_line(msg))
ret.append(self.curse_new_line())
- msg = msg_col.format(_("i"), _("Sort processes by I/O rate"))
+ msg = msg_col.format("i", _("Sort processes by I/O rate"))
ret.append(self.curse_add_line(msg))
- msg = msg_col2.format(_("1"), _("Global CPU or per-CPU stats"))
+ msg = msg_col2.format("1", _("Global CPU or per-CPU stats"))
ret.append(self.curse_add_line(msg))
ret.append(self.curse_new_line())
- msg = msg_col.format(_("d"), _("Show/hide disk I/O stats"))
+ msg = msg_col.format("d", _("Show/hide disk I/O stats"))
ret.append(self.curse_add_line(msg))
- msg = msg_col2.format(_("h"), _("Show/hide this help screen"))
+ msg = msg_col2.format("h", _("Show/hide this help screen"))
ret.append(self.curse_add_line(msg))
ret.append(self.curse_new_line())
- msg = msg_col.format(_("f"), _("Show/hide file system stats"))
+ msg = msg_col.format("f", _("Show/hide file system stats"))
ret.append(self.curse_add_line(msg))
- msg = msg_col2.format(_("t"), _("View network I/O as combination"))
+ msg = msg_col2.format("t", _("View network I/O as combination"))
ret.append(self.curse_add_line(msg))
ret.append(self.curse_new_line())
- msg = msg_col.format(_("n"), _("Show/hide network stats"))
+ msg = msg_col.format("n", _("Show/hide network stats"))
ret.append(self.curse_add_line(msg))
- msg = msg_col2.format(_("u"), _("View cumulative network I/O"))
+ msg = msg_col2.format("u", _("View cumulative network I/O"))
ret.append(self.curse_add_line(msg))
ret.append(self.curse_new_line())
- msg = msg_col.format(_("s"), _("Show/hide sensors stats"))
+ msg = msg_col.format("s", _("Show/hide sensors stats"))
ret.append(self.curse_add_line(msg))
- msg = msg_col2.format(_("z"), _("Enable/disable processes stats"))
+ msg = msg_col2.format("g", _("Generate graphs for current history"))
ret.append(self.curse_add_line(msg))
ret.append(self.curse_new_line())
- msg = msg_col.format(_("q"), _("Quit (Esc and Ctrl-C also work)"))
+ msg = msg_col.format("z", _("Enable/disable processes stats"))
ret.append(self.curse_add_line(msg))
+ msg = msg_col2.format("r", _("Reset history"))
+ ret.append(self.curse_add_line(msg))
+ ret.append(self.curse_new_line())
+ msg = msg_col.format("e", _("Enable/disable top extended stats"))
+ ret.append(self.curse_add_line(msg))
+ msg = msg_col2.format("q", _("Quit (Esc and Ctrl-C also work)"))
+ ret.append(self.curse_add_line(msg))
+ ret.append(self.curse_new_line())
+ msg = msg_col.format("/", _("Enable/disable short processes name"))
+ ret.append(self.curse_add_line(msg))
+
+ ret.append(self.curse_new_line())
+ ret.append(self.curse_new_line())
+ msg = '{0}: {1}'.format("ENTER", _("Edit the process filter patern"))
+ ret.append(self.curse_add_line(msg))
+
# Return the message with decoration
return ret
diff --git a/glances/plugins/glances_load.py b/glances/plugins/glances_load.py
index 4b6a7a14..22a3cd04 100644
--- a/glances/plugins/glances_load.py
+++ b/glances/plugins/glances_load.py
@@ -23,6 +23,7 @@
import os
# Import Glances libs
+from glances.core.glances_globals import logger
from glances.plugins.glances_core import Plugin as CorePlugin
from glances.plugins.glances_plugin import GlancesPlugin
@@ -34,6 +35,13 @@ snmp_oid = {'min1': '1.3.6.1.4.1.2021.10.1.3.1',
'min5': '1.3.6.1.4.1.2021.10.1.3.2',
'min15': '1.3.6.1.4.1.2021.10.1.3.3'}
+# Define the history items list
+# All items in this list will be historised if the --enable-history tag is set
+# 'color' define the graph color in #RGB format
+items_history_list = [{'name': 'min1', 'color': '#0000FF'},
+ {'name': 'min5', 'color': '#0000AA'},
+ {'name': 'min15', 'color': '#000044'}]
+
class Plugin(GlancesPlugin):
@@ -44,20 +52,20 @@ class Plugin(GlancesPlugin):
def __init__(self, args=None):
"""Init the plugin."""
- GlancesPlugin.__init__(self, args=args)
+ GlancesPlugin.__init__(self, args=args, items_history_list=items_history_list)
# We want to display the stat in the curse interface
self.display_curse = True
- # Set the message position
- # It is NOT the curse position but the Glances column/line
- # Enter -1 to right align
- self.column_curse = 1
- # Enter -1 to diplay bottom
- self.line_curse = 1
# Init stats
self.reset()
+ # Call CorePlugin in order to display the core number
+ try:
+ self.nb_log_core = CorePlugin(args=self.args).update()["log"]
+ except Exception:
+ self.nb_log_core = 0
+
def reset(self):
"""Reset/init the stats."""
self.stats = {}
@@ -67,12 +75,6 @@ class Plugin(GlancesPlugin):
# Reset stats
self.reset()
- # Call CorePlugin in order to display the core number
- try:
- nb_log_core = CorePlugin().update()["log"]
- except Exception:
- nb_log_core = 0
-
if self.get_input() == 'local':
# Update stats using the standard system lib
@@ -85,19 +87,28 @@ class Plugin(GlancesPlugin):
self.stats = {'min1': load[0],
'min5': load[1],
'min15': load[2],
- 'cpucore': nb_log_core}
+ 'cpucore': self.nb_log_core}
elif self.get_input() == 'snmp':
# Update stats using SNMP
self.stats = self.set_stats_snmp(snmp_oid=snmp_oid)
- self.stats['cpucore'] = nb_log_core
-
if self.stats['min1'] == '':
self.reset()
return self.stats
- for key in self.stats.iterkeys():
- self.stats[key] = float(self.stats[key])
+ # Python 3 return a dict like:
+ # {'min1': "b'0.08'", 'min5': "b'0.12'", 'min15': "b'0.15'"}
+ try:
+ iteritems = self.stats.iteritems()
+ except AttributeError:
+ iteritems = self.stats.items()
+ for k, v in iteritems:
+ self.stats[k] = float(v)
+
+ self.stats['cpucore'] = self.nb_log_core
+
+ # Update the history list
+ self.update_stats_history()
return self.stats
@@ -116,7 +127,7 @@ class Plugin(GlancesPlugin):
ret.append(self.curse_add_line(msg, "TITLE"))
# Core number
if self.stats['cpucore'] > 0:
- msg = _("{0}-core").format(self.stats['cpucore'], '>1')
+ msg = _("{0:d}-core").format(int(self.stats['cpucore']), '>1')
ret.append(self.curse_add_line(msg))
# New line
ret.append(self.curse_new_line())
diff --git a/glances/plugins/glances_mem.py b/glances/plugins/glances_mem.py
index c89ac343..6e6ed101 100644
--- a/glances/plugins/glances_mem.py
+++ b/glances/plugins/glances_mem.py
@@ -30,12 +30,25 @@ import psutil
# Total RAM Shared: .1.3.6.1.4.1.2021.4.13.0
# Total RAM Buffered: .1.3.6.1.4.1.2021.4.14.0
# Total Cached Memory: .1.3.6.1.4.1.2021.4.15.0
-snmp_oid = {'total': '1.3.6.1.4.1.2021.4.5.0',
- # 'used': '1.3.6.1.4.1.2021.4.6.0',
- 'free': '1.3.6.1.4.1.2021.4.11.0',
- 'shared': '1.3.6.1.4.1.2021.4.13.0',
- 'buffers': '1.3.6.1.4.1.2021.4.14.0',
- 'cached': '1.3.6.1.4.1.2021.4.15.0'}
+# Note: For Windows, stats are in the FS table
+snmp_oid = {'default': {'total': '1.3.6.1.4.1.2021.4.5.0',
+ 'free': '1.3.6.1.4.1.2021.4.11.0',
+ 'shared': '1.3.6.1.4.1.2021.4.13.0',
+ 'buffers': '1.3.6.1.4.1.2021.4.14.0',
+ 'cached': '1.3.6.1.4.1.2021.4.15.0'},
+ 'windows': {'mnt_point': '1.3.6.1.2.1.25.2.3.1.3',
+ 'alloc_unit': '1.3.6.1.2.1.25.2.3.1.4',
+ 'size': '1.3.6.1.2.1.25.2.3.1.5',
+ 'used': '1.3.6.1.2.1.25.2.3.1.6'},
+ 'esxi': {'mnt_point': '1.3.6.1.2.1.25.2.3.1.3',
+ 'alloc_unit': '1.3.6.1.2.1.25.2.3.1.4',
+ 'size': '1.3.6.1.2.1.25.2.3.1.5',
+ 'used': '1.3.6.1.2.1.25.2.3.1.6'}}
+
+# Define the history items list
+# All items in this list will be historised if the --enable-history tag is set
+# 'color' define the graph color in #RGB format
+items_history_list = [