1 # Description: base for netdata python.d plugins
2 # Author: Pawel Krupa (paulfantom)
8 class BaseService(object):
9 def __init__(self, configuration=None):
10 if configuration is None:
11 self.error("BaseService: no configuration parameters supplied. Cannot create Service.")
14 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(msg, exception=""):
36 exception = " " + str(exception).replace("\n"," ")
37 sys.stderr.write(str(msg)+exception+"\n")
41 # TODO notify about not overridden function
42 self.error("Where is your check()?")
46 # TODO notify about not overridden function
47 self.error("Where is your create()?")
51 # TODO notify about not overridden function
52 self.error("Where is your update()?")