1 # Description: base for netdata python.d plugins
2 # Author: Pawel Krupa (paulfantom)
7 class BaseService(object):
8 def __init__(self,configuration=None):
9 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):
26 self.timetable = {'last' : now,
27 'next' : now - (now % self.update_every) + self.update_every,
28 'freq' : self.update_every}
31 def error(self, msg, exception=""):
33 exception = " " + str(exception).replace("\n"," ")
34 sys.stderr.write(str(msg)+exception+"\n")
38 # TODO notify about not overriden function
39 self.error("Where is your check()?")
43 # TODO notify about not overriden function
44 self.error("Where is your create()?")
48 # TODO notify about not overriden function
49 self.error("Where is your update()?")