提交 0c49fecf 编写于 作者: N nicolargo

Merge branch 'issue718' into develop

......@@ -91,7 +91,9 @@ class Plugin(GlancesPlugin):
except UnicodeDecodeError:
return self.stats
# New in PsUtil 3.0: optionaly import the interface's status (issue #765)
# New in PsUtil 3.0
# - import the interface's status (issue #765)
# - import the interface's speed (issue #718)
netstatus = {}
try:
netstatus = psutil.net_if_stats()
......@@ -137,11 +139,19 @@ class Plugin(GlancesPlugin):
continue
else:
# Optional stats (only compliant with PsUtil 3.0+)
# Interface status
try:
netstat['is_up'] = netstatus[net].isup
except (KeyError, AttributeError):
pass
# Set the key
# Interface speed in Mbps, convert it to bps
# Can be always 0 on some OS
try:
netstat['speed'] = netstatus[net].speed * 1048576
except (KeyError, AttributeError):
pass
# Finaly, set the key
netstat['key'] = self.get_key()
self.stats.append(netstat)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册