Page 1 of 1

Custom nagios status information

Posted: Fri Feb 22, 2013 5:11 am
by kalyan1709
Hi all,

I have added a switch port monitoring to nagios as shown below and it is working fine:

define service{
use generic-service
host_name XX.XX.XX.XX
service_description Port 1 Link Status
check_command check_snmp!-C <my community> -o ifOperStatus.1 -r 1 -m RFC1213-MIB
}


The status information is showing:

SNMP OK - 1 - means the switch port is UP
SNMP OK - 2 - means the switch port is down

I would like to change the status information from "SNMP OK - 1" to UP and "SNMP OK - 2" to DOWN.

Please suggest the solution.

Thanks in advance

Regards
KP

Re: Custom nagios status information

Posted: Fri Feb 22, 2013 2:37 pm
by abrist
From: http://nagiosplugins.org/man/check_snmp

Code: Select all

--invert-search
    Invert search result (CRITICAL if found)
So you may want to try:

Code: Select all

define service{
use generic-service
host_name XX.XX.XX.XX
service_description Port 1 Link Status
check_command check_snmp!-C <my community> -o ifOperStatus.1 -r 2 --invert-search -m RFC1213-MIB
}

Re: Custom nagios status information

Posted: Mon Feb 25, 2013 5:44 am
by kalyan1709
Hi abrist,

Thanks for the reply. I followed your post and below is the output:

[root@Nagios ~]# /usr/local/src/nagios/libexec/check_snmp -C mycommunity -o ifOperStatus.12002 -r 2 -m RFC1213-MIB -H 172.16.7.11
SNMP OK - 2 | RFC1213-MIB::ifOperStatus.12002=2
[root@Nagios ~]# /usr/local/src/nagios/libexec/check_snmp -C mycommunity -o ifOperStatus.12002 -r 1 -m RFC1213-MIB -H 172.16.7.11
SNMP OK - 2 | RFC1213-MIB::ifOperStatus.12002=2

Actually the port 12002 is down. But I am getting out put as "SNMP OK - 2 | RFC1213-MIB::ifOperStatus.12002=2". I need the info "Down" here.

snmpwalk out put: IF-MIB::ifOperStatus.12002 = INTEGER: down(2)

Thanks & Regards
Kalyan Pasupuleti

Re: Custom nagios status information

Posted: Mon Feb 25, 2013 7:44 am
by gshergill
Hi kalyan1709,

I think abrist means to run:

Code: Select all

/usr/local/src/nagios/libexec/check_snmp -C mycommunity -o ifOperStatus.12002 -r 2 --invert-search -m RFC1213-MIB -H 172.16.7.11
With the "--invert-search" added in there.

Kind Regards,

Gary Shwergill

Re: Custom nagios status information

Posted: Mon Feb 25, 2013 8:26 am
by kalyan1709
Hi Gary,

Sorry, I have pasted the wrong line. But still it is giving the same out put "SNMP OK - 2 | RFC1213-MIB::ifOperStatus.12002=2
" even after executing the below command:
/usr/local/src/nagios/libexec/check_snmp -C mycommunity -o ifOperStatus.12002 -r 2 --invert-search -m RFC1213-MIB -H 172.16.7.11

Thanks & Regards
Kalyan Pasupuleti

Re: Custom nagios status information

Posted: Mon Feb 25, 2013 11:11 am
by abrist
Do you get the same behavior if you try a string match instead of a regex?

Code: Select all

/usr/local/src/nagios/libexec/check_snmp -C mycommunity -o ifOperStatus.12002 -s " 2 " --invert-search -m RFC1213-MIB -H 172.16.7.1

Re: Custom nagios status information

Posted: Wed Feb 27, 2013 8:49 am
by kalyan1709
Thanks all.

Finally I it worked for me by using /usr/local/src/nagios/libexec/check_snmp -C mycommunity -o ifOperStatus.12002 -r 2 --invert-search -m RFC1213-MIB -H 172.16.7.1

Thanks & Regards
Kalyan Pasupuleti

Re: Custom nagios status information

Posted: Wed Feb 27, 2013 11:45 am
by sreinhardt
Thanks for letting us know its working!