summaryrefslogtreecommitdiffstats
path: root/python.d/sensors.chart.py
diff options
context:
space:
mode:
Diffstat (limited to 'python.d/sensors.chart.py')
-rw-r--r--python.d/sensors.chart.py29
1 files changed, 19 insertions, 10 deletions
diff --git a/python.d/sensors.chart.py b/python.d/sensors.chart.py
index 7abe7f080..23bccb97c 100644
--- a/python.d/sensors.chart.py
+++ b/python.d/sensors.chart.py
@@ -49,6 +49,13 @@ CHARTS = {
]}
}
+LIMITS = {
+ 'temperature': [-127, 1000],
+ 'voltage': [-127, 127],
+ 'current': [-127, 127],
+ 'fan': [0, 65535]
+}
+
TYPE_MAP = {
0: 'voltage',
1: 'fan',
@@ -82,6 +89,11 @@ class Service(SimpleService):
for sf in sfi:
val = sensors.get_value(chip, sf.number)
break
+ typeName = TYPE_MAP[feature.type]
+ if typeName in LIMITS:
+ limit = LIMITS[typeName];
+ if val < limit[0] or val > limit[1]:
+ continue
data[prefix + "_" + str(feature.name.decode())] = int(val * 1000)
except Exception as e:
self.error(e)
@@ -92,7 +104,6 @@ class Service(SimpleService):
return data
def _create_definitions(self):
- prev_chip = ""
for type in ORDER:
for chip in sensors.ChipIterator():
chip_name = sensors.chip_snprintf_name(chip)
@@ -105,19 +116,17 @@ class Service(SimpleService):
continue
if TYPE_MAP[feature.type] == type:
# create chart
- if chip_name != prev_chip:
- name = chip_name + "_" + TYPE_MAP[feature.type]
- if name not in self.order:
- self.order.append(name)
- chart_def = list(CHARTS[type]['options'])
- chart_def[1] = chip_name + chart_def[1]
- self.definitions[name] = {'options': chart_def}
- self.definitions[name]['lines'] = []
+ name = chip_name + "_" + TYPE_MAP[feature.type]
+ if name not in self.order:
+ self.order.append(name)
+ chart_def = list(CHARTS[type]['options'])
+ chart_def[1] = chip_name + chart_def[1]
+ self.definitions[name] = {'options': chart_def}
+ self.definitions[name]['lines'] = []
line = list(CHARTS[type]['lines'][0])
line[0] = chip_name + "_" + str(feature.name.decode())
line[1] = sensors.get_label(chip, feature)
self.definitions[name]['lines'].append(line)
- prev_chip = chip_name
def check(self):
try: