Custom nagios status information

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
kalyan1709
Posts: 43
Joined: Tue Oct 16, 2012 12:45 am

Custom nagios status information

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Custom nagios status information

Post 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
}
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
kalyan1709
Posts: 43
Joined: Tue Oct 16, 2012 12:45 am

Re: Custom nagios status information

Post 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
User avatar
gshergill
Posts: 231
Joined: Tue Aug 07, 2012 5:08 am

Re: Custom nagios status information

Post 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
kalyan1709
Posts: 43
Joined: Tue Oct 16, 2012 12:45 am

Re: Custom nagios status information

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Custom nagios status information

Post 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
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
kalyan1709
Posts: 43
Joined: Tue Oct 16, 2012 12:45 am

Re: Custom nagios status information

Post 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
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Custom nagios status information

Post by sreinhardt »

Thanks for letting us know its working!
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked