SNMP value 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 value question

Post 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.
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: SNMP value question

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

Re: SNMP value question

Post by abrist »

@and1100 - How did jsmurphy's suggestion work out for you?
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 value question

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

Re: SNMP value question

Post by abrist »

No problem, let us know!
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 value question

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

Re: SNMP value question

Post 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'
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 value question

Post by and1100 »

Awesome! That works!

Thanks a lot!
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: SNMP value question

Post by abrist »

!??!!?! Great! . . . locking thread.
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