From 159b00b5e0707306a1e1442d4dcdf3018587dcbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johana=20Sup=C3=ADkov=C3=A1?= <johana.supikova@seznam.cz> Date: Tue, 6 Jun 2023 16:21:25 +0200 Subject: [PATCH] feat: script calling non-python monitoring scripts --- .../utils/nagios/check_custom_command.py | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 perun/proxy/utils/nagios/check_custom_command.py diff --git a/perun/proxy/utils/nagios/check_custom_command.py b/perun/proxy/utils/nagios/check_custom_command.py new file mode 100644 index 0000000..8628eca --- /dev/null +++ b/perun/proxy/utils/nagios/check_custom_command.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 + +import argparse +import subprocess +import sys + + +""" +general script to run non-python checks by a custom-defined command +""" + + +def get_args(): + """ + Supports the command-line arguments listed below. + """ + parser = argparse.ArgumentParser(description="Custom command to run") + parser.add_argument( + "-c", + "--command", + required=True, + help="whole command to be executed", + ) + + return parser.parse_args() + + +def main(): + args = get_args() + result = subprocess.run(args.command, shell=True, text=True, capture_output=True) + print(result.stdout, end="") + return result.returncode + + +if __name__ == "__main__": + sys.exit(main()) -- GitLab