Custom plugin help
Posted: Thu Mar 24, 2016 4:45 am
Hi had a developer send me a plug in to deploy - basically connects to a port and interprets some JSON for a health check - doesn't work do I need to change the localhost URL to be a reference to the host i.e $HOSTADDRESS?
#!/usr/bin/env python
import requests
import sys
import 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)
#!/usr/bin/env python
import requests
import sys
import 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)