# good economy and prosperity:
self.jobs = self._create_jobs(configured_modules)
- debug(self.jobs)
def _create_jobs(self,modules):
return None
else:
# set execution_name (needed to plot run time graphs)
- job.execution_name = module.__name__ + "_" + name
+ job.execution_name = module.__name__
+ if name is not None:
+ job.execution_name += "_" + name
jobs.append(job)
return [j for j in jobs if j is not None]
except (KeyError,ValueError):
# if above failed, get defaults from global dict
defaults[key] = BASE_CONFIG[key]
-
- # assign variables needed by supervisor to every job configuration
+
+ # check if there are dict in config dict
+ many_jobs = False
for name in config:
- for key in BASE_CONFIG:
- if key not in config[name]:
- config[name][key] = defaults[key]
+ if type(config[name]) is dict:
+ many_jobs = True
+ break
+ # assign variables needed by supervisor to every job configuration
+ if many_jobs:
+ for name in config:
+ for key in defaults:
+ if key not in config[name]:
+ config[name][key] = defaults[key]
+ # if only one job is needed, values doesn't have to be in dict (in YAML)
+ else:
+ config = {None: config.copy()}
+ config[None].update(defaults)
+
# return dictionary of jobs where every job has BASE_CONFIG variables
return config
self._stop(job, "no check")
except (UnboundLocalError, Exception) as e:
self._stop(job, "misbehaving. Reason: " + str(e))
+ print("CHECK OK")
def create(self):
# try to execute create() on every job
self._stop(job, "no create")
except (UnboundLocalError, Exception) as e:
self._stop(job, "misbehaving. Reason: " + str(e))
+ print("CREATE OK")
def _update_job(self, job):
# try to execute update() on every job and draw run time graph
try:
conf = read_config(configfile)
try:
- if str(conf['enable']) == "no":
+ if str(conf['enable']) is False:
debug("disabled in configuration file")
sys.stdout.write("DISABLE\n")
sys.exit(1)
pass
try:
modules_conf = conf['plugins_config_dir']
- except (KeyError):
+ except KeyError:
modules_conf = config_dir + "python.d/" # default configuration directory
try:
modules_dir = conf['plugins_dir']
- except (KeyError):
+ except KeyError:
modules_dir = main_dir.replace("plugins.d", "python.d")
try:
- interval = int(conf['interval'])
- except (KeyError, TypeError):
+ interval = conf['interval']
+ except KeyError:
pass # use default interval from NETDATA_UPDATE_EVERY
try:
- DEBUG_FLAG = bool(conf['debug'])
- except (KeyError, TypeError):
+ DEBUG_FLAG = conf['debug']
+ except KeyError:
pass
for k, v in conf.items():
if k in ("plugins_config_dir", "plugins_dir", "interval", "debug"):
continue
- if v == 'no':
+ if v is False:
disabled.append(k)
except FileNotFoundError:
modules_conf = config_dir