So there is a currently unresolved issue with the check_snmp nagios plugin where it doesn’t use the snmp.conf file. I use v3 of the protocol, and don’t want to have to put the big long string everywhere in the nagios configuration file:
define command{
command_name check_snmp_cpu
command_line $USER1$/check_snmp -H $HOSTADDRESS$ -w 2 -c 4 -u "cpu" -P 3 -L authPriv -a MD5 -U snmpmonitor -A "have a look at what I have to offer" -x des -X "have a look at what I have to offer" -o .1.3.6.1.4.1.2021.11.10.0
}
With this in my /etc/snmp/snmp.conf file:
defVersion 3 defSecurityName snmpmonitor defSecurityLevel authPriv defPassphrase "have a look at what I have to offer"
I don’t have to give any arguments to the snmp commands on the command line. The check_snmp plugin forks out to the snmpget command, but does so in such a way that the snmp.conf file isn’t used. So I thought to myself, why not write a simple script that forks out to snmpget?
Here is my check_snmp.pl script, and my nagios command is now simply:
define command{
command_name check_snmp_cpu
command_line /usr/bin/perl $USER1$/check_snmp.pl -w 2 -c 4 -m " cpu" -- $HOSTADDRESS$ .1.3.6.1.4.1.2021.11.10.0
}
Much, much shorter. And if I ever change the passphrase, I don’t have to do it in 20 places.
Be warned, it took me all of 45 minutes on it and it “works for me”. Your results may vary. I release is to you all under the public domain. Have fun.
Pingback: nagios snmp memory and swap plugin | cormander's blog