Skip to content
Snippets Groups Projects
Commit cd626d50 authored by Jan Pavlíček's avatar Jan Pavlíček
Browse files

chore: merge branch 'xpavlic/run_probes_new_arg' into 'main'

feat: run_probes.py now allows to select probes to run with optional argument

See merge request !78
parents 48158f6f 53e638a4
No related branches found
No related tags found
1 merge request!78feat: run_probes.py now allows to select probes to run with optional argument
Pipeline #615641 passed
#!/usr/bin/python3 #!/usr/bin/python3
import argparse
import re import re
import subprocess import subprocess
import sys import sys
...@@ -73,9 +74,27 @@ def run_probe(probe_name, command, timeout): ...@@ -73,9 +74,27 @@ def run_probe(probe_name, command, timeout):
return result.returncode return result.returncode
def parse_arguments():
parser = argparse.ArgumentParser()
parser.add_argument(
"-p",
"--probes",
nargs="+",
default=[],
help="Optional list of probes to run from the config."
"If not specified, all probes will be run.",
)
args = parser.parse_args()
return args
def main(): def main():
args = parse_arguments()
probes_to_run = args.probes
config_filepath = "/etc/run_probes_cfg.yaml" config_filepath = "/etc/run_probes_cfg.yaml"
config = yaml.safe_load(open_file(config_filepath)) config = yaml.safe_load(open_file(config_filepath))
if not config: if not config:
return return
...@@ -83,6 +102,8 @@ def main(): ...@@ -83,6 +102,8 @@ def main():
for _, options in config["checks"].items(): for _, options in config["checks"].items():
module = options["module"] module = options["module"]
for name, args in options.get("runs").items(): for name, args in options.get("runs").items():
if probes_to_run and name not in probes_to_run:
continue
command = ["python3", "-m", module] command = ["python3", "-m", module]
timeout = global_timeout timeout = global_timeout
if args is not None: if args is not None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment