File: //usr/lib/python2.7/site-packages/lap/tomcat.py
import socket
import httplib
def __run__(params):
try:
host = params.get("host", "localhost")
port = params.get("port", 8080)
path = params.get("path")
except Exception, e:
return [2, "CRITICAL - Error %s" % repr(e)]
try:
socket.setdefaulttimeout(5)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((host, port))
except socket.error, e:
return [2, "CRITICAL - Error %s" % repr(e)]
try:
conn = httplib.HTTPConnection(host,port)
conn.request("HEAD", path)
res = conn.getresponse().status
if res == 200:
return [0, "OK - %s" % res]
else:
return [2, "CRITICAL - %s" % repr(res)]
except Exception, e:
return[2, "CRITICAL - %s" % repr(e)]