How do I set status based on check?

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
bmcwhirt
Posts: 2
Joined: Wed Mar 28, 2012 7:21 pm

How do I set status based on check?

Post by bmcwhirt »

I am having trouble understanding exactly how I go about setting the status based on a check_snmp. Here is my service definitions

Code: Select all

define service{
	use generic-service
	host_name cisco1760
	service_description FastEthernet0/0 Status
	check_command check_snmp!-C public -o ifOperStatus.2
}
What gets displayed in status information:
SNMP OK - 1 (this is if the interface is up)
SNMP OK - 2 (this is if the interface is down)

Ideally I would like to have this be yellow:warning if the interface has been down less than 5 minuets and red:critical if 5 minuets or longer, but even just setting it to one or the other is acceptable.

Thanks
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: How do I set status based on check?

Post by jsmurphy »

You need to use the -r modifier to tell it what the expected return should be. So your command should be:

check_command check_snmp!-C public -o ifOperStatus.2 -r 1
bmcwhirt
Posts: 2
Joined: Wed Mar 28, 2012 7:21 pm

Re: How do I set status based on check?

Post by bmcwhirt »

Ok, I made those changes and restarted nagios and waited for an updated check to occur but the status remains 'OK' even when the return value is not 1
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: How do I set status based on check?

Post by jsmurphy »

Are you able to try this from the Linux command line? Are you able to post the exact command you execute and what it returns?

/usr/lib/nagios/libexec/check_snmp -H hostname -v 2c -C public -o ifOperStatus.2 -r 1 (should be the full command but I am operating from memory here so it might not be exact)
Locked