Page 1 of 1

SNMP value question

Posted: Fri Apr 05, 2013 4:18 pm
by and1100
Hello,

I am trying to tweak my switch port SNMP in Nagios. I would like a port that is 'Not connected' or 'Not Present' in Nagios to not send out any critical alerts or warning (basically to show OK), but I would like it to do so for a 'down' port. Here is an example of how it works currently. Eth7= connected and up. Eth8= connected and DOWN. Eth9= not connected.

Eth 7
OK 04-05-2013 17:08:18 0d 3h 34m 43s 1/3 SNMP OK - up(1)

Eth 8
CRITICAL 04-05-2013 17:08:52 0d 0h 48m 9s 3/3 SNMP CRITICAL - *down(2)*

Eth 9
CRITICAL 04-05-2013 14:42:23 0d 3h 34m 38s 3/3 SNMP CRITICAL - *notPresent(6)*

Here is my current SNMP check command for Nagios:

check_snmp!-H 10.1.1.1 -P 2c -C secret -o ifOperStatus.9 -r 1 (repeated for the other ports)

I've tried a few different options with no luck. I'm sure it's a simple parameter I am missing or not understanding...

Thank you for taking the time to read this.

Re: SNMP value question

Posted: Sun Apr 07, 2013 6:32 pm
by jsmurphy
For port 9 change your command from:
check_snmp!-H 10.1.1.1 -P 2c -C secret -o ifOperStatus.9 -r 1

to:
check_snmp!-H 10.1.1.1 -P 2c -C secret -o ifOperStatus.9 -r 6

The -r is a regex pattern match, it's not up so there's no "1" to match on interface 9, but notPresent is 6... so you can match that number instead. If you want to make it more generic for the sake of manageability you could probably also change it to -r 1|6 (1 or 6)

Re: SNMP value question

Posted: Tue Apr 09, 2013 12:25 pm
by abrist
@and1100 - How did jsmurphy's suggestion work out for you?

Re: SNMP value question

Posted: Tue Apr 09, 2013 1:37 pm
by and1100
Apologies, I was out and did not get a chance to test.

I will give this a shot very soon and see how it works out!

Thank you very much for the response and your information.

Re: SNMP value question

Posted: Tue Apr 09, 2013 1:40 pm
by abrist
No problem, let us know!

Re: SNMP value question

Posted: Tue Apr 09, 2013 2:00 pm
by and1100
I was able to test the command using -r 6 and it works as expected for 'NotPresent' ports. I tried to incorporate both values to report back as OK using this syntax:

[root@vmnagios libexec]# ./check_snmp -H 1.1.1.1 -P 2c -C secret -o ifOperStatus.19 -r 1|6
-bash: 6: command not found

but it does not recognize -r 1|6.

Did I incorrectly input the parameters?

Thanks!

Re: SNMP value question

Posted: Tue Apr 09, 2013 2:07 pm
by abrist
You may have to wrap the regex in quotes as it is a special char in bash for piping output to another command.

Code: Select all

-r '1|6'

Re: SNMP value question

Posted: Tue Apr 09, 2013 2:36 pm
by and1100
Awesome! That works!

Thanks a lot!

Re: SNMP value question

Posted: Tue Apr 09, 2013 2:39 pm
by abrist
!??!!?! Great! . . . locking thread.