1 # Description: base for netdata python.d plugins
2 # Author: Pawel Krupa (paulfantom)
4 class BaseService(object):
5 def __init__(self,configuration=None,update_every=None,priority=None,retries=None):
6 if None in (configuration,update_every,priority,retries):
8 self.error("BaseService: no configuration parameters supplied. Cannot create Service.")
11 self._parse_base_config(configuration,update_every,priority,retries)
13 def _parse_base_config(self,config,update_every,priority,retries):
14 # parse configuration options to run this Service
16 self.update_every = int(config['update_every'])
17 except (KeyError, ValueError):
18 self.update_every = update_every
20 self.priority = int(config['priority'])
21 except (KeyError, ValueError):
22 self.priority = priority
24 self.retries = int(config['retries'])
25 except (KeyError, ValueError):
26 self.retries = retries
27 self.retries_left = self.retries
29 def error(self, msg, exception=""):
31 exception = " " + str(exception).replace("\n"," ")
32 sys.stderr.write(str(msg)+exception+"\n")
36 # TODO notify about not overriden function
37 self.error("Where is your check()?")
41 # TODO notify about not overriden function
42 self.error("Where is your create()?")
46 # TODO notify about not overriden function
47 self.error("Where is your update()?")