1 # Description: base for netdata python.d plugins
2 # Author: Pawel Krupa (paulfantom)
8 class BaseService(object):
9 def __init__(self,name=None,configuration=None):
10 if configuration is None:
11 self.error("BaseService: no configuration parameters supplied. Cannot create Service.")
14 self._extract_base_config(configuration)
15 self._create_timetable()
16 self.execution_name = ""
18 def _extract_base_config(self,config):
19 self.update_every = int(config['update_every'])
20 self.priority = int(config['priority'])
21 self.retries = int(config['retries'])
22 self.retries_left = self.retries
24 def _create_timetable(self,freq=None):
26 freq = self.update_every
28 self.timetable = {'last' : now,
29 'next' : now - (now % freq) + freq,
33 def error(self, msg, exception=""):
35 exception = " " + str(exception).replace("\n"," ")
36 sys.stderr.write(str(msg)+exception+"\n")
40 # TODO notify about not overriden function
41 self.error("Where is your check()?")
45 # TODO notify about not overriden function
46 self.error("Where is your create()?")
50 # TODO notify about not overriden function
51 self.error("Where is your update()?")