Requesting some assistance with the check_snmp plugin

I am trying to figure out how to configure nagios and I am having some problems with the check_snmp plugins. When I setup the service in the switch.cfg I have this code

define service{
use generic-service ; Inherit values from a template
host_name

    service_description     Uptime
    check_command           check_snmp!-C <community name> -o sysUpTime.0
    }

Yet when the script executes on the web interface I get this error

Status Information: SNMP problem - No data received from host
CMD: /usr/bin/snmpget -t 1 -r 5 -m ALL -v 1 [authpriv] xx.xx.xx.xx:161 sysUpTime.0$

So I looked at the commands.cfg and this is the config I have for check_snmp. Yes I know it is the template but I am now learning my way arounf nagios

‘check_snmp’ command definition

define command{
command_name check_snmp
command_line $USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$
}

When I run the command from my desktop where the code resides it works
ravir.desktop% ./check_snmp -t 1 -r 5 -m ALL -v 1 -C -H xx.xx.xx.xx -o sysUpTime.0
/usr/bin/snmpget -t 1 -r 5 -m ALL -v 1 -c xx.xx.xx.xx:161 sysUpTime.0
RFC1213-MIB::sysUpTime.0 = Timeticks: (698815868) 80 days, 21:09:18.68

But when I replace the -o string to exactly what the web interface shows as an error…IE
ravir.desktop% ./check_snmp -t 1 -r 5 -m ALL -v 1 -C -H xx.xx.xx.xx -o sysUpTime.0$
/usr/bin/snmpget -t 1 -r 5 -m ALL -v 1 -c xx.xx.xx.xx:161 sysUpTime.0$

SNMP problem - No data received from host
CMD: /usr/bin/snmpget -t 1 -r 5 -m ALL -v 1 [authpriv] xx.xx.xx.xx:161 sysUpTime.0$

So my question is, how do I prevent the script from adding a $ to the end of sysUpTime.O when I do not specify the $ in the service definition. Any help would be greatly appreciated

Have you tried to use numeric OID instead of symbolic one?

Hi I’ve tried by substituting the numeric OID but I get the same problem

Current Status:
UNKNOWN
(for 4d 19h 24m 37s)
Status Information: SNMP problem - No data received from host
CMD: /usr/bin/snmpget -t 1 -r 5 -m ALL -v 1 [authpriv] :161 1.3.6.1.2.1.1.3.0$

while I have ammended the code to look like this
define service{
use generic-service ; Inherit values from a template
host_name

    service_description     Uptime
    check_command           check_snmp!-C <community strings> -o 1.3.6.1.2.1.1.3.0
    }

while the command line again returns correct information

ravir.desktop% /usr/bin/snmpget -t 1 -r 5 -m ALL -v 1 -c :161 1.3.6.1.2.1.1.3.0
RFC1213-MIB::sysUpTime.0 = Timeticks: (851085525) 98 days, 12:07:35.25
ravir.desktop%

and even if I run the compiled source code
ravir.desktop% ./check_snmp -t 1 -r 5 -m ALL -v 1 -C -H -o 1.3.6.1.2.1.1.3.0
/usr/bin/snmpget -t 1 -r 5 -m ALL -v 1 -c :161 1.3.6.1.2.1.1.3.0
RFC1213-MIB::sysUpTime.0 = Timeticks: (741155806) 85 days, 18:45:58.06

SNMP OK - Timeticks: (741155806) 85 days, 18:45:58.06 |
ravir.desktop%

This one’s really weird. Haven’t seen this ever…

Try to look at the /usr/bin/snmpget permission and be sure all users have read/execute permissions on it. Check the $USER$ variable you’re using. Try with a different approach to defining command and service definitions, maybe something like this:

[code]# ‘check_snmp’ command definition
define command{
command_name check_snmp
command_line /usr/lib/nagios/plugins/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o $ARG2$ -P $ARG3$
}

define service{
use generic-service ; Inherit values from a template
host_name

service_description Uptime
check_command check_snmp!!1.3.6.1.2.1.1.3.0!2c
[/code]