mirror of
https://github.com/nicolargo/glances.git
synced 2024-11-24 13:23:12 +03:00
Hide config list works for network interface
This commit is contained in:
parent
f158a729e2
commit
fb3745d8b6
@ -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 %
|
||||
|
@ -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):
|
||||
|
@ -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']
|
||||
|
Loading…
Reference in New Issue
Block a user