Check multiple ports of a switch with snmp

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
Mester1202
Posts: 2
Joined: Thu Mar 01, 2012 8:04 pm

Check multiple ports of a switch with snmp

Post by Mester1202 »

Hi All,

I try to check our switch for bad packets. I have succesfully made the configuration file, but for some reason it always sais SNMP OK.
This is the command I use for checking:

/usr/local/nagios/libexec/check_snmp -H ip_address -C name -o ifInErrors.101 -w 10 -c 100, -o ifInErrors.102 -w 10 -c 100 -o ifInErrors.103 -w 10 -c 100, -o ifInErrors.104 -w 10 -c 100

And the result is:

SNMP OK - 0 20 0 0 | RFC1213-MIB::ifInErrors.101=0c RFC1213-MIB::ifInErrors.102=20c RFC1213-MIB::ifInErrors.103=0c RFC1213-MIB::ifInErrors.104=0c

As you can see I have bad backets on the second port of the switch (102), but for some reason the -w and -c part of the command only check the first number of the returned string. (In this case this is 0 so it thinks everything is ok)

If I put the bad port on the first place it reports warning:

/usr/local/nagios/libexec/check_snmp -H ip_address -C name -o ifInErrors.102 -w 10 -c 100, -o ifInErrors.101 -w 10 -c 100 -o ifInErrors.103 -w 10 -c 100, -o ifInErrors.104 -w 10 -c 100
SNMP WARNING - *20* 0 0 0 | RFC1213-MIB::ifInErrors.102=20c RFC1213-MIB::ifInErrors.101=0c RFC1213-MIB::ifInErrors.103=0c RFC1213-MIB::ifInErrors.104=0c

So is there a way to check the whole array of result and no only the first number of it?
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Check multiple ports of a switch with snmp

Post by jsmurphy »

I think the reason for this is that I think with this check you only define -w and -c once and use commas to separate the thresholds for each:

/usr/local/nagios/libexec/check_snmp -H ip_address -C name -o ifInErrors.101, -o ifInErrors.102, -o ifInErrors.103, -o ifInErrors.104 -w 10,10,10,10 -c 100,100,100,100
Mester1202
Posts: 2
Joined: Thu Mar 01, 2012 8:04 pm

Re: Check multiple ports of a switch with snmp

Post by Mester1202 »

Thank you!
Now it works!
Thanks again!
Locked