Skip to content
Snippets Groups Projects
Commit 8ef63b4a authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Added check_datorhandbok.

parent 09ba16fa
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ LIBEXECDIR = /usr/local/nagios/libexec/
SCRIPTS = check_cups check_glsa check_saned check_lpd check_hddtemp \
check_link_status check_true check_lysrdiff check_syslog \
check_ping check_enodia_monitored check_hostextinfo \
check_hydra
check_hydra check_datorhandbok
all:;
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import BeautifulSoup
def critical(hostname, msg):
print "CRITICAL - %s: %s" % (hostname, msg)
sys.exit(2)
def warning(hostname, msg):
print "WARNING - %s: %s" % (hostname, msg)
sys.exit(1)
def ok(hostname, msg):
print "OK - %s: %s" % (hostname, msg)
sys.exit(0)
def url(hostname):
return "http://datorhandbok.lysator.liu.se/index.php/" + hostname
def nagios_url(hostname):
return ("https://nagios.lysator.liu.se/nagios/cgi-bin/"
"extinfo.cgi?type=1&host=" + hostname)
def check_host(hostname):
page = urllib2.urlopen(url(hostname))
contents = page.read()
tree = BeautifulSoup.BeautifulSoup(contents)
csub = tree.find(id="contentSub")
if csub.findNext(attrs={"alt": "#REDIRECT"}):
warning(hostname, "broken redirect")
firstpara = csub.findNext("p").string
if firstpara == u"(Det finns för tillfället ingen text på den här sidan.)\n":
warning(hostname, "not documented")
if csub.findNext(attrs={"href": nagios_url(hostname)}):
ok(hostname, "all ok")
else:
warning(hostname, "Nagios link missing")
if __name__ == '__main__':
import sys
check_host(sys.argv[1])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment