diff options
author | Costa Tsaousis <costa@tsaousis.gr> | 2016-12-25 12:57:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-25 12:57:08 +0200 |
commit | 2d8dcd4a2be1c303b5887ca812478c7545a0fcf7 (patch) | |
tree | 070345a3001874f27d45da6c93f3f13fd527ac77 /python.d | |
parent | 77a85c91865359185007bda3f4f99069cb5abb81 (diff) | |
parent | a55ebd6d42d6c39484765e8a83e47d3f4d7f4814 (diff) |
Merge pull request #1438 from l2isbad/hddtemp_chart_py_enhancement
Hddtemp chart py enhancement
Diffstat (limited to 'python.d')
-rw-r--r-- | python.d/hddtemp.chart.py | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/python.d/hddtemp.chart.py b/python.d/hddtemp.chart.py index 2e7695db54..8a98995be9 100644 --- a/python.d/hddtemp.chart.py +++ b/python.d/hddtemp.chart.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Description: hddtemp netdata python.d module # Author: Pawel Krupa (paulfantom) +# Modified by l2isbad import os from base import SocketService @@ -21,15 +22,6 @@ retries = 60 ORDER = ['temperatures'] -CHARTS = { - 'temperatures': { - 'options': ['disks_temp', 'Disks Temperatures', 'Celsius', 'temperatures', 'hddtemp.temperatures', 'line'], - 'lines': [ - # lines are created dynamically in `check()` method - ]} -} - - class Service(SocketService): def __init__(self, configuration=None, name=None): SocketService.__init__(self, configuration=configuration, name=name) @@ -38,7 +30,10 @@ class Service(SocketService): self.host = "127.0.0.1" self.port = 7634 self.order = ORDER - self.definitions = CHARTS + self.fahrenheit = ('Fahrenheit', lambda x: x * 9 / 5 + 32) if self.configuration.get('fahrenheit') else False + self.whatever = ('Whatever', lambda x: x * 33 / 22 + 11) if self.configuration.get('whatever') else False + self.choice = (choice for choice in [self.fahrenheit, self.whatever] if choice) + self.calc = lambda x: x self.disks = [] def _get_disks(self): @@ -82,7 +77,7 @@ class Service(SocketService): if not raw[i*5+1] in self.disks: continue try: - val = int(raw[i*5+3]) + val = self.calc(int(raw[i*5+3])) except ValueError: val = 0 data[raw[i*5+1].replace("/dev/", "")] = val @@ -105,9 +100,21 @@ class Service(SocketService): if data is None: return False + self.definitions = { + 'temperatures': { + 'options': ['disks_temp', 'Disks Temperatures', 'temperatures', 'hddtemp.temperatures', 'line'], + 'lines': [ + # lines are created dynamically in `check()` method + ]} + } + try: + self.choice = next(self.choice) + except StopIteration: + self.definitions[ORDER[0]]['options'].insert(2, 'Celsius') + else: + self.calc = self.choice[1] + self.definitions[ORDER[0]]['options'].insert(2, self.choice[0]) + for name in data: self.definitions[ORDER[0]]['lines'].append([name]) - return True - - |