提交 f038be4c 编写于 作者: N Nicolargo

Don't show interfaces in down state #765

上级 dcbb96f1
......@@ -19,6 +19,7 @@ Enhancements and new features:
* Add option (--disable-bg) to disable ANSI background colours (issue #738 from okdana)
* [WebUI] add "pointer" cursor for sortable columns (issue #704 from @notFloran)
* [WebUI] Make web page title configurable (issue #724)
* Do not show interface in down state (issue #765)
Bugs corrected:
* Can't read sensors on a Thinkpad (issue #711)
......
......@@ -84,6 +84,13 @@ class Plugin(GlancesPlugin):
except UnicodeDecodeError:
return self.stats
# New in PsUtil 3.0: optionaly import the interface's status (issue #765)
netstatus = {}
try:
netstatus = psutil.net_if_stats()
except AttributeError:
pass
# Previous network interface stats are stored in the network_old variable
if not hasattr(self, 'network_old'):
# First call, we init the network_old var
......@@ -119,6 +126,12 @@ class Plugin(GlancesPlugin):
except KeyError:
continue
else:
# Optional stats (only compliant with PsUtil 3.0+)
try:
netstat['is_up'] = netstatus[net].isup
except (KeyError, AttributeError):
pass
# Set the key
netstat['key'] = self.get_key()
self.stats.append(netstat)
......@@ -255,6 +268,9 @@ class Plugin(GlancesPlugin):
# Do not display hidden interfaces
if self.is_hide(i['interface_name']):
continue
# Do not display interface in down state (issue #765)
if ('is_up' in i) and (i['is_up'] is False):
continue
# Format stats
# Is there an alias for the interface name ?
ifrealname = i['interface_name'].split(':')[0]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册