File: //usr/lib/python2.7/site-packages/lap/arda-web-status.py
import socket
def __run__(params):
try:
import requests
except ImportError:
return [2, "CRITICAL - Error: Please install python-requests"]
try:
url = params.get("url", "http://arda.locaweb.com.br/status.txt")
content = params.get("content", "UP")
except Exception, e:
return [2, "CRITICAL - Error %s" % repr(e)]
try:
socket.setdefaulttimeout(10)
data = requests.get(url, verify=False)
except Exception, e:
return [2, "CRITICAL - Error: the url %s cannot be opened : %s" % (url,repr(e))]
if content in data.text:
return [0, "OK - %s returned '%s'" % (url,content)]
else:
return [2, "CRITICAL - Error: '%s' is NOT returning %s" % (url,content)]