Skip to content

Instantly share code, notes, and snippets.

@devdazed
Forked from elubow/gist:2008708
Created April 24, 2012 16:34
Show Gist options
  • Save devdazed/2481257 to your computer and use it in GitHub Desktop.
Save devdazed/2481257 to your computer and use it in GitHub Desktop.
Nagios Passive Check
#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