Merge branch 'issue1018' into develop

This commit is contained in:
nicolargo
2017-02-11 10:06:11 +01:00
8 changed files with 35 additions and 45 deletions

7
NEWS
View File

@@ -5,6 +5,11 @@ Glances Version 2
Version 2.x
=============
Enhancements and new features:
* Use new sensors-related APIs of Psutil 5.1.0 (issue #1018)
=> Remove Py3Sensors and Batinfo dependencies
Bugs corrected:
* Unable to launch Glances on Windows (issue #1021)
@@ -62,9 +67,9 @@ Enhancements and new features:
* System uptime in export (issue #890)
* Refactor the --disable-* options (issue #948)
* PID column too small if kernel.pid_max is > 99999 (issue #959)
Bugs corrected:
* Glances RAID plugin Traceback (issue #927)
* Default AMP crashes when 'command' given (issue #933)
* Default AMP ignores `enable` setting (issue #932)

View File

@@ -50,7 +50,6 @@ Requirements
Optional dependencies:
- ``batinfo`` (for battery monitoring support) [Linux-only]
- ``bernhard`` (for the Riemann export module)
- ``bottle`` (for Web server mode)
- ``cassandra-driver`` (for the Cassandra export module)
@@ -64,7 +63,6 @@ Optional dependencies:
- ``nvidia-ml-py`` (for the GPU plugin) [Python 2-only]
- ``pika`` (for the RabbitMQ/ActiveMQ export module)
- ``potsdb`` (for the OpenTSDB export module)
- ``py3sensors`` (for hardware monitoring support) [Linux-only]
- ``py-cpuinfo`` (for the Quicklook CPU info module)
- ``pymdstat`` (for RAID support) [Linux-only]
- ``pysnmp`` (for SNMP support)
@@ -132,12 +130,11 @@ just install psutil from the binary installation file.
to install the *wireless-tools* package on your system.
You can also install the following libraries in order to use optional
features (like the Web interface, exports modules, sensors...):
features (like the Web interface, exports modules...):
.. code-block:: console
pip install glances[action,batinfo,browser,cpuinfo,chart,docker,export,folders,gpu,ip,raid,snmp,web,wifi]
pip install https://bitbucket.org/gleb_zhulik/py3sensors/get/tip.zip
pip install glances[action,browser,cpuinfo,chart,docker,export,folders,gpu,ip,raid,snmp,web,wifi]
To upgrade Glances to the latest version:

View File

@@ -7,10 +7,7 @@ Sensors
.. image:: ../_static/sensors.png
Glances can displays the sensors information using ``lm-sensors``,
``hddtemp`` and `batinfo`_.
All of the above libraries are available only on Linux.
Glances can displays the sensors information using ``PsUtil`` and ``hddtemp``.
As of ``lm-sensors``, a filter is being applied in order to display
temperature and fan speed only.
@@ -20,5 +17,3 @@ There is no alert on this information.
.. note::
Limit values and sensors alias names can be defined in the
configuration file under the ``[sensors]`` section.
.. _batinfo: https://github.com/nicolargo/batinfo

View File

@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "GLANCES" "1" "Feb 07, 2017" "2.8.2" "Glances"
.TH "GLANCES" "1" "Feb 11, 2017" "2.8.3_DEVELOP" "Glances"
.SH NAME
glances \- An eye on your system
.

View File

@@ -19,14 +19,10 @@
"""Sensors plugin."""
# Sensors library (optional; Linux-only)
# Py3Sensors: https://bitbucket.org/gleb_zhulik/py3sensors
try:
import sensors
except ImportError:
pass
import psutil
from glances.logger import logger
from glances.compat import iteritems
from glances.plugins.glances_batpercent import Plugin as BatPercentPlugin
from glances.plugins.glances_hddtemp import Plugin as HddTempPlugin
from glances.plugins.glances_plugin import GlancesPlugin
@@ -223,13 +219,14 @@ class Plugin(GlancesPlugin):
class GlancesGrabSensors(object):
"""Get sensors stats using the py3sensors library."""
"""Get sensors stats."""
def __init__(self):
"""Init sensors stats."""
try:
sensors.init()
except Exception:
# XXX: psutil>=5.1.0 is required
self.stemps = psutil.sensors_temperatures()
except AttributeError:
self.initok = False
else:
self.initok = True
@@ -246,24 +243,25 @@ class GlancesGrabSensors(object):
# Reset the list
self.reset()
if self.initok:
for chip in sensors.iter_detected_chips():
for feature in chip:
sensors_current = {}
if feature.name.startswith(b'temp'):
# Temperature sensor
sensors_current['unit'] = SENSOR_TEMP_UNIT
elif feature.name.startswith(b'fan'):
# Fan speed sensor
sensors_current['unit'] = SENSOR_FAN_UNIT
if sensors_current:
try:
sensors_current['label'] = feature.label
sensors_current['value'] = int(feature.get_value())
except Exception as e:
logger.debug("Cannot grab sensor stat (%s)" % e)
else:
self.sensors_list.append(sensors_current)
if not self.initok:
return self.sensors_list
# Temperature sensor
for chipname, chip in iteritems(self.stemps):
i = 1
for feature in chip:
sensors_current = {}
# Sensor name
if feature.label == '':
sensors_current['label'] = chipname + ' ' + str(i)
else:
sensors_current['label'] = feature.label
# Temperature and unit
sensors_current['value'] = int(feature.current)
sensors_current['unit'] = SENSOR_TEMP_UNIT
# Add sensor to the list
self.sensors_list.append(sensors_current)
i += 1
return self.sensors_list

View File

@@ -1,4 +1,3 @@
batinfo
bernhard
bottle
cassandra-driver
@@ -21,4 +20,3 @@ scandir; python_version < "3.5"
statsd
wifi
zeroconf
https://bitbucket.org/gleb_zhulik/py3sensors/get/tip.zip

View File

@@ -79,7 +79,6 @@ setup(
install_requires=get_install_requires(),
extras_require={
'action': ['pystache'],
'batinfo': ['batinfo'],
'browser': ['zeroconf>=0.17'],
'cpuinfo': ['py-cpuinfo'],
'chart': ['matplotlib'],

View File

@@ -14,8 +14,6 @@ deps =
requests
psutil
bottle
batinfo
https://bitbucket.org/gleb_zhulik/py3sensors/get/tip.tar.gz
commands =
python unitest.py
python unitest-restful.py