mirror of
https://github.com/nicolargo/glances.git
synced 2025-01-07 02:20:26 +03:00
Merge branch 'issue718' into develop
This commit is contained in:
commit
0c49fecf6f
@ -91,7 +91,9 @@ class Plugin(GlancesPlugin):
|
|||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
return self.stats
|
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 = {}
|
netstatus = {}
|
||||||
try:
|
try:
|
||||||
netstatus = psutil.net_if_stats()
|
netstatus = psutil.net_if_stats()
|
||||||
@ -137,11 +139,19 @@ class Plugin(GlancesPlugin):
|
|||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
# Optional stats (only compliant with PsUtil 3.0+)
|
# Optional stats (only compliant with PsUtil 3.0+)
|
||||||
|
# Interface status
|
||||||
try:
|
try:
|
||||||
netstat['is_up'] = netstatus[net].isup
|
netstat['is_up'] = netstatus[net].isup
|
||||||
except (KeyError, AttributeError):
|
except (KeyError, AttributeError):
|
||||||
pass
|
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()
|
netstat['key'] = self.get_key()
|
||||||
self.stats.append(netstat)
|
self.stats.append(netstat)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user