Page 1 of 1

Check multiple ports of a switch with snmp

Posted: Thu Mar 01, 2012 8:12 pm
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?

Re: Check multiple ports of a switch with snmp

Posted: Sun Mar 04, 2012 6:24 pm
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

Re: Check multiple ports of a switch with snmp

Posted: Mon Mar 05, 2012 3:13 am
by Mester1202
Thank you!
Now it works!
Thanks again!