SNMP 'regex' question

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
and1100
Posts: 93
Joined: Mon Mar 25, 2013 8:37 am

SNMP 'regex' question

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: SNMP 'regex' question

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
and1100
Posts: 93
Joined: Mon Mar 25, 2013 8:37 am

Re: SNMP 'regex' question

Post by and1100 »

Certainly:

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

Thank you.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: SNMP 'regex' question

Post 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
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.
and1100
Posts: 93
Joined: Mon Mar 25, 2013 8:37 am

Re: SNMP 'regex' question

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

Re: SNMP 'regex' question

Post by abrist »

Does this box have openssl and the ssl headers/devel files?
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.
and1100
Posts: 93
Joined: Mon Mar 25, 2013 8:37 am

Re: SNMP 'regex' question

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

Re: SNMP 'regex' question

Post by abrist »

Great. Cheers.
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.
Locked