Page 1 of 1

check_snmp multiple protocol version

Posted: Mon Jul 06, 2015 9:54 am
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.
}

Re: check_snmp multiple protocol version

Posted: Mon Jul 06, 2015 11:10 am
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.

Re: check_snmp multiple protocol version

Posted: Mon Jul 06, 2015 11:36 am
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