From: paulfantom Date: Sat, 11 Jun 2016 11:50:22 +0000 (+0200) Subject: added option to pass interval with command line parameter X-Git-Tag: v1.3.0~137^2~14 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4918953dbe94d117f6d0bc2ce9aff1b7ffe3d485;p=netdata.git added option to pass interval with command line parameter --- diff --git a/plugins.d/python.d.plugin b/plugins.d/python.d.plugin index bc07eab3..22292aac 100755 --- a/plugins.d/python.d.plugin +++ b/plugins.d/python.d.plugin @@ -212,6 +212,7 @@ def parse_cmdline(directory, *commands): # TODO number -> interval global DEBUG_FLAG, PROGRAM DEBUG_FLAG = False + interval = None mods = [] for cmd in commands[1:]: @@ -223,11 +224,17 @@ def parse_cmdline(directory, *commands): elif os.path.isfile(directory + cmd + ".chart.py") or os.path.isfile(directory + cmd): DEBUG_FLAG = True mods.append(cmd.replace(".chart.py", "")) + else: + try: + interval = int(cmd) + except ValueError: + pass PROGRAM = commands[0].split('/')[-1].split('.plugin')[0] debug("started from", commands[0], "with options:", *commands[1:]) - return mods + return {'interval': interval, + 'modules': mods} # if __name__ == '__main__': @@ -282,7 +289,10 @@ def run(): modules_conf += "/" # parse passed command line arguments - modules = parse_cmdline(modules_dir, *sys.argv) + out = parse_cmdline(modules_dir, *sys.argv) + modules = out['modules'] + if out['interval'] is not None: + interval = out['interval'] # run plugins charts = PythonCharts(interval, modules, modules_dir, modules_conf)