Page 1 of 1

SNMP 'regex' question

Posted: Mon Mar 25, 2013 5:01 pm
by and1100
Hi,

I am trying to use Nagios to monitor our port up/down status on a switch. I have Nagios correctly working with SNMP, however I am getting odd results when I am trying to test UP/DOWN functionality.

I am checking port 1 (up) and port 8 (down). It should throw a value of 1 if the port is up, and a value of 6 if it is down. I would like it to say that it is down if it throws 6, but it looks like -r does nothing. Here is an example:

[root@vmnagios libexec]# ./check_snmp -H x.x.x.x -P 2c -C pass -o ifOperStatus.8 -r 1
SNMP OK - 6 | IF-MIB::ifOperStatus.8=6
[root@vmnagios libexec]# ./check_snmp -H x.x.x.x -P 2c -C pass -o ifOperStatus.1 -r 1
SNMP OK - 1 | IF-MIB::ifOperStatus.1=1
[root@vmnagios libexec]# ./check_snmp -H x.x.x.x -P 2c -C pass -o ifOperStatus.8 -r 6
SNMP OK - 6 | IF-MIB::ifOperStatus.8=6
[root@vmnagios libexec]# ./check_snmp -H x.x.x.x -P 2c -C pass -o ifOperStatus.1 -r 6
SNMP OK - 1 | IF-MIB::ifOperStatus.1=1
[root@vmnagios libexec]# ./check_snmp -H x.x.x.x -P 2c -C pass -o ifOperStatus.1 -r dsadsadasdsa
SNMP OK - 1 | IF-MIB::ifOperStatus.1=1

I threw in the last one to show that it doesn't seem to be taking my REGEX values at all. On the Nagios GUI it shows the following:

Port 1 Link Status
OK 03-25-2013 17:52:48 0d 0h 43m 6s 1/3 SNMP OK - 1
Port 8 Link Status
OK 03-25-2013 17:46:45 0d 0h 39m 9s 1/3 SNMP OK - 6

However, I would like it to show DOWN for the value of 6.

I tried a few different things but I am stumped. Am I misunderstanding how -r is supposed to work?

Thank you for taking the time to read this.

Re: SNMP 'regex' question

Posted: Tue Mar 26, 2013 8:56 am
by scottwilkerson
I did some tests with the following version and got results as expected

Code: Select all

./check_snmp -V
check_snmp v2021 (nagios-plugins 1.4.13)
Can you run the following to see what version you have

Code: Select all

./check_snmp -V

Re: SNMP 'regex' question

Posted: Tue Mar 26, 2013 9:25 am
by and1100
Certainly:

[root@vmnagios libexec]# ./check_snmp -V
check_snmp v1.4.15 (nagios-plugins 1.4.15)

Thank you.

Re: SNMP 'regex' question

Posted: Tue Mar 26, 2013 9:55 am
by abrist
I tested with 1.4.16 and it works as expected. Once you get regex working, you will want to use "--invert-search" to along with "-r" to flag a critical if the regex is found.
http://nagiosplugins.org/man/check_snmp

Re: SNMP 'regex' question

Posted: Tue Mar 26, 2013 10:15 am
by and1100
Interesting, thank you. However, in the process of trying to install the 1.4.16 plugins I was receiving the following error during the 'make' portion of the install:

check_http.c: In function âprocess_argumentsâ:
check_http.c:312: error: âssl_versionâ undeclared (first use in this function)
check_http.c:312: error: (Each undeclared identifier is reported only once
check_http.c:312: error: for each function it appears in.)
make[2]: *** [check_http.o] Error 1
make[2]: Leaving directory `/root/temp/nagios-plugins-1.4.16/plugins'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/temp/nagios-plugins-1.4.16'
make: *** [all] Error 2

Re: SNMP 'regex' question

Posted: Tue Mar 26, 2013 10:19 am
by abrist
Does this box have openssl and the ssl headers/devel files?

Re: SNMP 'regex' question

Posted: Tue Mar 26, 2013 11:50 am
by and1100
Awesome! I installed openssl-devel, recompiled and installed 1.4.16 plugins. I ran the same check_snmp script as before and it works correctly now!

Thanks for your help.

Re: SNMP 'regex' question

Posted: Tue Mar 26, 2013 12:22 pm
by abrist
Great. Cheers.