Adjusted nagios check_snmp for checking jitter

This patch will allow checking SNMP version 2c values in Nagios-plugins-1.4:


— check_snmp.c 2005-01-20 18:03:56.000000000 -0700
+++ /root/check_snmp.c 2005-11-15 10:27:33.000000000 -0700
@@ -646,6 +646,10 @@
asprintf(&proto, DEFAULT_PROTOCOL);
asprintf(&authpriv, “%s%s”, "-c ", community);
}
+ else if ( strcmp (proto, “2c”) == 0 ) {
+ asprintf(&proto, “%s”, “2c”);
+ asprintf(&authpriv, “%s%s”, "-c “, community);
+ }
else if ( strcmp (proto, “3”) == 0 ) { /* snmpv3 args /
asprintf(&proto, “%s”, “3”);

@@ -859,7 +863,7 @@

/
SNMP and Authentication Protocol */
printf (_(”’
- -P, --protocol=[1|3]‘n’
+ -P, --protocol=[1|2c|3]‘n’
SNMP protocol version’n’
-L, --seclevel=[noAuthNoPriv|authNoPriv|authPriv]‘n’
SNMPv3 securityLevel’n’

I put that in a file called ~/snmp.patch.

To run the patch:
cd /wherever-you-have/nagios-plugins-1.4/plugins/
patch < ~/snmp.patch

Build it:
make check_snmp

and then copy over the old check_snmp command:
cp check_snmp /usr/local/nagios/libexec/

You can test it by running:

/usr/local/nagios/libexec/check_snmp -H AN-IP-ADDRESS -o 1.3.6.1.4.1.161.19.3.2.2.3.0 -w 3 -c 4 -C Canopy -P 2c

where AN-IP-ADDRESS is the IP of an SM and “Canopy” is replaced with your community string. It should return a numeric value. If the value is from 0 to 3 (inclusive) is reports “OK”, if it’s 4 you should get a warning, and if its greater than 4 you should get a critical error message.

Here’s the check command I’m using in checkcommands.cfg for nagios:

# ‘check_jitter’ command definition
define command{
command_name check_jitter
command_line $USER1$/check_snmp -H $HOSTADDRESS$ -o 1.3.6.1.4.1.161.19.3.2.2.3.0 -w 3 -c 4 -C Canopy -P 2c
}


And here’s the command as part of a host definition:

define service{
use generic-service
host_name CanopySM-001-005
service_description Jitter
is_volatile 0
check_period 24x7
max_check_attempts 10
normal_check_interval 5
retry_check_interval 5
contact_groups CanopySMAdmins
notification_interval 120
notification_period 24x7
notification_options c,r
check_command check_jitter
}


If you have any questions or comments, let me know via email because I rarely check these forums. tpb-canopy at the purple buffalo dot net