0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-05-08 11:00:27 +00:00

sensors module fix ()

* sensors: survive sensors.get_value Exception

* sensors: log unreadable subfeature in check

* sensors: add todos
This commit is contained in:
Ilya Mashchenko 2018-11-14 05:14:55 +09:00 committed by GitHub
parent 0f8b440c39
commit d0cc7910da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,13 +3,22 @@
# Author: Pawel Krupa (paulfantom)
# SPDX-License-Identifier: GPL-3.0-or-later
from bases.FrameworkServices.SimpleService import SimpleService
from third_party import lm_sensors as sensors
from bases.FrameworkServices.SimpleService import SimpleService
# default module values (can be overridden per job in `config`)
# update_every = 2
ORDER = ['temperature', 'fan', 'voltage', 'current', 'power', 'energy', 'humidity']
ORDER = [
'temperature',
'fan',
'voltage',
'current',
'power',
'energy',
'humidity',
]
# This is a prototype of chart definition which is used to dynamically create self.definitions
CHARTS = {
@ -94,9 +103,16 @@ class Service(SimpleService):
prefix = sensors.chip_snprintf_name(chip)
for feature in sensors.FeatureIterator(chip):
sfi = sensors.SubFeatureIterator(chip, feature)
val = None
for sf in sfi:
val = sensors.get_value(chip, sf.number)
break
try:
val = sensors.get_value(chip, sf.number)
break
# TODO: use specific error after upstream is fixed
except Exception:
continue
if val is None:
continue
type_name = TYPE_MAP[feature.type]
if type_name in LIMITS:
limit = LIMITS[type_name]
@ -117,8 +133,15 @@ class Service(SimpleService):
continue
for feature in sensors.FeatureIterator(chip):
sfi = sensors.SubFeatureIterator(chip, feature)
vals = [sensors.get_value(chip, sf.number) for sf in sfi]
if vals[0] == 0:
vals = list()
for sf in sfi:
try:
vals.append(sensors.get_value(chip, sf.number))
# TODO: use specific error after upstream is fixed
except Exception as error:
self.error('{0}: {1}'.format(sf.name, error))
continue
if not vals or vals[0] == 0:
continue
if TYPE_MAP[feature.type] == sensor:
# create chart