Page 1 of 2

Change SNMP data

Posted: Tue Mar 01, 2016 8:21 am
by csayre
Hello,

I am having a problem configuring snmp to monitor a UPS. The monitoring works, but it displays data improperly. For example, SNMP OK - Input Voltage 1227 Volts should be 122.7 Volts.

Is there any way to fix this?

Re: Change SNMP data

Posted: Tue Mar 01, 2016 10:53 am
by hsmith
If you check it from the command line, is the value correct?

Re: Change SNMP data

Posted: Wed Mar 02, 2016 9:10 am
by csayre
hsmith wrote:If you check it from the command line, is the value correct?

No it is returning 1225

Re: Change SNMP data

Posted: Wed Mar 02, 2016 11:11 am
by gormank
So you're fetching it w/ snmpget? I'd look into adding the decimal, or lopping off the last digit and verifying the value is greater than 2 digits, 100 or greater. Nagios receives what is sent or pulled from the SNMP system, it doesn't change the data.

More info's needed on what script, language, etc. is pulling the data.

Re: Change SNMP data

Posted: Wed Mar 02, 2016 12:29 pm
by rkennedy
Thanks @gormank!

As @gormank mentioned - please post the script that you're using to check.

Re: Change SNMP data

Posted: Thu Mar 03, 2016 9:29 am
by csayre
I am using nagios xi currently under an evaluation license. The command that I am using is check_xi_service_snmp.

Here is the test output.

COMMAND: /usr/local/nagios/libexec/check_snmp -H 10.2.50.251 -o 1.3.6.1.4.1.318.1.1.1.2.3.4.0 -C snmpstring -P 1 -l "Battery Actual Voltage" -u "V DC" -m powernet417.mib -w @682.5:882.5 -c @0:682.5
OUTPUT: SNMP OK - Battery Actual Voltage 1364 V DC | 'Battery Actual Voltage'=1364V DC;882;682;

Re: Change SNMP data

Posted: Thu Mar 03, 2016 5:55 pm
by jolson
I think that the best way to approach this likely involves a simple wrapper script. You'll have to make your own script and implement it as a new plugin in XI - example:

Code: Select all

#!/bin/bash

output=$(/usr/local/nagios/libexec/check_snmp -H 10.2.50.251 -o 1.3.6.1.4.1.318.1.1.1.2.3.4.0 -C snmpstring -P 1 -l "Battery Actual Voltage" -u "V DC" -m powernet417.mib -w @682.5:882.5 -c @0:682.5)
exit=$?

if [ "$exit" == 0 ]
then
        output2=$(echo "$output" | sed "s/./\.&/45")
        output3=$(echo "$output2" | sed "s/./\.&/83")
        echo "$output3"
        exit 0
elif [ "$exit" == 1 ]
then
        echo "$output"
        exit 1
elif [ "$exit" == 2 ]
then
        echo "$output"
        exit 2
elif [ "$exit" == 3 ]
then
        echo "$output"
        exit 3
fi
I wrote this script quickly, so it's likely riddled with things that could be improved - but hopefully it serves the purpose of demonstration. If you can modify the standard output, you can modify how Nagios interprets the results.

Re: Change SNMP data

Posted: Thu Mar 03, 2016 5:59 pm
by tgriep
Do you want to check the input voltage to your UPS or the battery voltage, or both?
What OID are you using to monitor the input voltage?
Can you run the following and post the output?

Code: Select all

/usr/local/nagios/libexec/check_snmp -H 10.2.50.251 -o 1.3.6.1.4.1.318.1.1.1.3.3.1.0 -C snmpstring -P 1 -m powernet417.mib
Can you upload the MIB file so we can review it?

Re: Change SNMP data

Posted: Fri Mar 04, 2016 10:21 am
by csayre
Do you want to check the input voltage to your UPS or the battery voltage, or both?
Both

What OID are you using to monitor the input voltage?
1.3.6.1.4.1.318.1.1.1.3.3.1.0

Can you run the following and post the output?
SNMP OK - 1237 | iso 3.6.1.4.1.318.1.1.1.3.3.1.0=1237

https://dl.dropboxusercontent.com/u/944 ... net417.mib

Re: Change SNMP data

Posted: Fri Mar 04, 2016 10:34 am
by rkennedy
Did you try @jolson's script? It should work for you.