File: //lib/python2.7/site-packages/lap/check_nginx_plus.py
import requests
import json
import yaml
def get_data(URL):
r = requests.get('http://%s/status' % URL )
if r.status_code == 200:
data = json.loads(r.content)
return data['connections']
else:
return None
def __run__(params):
try:
server = yaml.load(params.get('server'))
except Exception, e:
return [2, "CRITICAL - Error: %s" % repr(e)]
data = get_data(server)
if data is not None:
parserdata = '|'.join([ '%s=%d' % (x , data[x]) for x in data])
return [0, "OK - Server %s working fine" % server , parserdata]
else:
return [2, "CRITICAL - Error: %s" % repr(e)]