1 # -*- coding: utf-8 -*-
2 # Description: hddtemp netdata python.d plugin
3 # Author: Pawel Krupa (paulfantom)
5 from base import SimpleService
8 # default module values (can be overridden per job in `config`)
13 # default job configuration (overridden by python.d.plugin)
14 # config = {'local': {
15 # 'update_every': update_every,
17 # 'priority': priority,
18 # 'host': 'localhost',
22 ORDER = ['temperatures']
26 'options': ['disks_temp', 'temperature', 'Celsius', 'Disks temperature', 'hddtemp.temp', 'line'],
28 # lines are created dynamically in `check()` method
33 class Service(SimpleService):
34 def __init__(self, configuration=None, name=None):
35 self.host = "localhost"
37 SimpleService.__init__(self, configuration=configuration, name=name)
39 self.definitions = CHARTS
43 Get data from TCP/IP socket
47 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
48 s.connect((self.host, self.port))
49 raw = s.recv(4096).split("|")[:-1]
55 for i in range(len(raw) // 5):
60 data[raw[i*5+1].replace("/dev/", "")] = val
64 if self.name is not None or self.name != str(None):
67 self.name = str(self.name)
69 self.host = str(self.configuration['host'])
70 except (KeyError, TypeError):
71 self.error("No host specified. Using: '" + self.host + "'")
73 self.port = int(self.configuration['port'])
74 except (KeyError, TypeError):
75 self.error("No port specified. Using: '" + str(self.port) + "'")
77 data = self._get_data()
79 self.error("No data received")
83 self.definitions[ORDER[0]]['lines'].append([name])