-
-
Save DBassel/277e203a99e22ceb4d018bfeed2845d8 to your computer and use it in GitHub Desktop.
nagios plugin for spring-boot app status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import requests, sys, getopt | |
try: | |
opts, args = getopt.getopt(sys.argv[1:], "p:", ["port="]) | |
except getopt.GetoptError: | |
print('springboot.py -p <port>') | |
sys.exit(2) | |
for opt, arg in opts: | |
if opt == '-h': | |
print('springboot.py -p <port>') | |
sys.exit() | |
elif opt in ("-p", "--port"): | |
PORT = arg | |
try: | |
resp = requests.get('http://localhost:{PORT}/health'.format(**locals())).json() | |
except: | |
print sys.exc_info()[0] | |
sys.exit(2) | |
if resp['status'] == 'UP': | |
print "OK" | |
sys.exit(0) | |
else: | |
print "FAIL!" | |
sys.exit(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment