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 0000000000000000000000000000000000000000..8628ecaea9300e08f1c3d70545e626ce80407420 --- /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())