Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sensors module fix #4651

Merged
merged 3 commits into from Nov 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 29 additions & 6 deletions collectors/python.d.plugin/sensors/sensors.chart.py
Expand Up @@ -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 = {
Expand Down Expand Up @@ -94,9 +103,16 @@ def get_data(self):
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]
Expand All @@ -117,8 +133,15 @@ def create_definitions(self):
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
Expand Down