fix disabling already active auto-detected jobs
paulfantom committed
Jul 14, 2016 at 13:03 UTC
20de7e0eb9092760d14fd970aa79c3417cb51a26
1 file changed
+11
-7
plugins.d/python.d.plugin
+11
-7
@@ -285,11 +285,13 @@ class PythonCharts(object):
285
prefix = job.__module__
286
if job.name is not None and len(job.name) != 0:
287
prefix += "/" + job.name
288
- prefix += ": "
288
try:
289
self.jobs.remove(job)
290
+ msg.info("Disabled", prefix)
291
except Exception as e:
292
msg.debug("This shouldn't happen. NO " + prefix + " IN LIST:" + str(self.jobs))
293
+
294
+ prefix += ": "
295
if reason is None:
296
return
297
elif reason[:3] == "no ":
@@ -328,14 +330,14 @@ class PythonCharts(object):
330
i += 1
331
try:
332
if job.override_name is not None:
331
- tmp = job.name
332
- job.name = job.override_name
333
- msg.debug(job.chart_name + " changing chart name to: " + job.__module__ + '_' + job.name)
334
- job.chart_name = job.__module__ + '_' + job.name
335
- if job.chart_name in overridden:
333
+ new_name = job.__module__ + '_' + job.override_name
334
+ if new_name in overridden:
335
+ msg.error(job.chart_name + " already exists. Stopping '" + job.name + "'")
336
self._stop(job)
337
- msg.error(job.chart_name + " already exists. Created with '" + tmp + "'")
337
else:
338
+ job.name = job.override_name
339
+ msg.debug(job.chart_name + " changing chart name to: '" + new_name + "'")
340
+ job.chart_name = new_name
341
overridden.append(job.chart_name)
342
except Exception:
343
pass
@@ -483,6 +485,8 @@ def run():
485
486
# parse passed command line arguments
487
modules = parse_cmdline(MODULES_DIR, *sys.argv)
488
+ modules = ['sensors']
489
+ DEBUG_FLAG = True
490
msg.DEBUG_FLAG = DEBUG_FLAG
491
msg.info("MODULES_DIR='" + MODULES_DIR +
492
"', CONFIG_DIR='" + CONFIG_DIR +