summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Hennion <nicolas@nicolargo.com>2014-03-28 12:23:39 +0100
committerNicolas Hennion <nicolas@nicolargo.com>2014-03-28 12:23:39 +0100
commitfb3745d8b6f6316548dc0d47f90ed83e5ab3f459 (patch)
treeab2a367092ea1f661827c9a815d1fac8d7ac4f50
parentf158a729e2001c1f349cd30a8961e78279b01f8c (diff)
Hide config list works for network interface
-rw-r--r--conf/glances-monitor.conf4
-rw-r--r--glances/plugins/glances_network.py3
-rw-r--r--glances/plugins/glances_plugin.py26
3 files changed, 30 insertions, 3 deletions
diff --git a/conf/glances-monitor.conf b/conf/glances-monitor.conf
index 9521ee45..04eefb75 100644
--- a/conf/glances-monitor.conf
+++ b/conf/glances-monitor.conf
@@ -50,11 +50,11 @@ critical=90
[network]
# Define the list of hidden network interfaces (comma separeted)
-#hide=lo
+hide=lo
[diskio]
# Define the list of hidden disks (comma separeted)
-#hide=sda2,sda5
+hide=sda2,sda5
[fs]
# Default limits for free filesytem space in %
diff --git a/glances/plugins/glances_network.py b/glances/plugins/glances_network.py
index a9853723..ae89a954 100644
--- a/glances/plugins/glances_network.py
+++ b/glances/plugins/glances_network.py
@@ -135,6 +135,9 @@ class Plugin(GlancesPlugin):
ret.append(self.curse_add_line(msg))
# Interface list (sorted by name)
for i in sorted(self.stats, key=lambda network: network['interface_name']):
+ # Do not display hidden interfaces
+ if (self.is_hide(i['interface_name'])):
+ continue
# Format stats
ifname = i['interface_name'].split(':')[0]
if (args.byte):
diff --git a/glances/plugins/glances_plugin.py b/glances/plugins/glances_plugin.py
index 34557882..84eea485 100644
--- a/glances/plugins/glances_plugin.py
+++ b/glances/plugins/glances_plugin.py
@@ -71,7 +71,10 @@ class GlancesPlugin(object):
for s, v in config.items(self.plugin_name):
# Read limits
# print "\t%s = %s" % (self.plugin_name + '_' + s, v)
- self.limits[self.plugin_name + '_' + s] = config.get_option(self.plugin_name, s)
+ try:
+ self.limits[self.plugin_name + '_' + s] = config.get_option(self.plugin_name, s)
+ except ValueError, e:
+ self.limits[self.plugin_name + '_' + s] = config.get_raw_option(self.plugin_name, s).split(",")
def set_limits(self, input_limits):
# Set the limits to input_limits
@@ -145,6 +148,27 @@ class GlancesPlugin(object):
else:
return self.limits[self.plugin_name + '_' + header + '_' + 'warning']
+ def get_hide(self, header=""):
+ """
+ Return the hide configuration list key for the current plugin
+ """
+ if (header == ""):
+ try:
+ return self.limits[self.plugin_name + '_' + 'hide']
+ except Exception, e:
+ return []
+ else:
+ try:
+ return self.limits[self.plugin_name + '_' + header + '_' + 'hide']
+ except Exception, e:
+ return []
+
+ def is_hide(self, value, header=""):
+ """
+ Return True if the value is in the hide configuration list
+ """
+ return value in self.get_hide(header=header)
+
def get_limit_careful(self, header=""):
if (header == ""):
return self.limits[self.plugin_name + '_' + 'careful']