mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-26 10:42:29 +03:00
Merge branch 'issue344' into develop
This commit is contained in:
commit
57e07faf02
1
NEWS
1
NEWS
@ -8,6 +8,7 @@ Version 3.1.1
|
||||
Enhancements and new features:
|
||||
|
||||
* Please add some sparklines! #1446
|
||||
* Add Load Average (similar to Linux) on Windows #344
|
||||
* Add authprovider for cassandra export (thanks to @EmilienMottet) #1395
|
||||
* Curses's browser server list sorting added (thanks to @limfreee) #1396
|
||||
* ElasticSearch: add date to index, unbreak object push (thanks to @genevera) # 1438
|
||||
|
@ -3,7 +3,7 @@
|
||||
Load
|
||||
====
|
||||
|
||||
*Availability: Unix*
|
||||
*Availability: Unix and Windows with a PsUtil version >= 5.6.2*
|
||||
|
||||
.. image:: ../_static/load.png
|
||||
|
||||
@ -14,8 +14,9 @@ on GNU/Linux operating system:
|
||||
waiting in the run-queue plus the number currently executing
|
||||
over 1, 5, and 15 minutes time periods."
|
||||
|
||||
Be aware that Load on Linux and BSD are different things, high
|
||||
`load on BSD`_ does not means high CPU load.
|
||||
Be aware that Load on Linux, BSD and Windows are different things, high
|
||||
`load on BSD`_ does not means high CPU load. The Windows load is emulated
|
||||
by the PsUtil lib (see `load on Windows`_)
|
||||
|
||||
Glances gets the number of CPU core to adapt the alerts.
|
||||
Alerts on load average are only set on 15 minutes time period.
|
||||
@ -38,3 +39,4 @@ Load avg Status
|
||||
|
||||
.. _load average: http://nosheep.net/story/defining-unix-load-average/
|
||||
.. _load on BSD: http://undeadly.org/cgi?action=article&sid=20090715034920
|
||||
.. _load on Windows: https://psutil.readthedocs.io/en/latest/#psutil.getloadavg
|
||||
|
@ -20,6 +20,7 @@
|
||||
"""Load plugin."""
|
||||
|
||||
import os
|
||||
import psutil
|
||||
|
||||
from glances.compat import iteritems
|
||||
from glances.plugins.glances_core import Plugin as CorePlugin
|
||||
@ -63,6 +64,17 @@ class Plugin(GlancesPlugin):
|
||||
except Exception:
|
||||
self.nb_log_core = 1
|
||||
|
||||
def _getloadavg(self):
|
||||
"""Get load average. On both Linux and Windows thanks to PsUtil"""
|
||||
try:
|
||||
return psutil.getloadavg()
|
||||
except AttributeError:
|
||||
pass
|
||||
try:
|
||||
return os.getloadavg()
|
||||
except OSError:
|
||||
return None
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
@ -74,15 +86,15 @@ class Plugin(GlancesPlugin):
|
||||
# Update stats using the standard system lib
|
||||
|
||||
# Get the load using the os standard lib
|
||||
try:
|
||||
load = os.getloadavg()
|
||||
except (OSError, AttributeError):
|
||||
load = self._getloadavg()
|
||||
if load is None:
|
||||
stats = self.get_init_value()
|
||||
else:
|
||||
stats = {'min1': load[0],
|
||||
'min5': load[1],
|
||||
'min15': load[2],
|
||||
'cpucore': self.nb_log_core}
|
||||
|
||||
elif self.input_method == 'snmp':
|
||||
# Update stats using SNMP
|
||||
stats = self.get_stats_snmp(snmp_oid=snmp_oid)
|
||||
|
Loading…
Reference in New Issue
Block a user