Skip to content

Instantly share code, notes, and snippets.

@elubow
Created March 9, 2012 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save elubow/2008708 to your computer and use it in GitHub Desktop.
Save elubow/2008708 to your computer and use it in GitHub Desktop.
Nagios Passive Check
# 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