update_every
paulfantom committed
Jun 21, 2016 at 12:07 UTC
50f8d35bc34d070af75f1fe39749bc6a6178d04e
1 file changed
+11
-12
plugins.d/python.d.plugin
+11
-12
@@ -74,13 +74,13 @@ def fatal(*args):
74
MODULES_DIR = os.path.abspath(os.getenv('NETDATA_PLUGINS_DIR',
75
os.path.dirname(__file__)) + "/../python.d") + "/"
76
CONFIG_DIR = os.getenv('NETDATA_CONFIG_DIR', "/etc/netdata/")
77
-UPDATE_EVERY = os.getenv('NETDATA_UPDATE_EVERY', 1)
77
+UPDATE_EVERY = os.getenv('NETDATA_UPDATE_EVERY', None)
78
# directories should end with '/'
79
if CONFIG_DIR[-1] != "/":
80
CONFIG_DIR += "/"
81
sys.path.append(MODULES_DIR + "python_modules")
82
83
-BASE_CONFIG = {'update_every': UPDATE_EVERY,
83
+BASE_CONFIG = {'update_every': 1,
84
'priority': 90000,
85
'retries': 10}
86
@@ -115,7 +115,7 @@ class PythonCharts(object):
115
Main class used to control every python module.
116
"""
117
def __init__(self,
118
- update_every=None, # TODO remove this
118
+ update_every=None,
119
modules=None,
120
modules_path='../python.d/',
121
modules_configs='../conf.d/',
@@ -145,9 +145,11 @@ class PythonCharts(object):
145
146
# good economy and prosperity:
147
self.jobs = self._create_jobs(configured_modules) # type: list
148
-# if DEBUG_FLAG and update_every is not None:
149
-# for job in self.jobs:
150
-# job.create_timetable(update_every)
148
+
149
+ # enable timetable override like `python.d.plugin mysql debug 1`
150
+ if DEBUG_FLAG and update_every is not None:
151
+ for job in self.jobs:
152
+ job.create_timetable(update_every)
153
154
@staticmethod
155
def _import_module(path, name=None):
@@ -496,7 +498,6 @@ def parse_cmdline(directory, *commands):
498
"""
499
global DEBUG_FLAG
500
global UPDATE_EVERY
499
- update_every = UPDATE_EVERY
501
502
mods = []
503
for cmd in commands[1:]:
@@ -510,13 +511,12 @@ def parse_cmdline(directory, *commands):
511
mods.append(cmd.replace(".chart.py", ""))
512
else:
513
try:
513
- update_every = int(cmd)
514
+ UPDATE_EVERY = int(cmd)
515
except ValueError:
515
- update_every = UPDATE_EVERY
516
+ pass
517
518
debug("started from", commands[0], "with options:", *commands[1:])
519
519
- UPDATE_EVERY = update_every
520
return mods
521
522
@@ -525,8 +525,7 @@ def run():
525
"""
526
Main program.
527
"""
528
- global PROGRAM, DEBUG_FLAG
529
- PROGRAM = sys.argv[0].split('/')[-1].split('.plugin')[0]
528
+ global DEBUG_FLAG
529
530
# read configuration file
531
disabled = []