-
-
Save devdazed/2481257 to your computer and use it in GitHub Desktop.
Nagios Passive Check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#foobar | |
# Send the passive service check back to Nagios | |
logger.debug("Constructing the Nagios result string") | |
nag_message = config.get('nagios','message') | |
nag_status = 0 | |
logger.info("Passive check result sent to Nagios") | |
except Exception, e: | |
nag_status = 2 | |
nag_message = "%s" % (e) | |
# Nagios passive status update | |
nag_localhost_name = config.get('nagios','localhost_name') | |
nag_remote_service_name = config.get('nagios','remote_service_name') | |
nag_servers = config.get('nagios','servers') | |
# Structure: $nagios_machine_name;$check_name;<status_int>;message | |
nagios_result = """%s;%s;%s;%s in %s""" % (nag_localhost_name,nag_remote_service_name,nag_status,nag_message,total_human_time) | |
for host in nag_servers.split(','): | |
result = os.system("/bin/echo '%s' | /usr/sbin/send_nsca -c /etc/nagios/send_nsca.cfg -H %s -d ';'" %(nagios_result,host)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment