#! /usr/bin/env python
###############################################################################
-# Nagios plugin template
+# Nagios plugin check_actuator_health
#
# Notes
# - The RHEL boxes I work on are currently limited to Python 2.6.6, hence the
import urllib3 as urllib # python3-urllib3-1.24.2-5.el8.noarch.rpm python3-urllib3-1.26.5-3.el9.noarch.rpm
import json
except:
- sys.exit(2)
+ sys.exit(3)
## These will override any args passed to the script normally. Comment out after testing.
#testargs = '--help'
#testargs = '--version'
#testargs = '-vvv'
-testing = True
+#testing = True
OK_RESPONSE = """
{
keyword = options['keyword']
url = options['url']
agent = options['agent']
+ testing = options['testing']
if keyword is None or url is None:
message = "Keywork: {0} url: {1}".format(keyword, url)
status = 3
message = "UP"
status = 2
else:
- message = gather_message(data)
- status = 0
+ status, message = gather_message(data)
except Exception as e:
- print(e)
- message = "DOWN"
- status = 2
+ log.fatal(e)
+ message = e
+ status = 3
gtfo(status, message)
def gather_message(json_data):
""" Assemble error messages """
+ status = 2
msg = None
try:
if 'components' in json_data:
else:
msg = "{0}: {1}".format(component, error)
else:
- sys.exit(3)
+ return (3, msg)
except:
- sys.exit(3)
- return msg
+ return (3, msg)
+ return (status, msg)
def parse_args():