Page 1 of 1

Custom Defined Variable Not Working

Posted: Wed May 13, 2015 11:12 am
by raulpe
Hello,
I am having problems with a variable I defined in a host template not being passed down to the host. I am trying to call the variable from a service.
My host is a radio and I am trying to use check_snmp to get the voltage value from it (I had it working on Nagios core before).
The host Radio1 uses RadioType1 which has the custom variables

Code: Select all

_voltage_warn = 23.5
and

Code: Select all

_voltage_crit = 23
defined.
The service call looks like this:

Code: Select all

$USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$
and $ARG1$ looks like this:

Code: Select all

-o .1.3.6.1.4.1.21703.1.7.2.4.0 -l"Voltage" -u"Volts" -w$_HOSTVOLTAGE_WARN$: -c$_HOSTVOLTAGE_CRIT$:
The command runs and I do get a good value from the Radio1 host but the performance data returns as

Code: Select all

Voltage=27.287Volts;0;0;
When it should be

Code: Select all

Voltage=27.287Volts;23.5;23;
I am not sure if the variables are being inherited with values of 0 or not at all. I need to be able to define custom thresholds for different types of radios as they are powered differently and I want to have just one Check Voltage Service.
I have been trying to figure this out for two days and I am out of ideas. Any help?
Thanks.

Re: Custom Defined Variable Not Working

Posted: Wed May 13, 2015 11:21 am
by jdalrymple
Your setup looks good.

Can you change the thresholds to see if the plugin warns appropriately?

Code: Select all

_voltage_warn = 30
If it warns we know the problem isn't in your logic but rather in the plugin. If it doesn't, something isn't getting passed in proper.

Re: Custom Defined Variable Not Working

Posted: Wed May 13, 2015 1:22 pm
by raulpe
Jdalrymple,

I changed the variable to 30 as you suggested and it did alarm! However, the performance data is still reporting ;0;0

I ran it from command line and it seems it works fine if I don't put the : at the end. The values are returned in the performance data then.

Code: Select all

/usr/local/nagios/libexec/check_snmp -H X.X.X.X -o .1.3.6.1.4.1.21703.1.7.2.4.0 -l"Voltage" -u"Volts" -w30 -c23
SNMP CRITICAL - Voltage *27.711* Volts | Voltage=27.711Volts;30;23;
versus,

Code: Select all

/usr/local/nagios/libexec/check_snmp -H X.X.X.X -o .1.3.6.1.4.1.21703.1.7.2.4.0 -l"Voltage" -u"Volts" -w30: -c23:
SNMP WARNING - Voltage *27.57* Volts | Voltage=27.57Volts;0;0;
I am using check_snmp v2.0.3. Can it be that this version does not support the range? It is alarming with 30: so I think the math is right but the returned performance data is not.

Re: Custom Defined Variable Not Working

Posted: Wed May 13, 2015 1:27 pm
by raulpe
I think I got it. I need to specify both boundaries of the range 23:0 and 23.5:0 for this plugin.

Code: Select all

 /usr/local/nagios/libexec/check_snmp -H X.X.X.X -o .1.3.6.1.4.1.21703.1.7.2.4.0 -l"Voltage" -u"Volts" -w23.5:0 -c23:0
SNMP OK - Voltage 27.57 Volts | Voltage=27.57Volts;24;23;
I still don't like that it is returning 24 instead of 23.5 but it is much better than 0.

Re: Custom Defined Variable Not Working

Posted: Wed May 13, 2015 1:40 pm
by jdalrymple
Unfortunately the nagios plugin guidelines are just that "guidelines" Very very few plugins actually conform fully.

check_snmp is known to have quite a few bugs regarding handling numeric outputs. I think that the original code was intended almost entirely for interface counters which handle only integers. It would probably be fairly trivial to write your own check_snmp that handles non-integer type numeric values better, there may even be one that would work for you on the Exchange.

Maybe this one? http://exchange.nagios.org/directory/Pl ... id/details