check_snmp multiple protocol version

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
00_kl250
Posts: 63
Joined: Tue Apr 16, 2013 7:26 am

check_snmp multiple protocol version

Post by 00_kl250 »

Hi All,

I have a question about using the check_snmp plugin that be easily answered. Basically I have two devices that use different snmp protocols so I need the ability to use the same plugin for two different checks. When i define two different check_commands using the same snmp plugin it errors out.

Here is my first check_command:

define command {
command_name check_snmp
command_line $USER1$/check_snmp -P 2c -H $HOSTADDRESS$ -C $ARG1$ -o $ARG2$
}

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

As you can see the first command I need to use "2c" to get the info from the device. On my second command I don't need to specify anything. Nagios will error out until I change one of the commands.

Is there a way to set a variable in the command line of the check command. For instance:


define command {
command_name check_snmp
command_line $USER1$/check_snmp -v $AGR1$ -H $HOSTADDRESS$ -C $ARG2$ -o $ARG3$

I tried doing something like this and i still had issues. Any help would be appreciated.
}
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: check_snmp multiple protocol version

Post by jdalrymple »

00_kl250 wrote:define command {
command_name check_snmp
command_line $USER1$/check_snmp -v $AGR1$ -H $HOSTADDRESS$ -C $ARG2$ -o $ARG3$
}
Did you have $ARG1$ spelled correctly?
What were you using for $ARG1$?

This should work fine for you.
00_kl250
Posts: 63
Joined: Tue Apr 16, 2013 7:26 am

Re: check_snmp multiple protocol version

Post by 00_kl250 »

I fixed my own problem:

instead of -v, i used -P:

define command {
command_name check_snmp
command_line $USER1$/check_snmp -P $ARG1$ -H $HOSTADDRESS$ -C $ARG2$ -o $ARG3$
}

all working now.

thx
Locked