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):
11 if configuration is None:
12 self.error("BaseService: no configuration parameters supplied. Cannot create Service.")
15 self._extract_base_config(configuration)
16 self._create_timetable()
17 self.execution_name = ""
19 def _extract_base_config(self,config):
20 self.update_every = int(config['update_every'])
21 self.priority = int(config['priority'])
22 self.retries = int(config['retries'])
23 self.retries_left = self.retries
25 def _create_timetable(self,freq=None):
27 freq = self.update_every
29 self.timetable = {'last' : now,
30 'next' : now - (now % freq) + freq,
34 def error(self, msg, exception=""):
36 exception = " " + str(exception).replace("\n"," ")
37 sys.stderr.write(str(msg)+exception+"\n")
41 # TODO notify about not overriden function
42 self.error("Where is your check()?")
46 # TODO notify about not overriden function
47 self.error("Where is your create()?")
51 # TODO notify about not overriden function
52 self.error("Where is your update()?")