summaryrefslogtreecommitdiffstats
path: root/python.d/sensors.chart.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2018-11-07 12:22:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2018-11-07 12:22:44 +0000
commit1e6c93250172946eeb38e94a92a1fd12c9d3011e (patch)
tree8ca5e16dfc7ad6b3bf2738ca0a48408a950f8f7e /python.d/sensors.chart.py
parentUpdate watch file (diff)
downloadnetdata-1e6c93250172946eeb38e94a92a1fd12c9d3011e.tar.xz
netdata-1e6c93250172946eeb38e94a92a1fd12c9d3011e.zip
Merging upstream version 1.11.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'python.d/sensors.chart.py')
-rw-r--r--python.d/sensors.chart.py139
1 files changed, 0 insertions, 139 deletions
diff --git a/python.d/sensors.chart.py b/python.d/sensors.chart.py
deleted file mode 100644
index 06e420b68..000000000
--- a/python.d/sensors.chart.py
+++ /dev/null
@@ -1,139 +0,0 @@
-# -*- coding: utf-8 -*-
-# Description: sensors netdata python.d plugin
-# Author: Pawel Krupa (paulfantom)
-
-from bases.FrameworkServices.SimpleService import SimpleService
-from third_party import lm_sensors as sensors
-
-# default module values (can be overridden per job in `config`)
-# update_every = 2
-
-ORDER = ['temperature', 'fan', 'voltage', 'current', 'power', 'energy', 'humidity']
-
-# This is a prototype of chart definition which is used to dynamically create self.definitions
-CHARTS = {
- 'temperature': {
- 'options': [None, ' temperature', 'Celsius', 'temperature', 'sensors.temperature', 'line'],
- 'lines': [
- [None, None, 'absolute', 1, 1000]
- ]},
- 'voltage': {
- 'options': [None, ' voltage', 'Volts', 'voltage', 'sensors.voltage', 'line'],
- 'lines': [
- [None, None, 'absolute', 1, 1000]
- ]},
- 'current': {
- 'options': [None, ' current', 'Ampere', 'current', 'sensors.current', 'line'],
- 'lines': [
- [None, None, 'absolute', 1, 1000]
- ]},
- 'power': {
- 'options': [None, ' power', 'Watt', 'power', 'sensors.power', 'line'],
- 'lines': [
- [None, None, 'absolute', 1, 1000000]
- ]},
- 'fan': {
- 'options': [None, ' fans speed', 'Rotations/min', 'fans', 'sensors.fan', 'line'],
- 'lines': [
- [None, None, 'absolute', 1, 1000]
- ]},
- 'energy': {
- 'options': [None, ' energy', 'Joule', 'energy', 'sensors.energy', 'areastack'],
- 'lines': [
- [None, None, 'incremental', 1, 1000000]
- ]},
- 'humidity': {
- 'options': [None, ' humidity', 'Percent', 'humidity', 'sensors.humidity', 'line'],
- 'lines': [
- [None, None, 'absolute', 1, 1000]
- ]}
-}
-
-LIMITS = {
- 'temperature': [-127, 1000],
- 'voltage': [-127, 127],
- 'current': [-127, 127],
- 'fan': [0, 65535]
-}
-
-TYPE_MAP = {
- 0: 'voltage',
- 1: 'fan',
- 2: 'temperature',
- 3: 'power',
- 4: 'energy',
- 5: 'current',
- 6: 'humidity',
- 7: 'max_main',
- 16: 'vid',
- 17: 'intrusion',
- 18: 'max_other',
- 24: 'beep_enable'
-}
-
-
-class Service(SimpleService):
- def __init__(self, configuration=None, name=None):
- SimpleService.__init__(self, configuration=configuration, name=name)
- self.order = list()
- self.definitions = dict()
- self.chips = list()
-
- def get_data(self):
- data = dict()
- try:
- for chip in sensors.ChipIterator():
- prefix = sensors.chip_snprintf_name(chip)
- for feature in sensors.FeatureIterator(chip):
- sfi = sensors.SubFeatureIterator(chip, feature)
- for sf in sfi:
- val = sensors.get_value(chip, sf.number)
- break
- type_name = TYPE_MAP[feature.type]
- if type_name in LIMITS:
- limit = LIMITS[type_name]
- if val < limit[0] or val > limit[1]:
- continue
- data[prefix + "_" + str(feature.name.decode())] = int(val * 1000)
- except Exception as error:
- self.error(error)
- return None
-
- return data or None
-
- def create_definitions(self):
- for sensor in ORDER:
- for chip in sensors.ChipIterator():
- chip_name = sensors.chip_snprintf_name(chip)
- if self.chips and not any([chip_name.startswith(ex) for ex in self.chips]):
- 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:
- continue
- if TYPE_MAP[feature.type] == sensor:
- # create chart
- name = chip_name + "_" + TYPE_MAP[feature.type]
- if name not in self.order:
- self.order.append(name)
- chart_def = list(CHARTS[sensor]['options'])
- chart_def[1] = chip_name + chart_def[1]
- self.definitions[name] = {'options': chart_def}
- self.definitions[name]['lines'] = []
- line = list(CHARTS[sensor]['lines'][0])
- line[0] = chip_name + "_" + str(feature.name.decode())
- line[1] = sensors.get_label(chip, feature)
- self.definitions[name]['lines'].append(line)
-
- def check(self):
- try:
- sensors.init()
- except Exception as error:
- self.error(error)
- return False
-
- self.create_definitions()
-
- return True
-