Change SNMP data

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
csayre
Posts: 9
Joined: Mon Jan 04, 2016 3:09 pm

Change SNMP data

Post 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?
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Change SNMP data

Post by hsmith »

If you check it from the command line, is the value correct?
Former Nagios Employee.
me.
csayre
Posts: 9
Joined: Mon Jan 04, 2016 3:09 pm

Re: Change SNMP data

Post by csayre »

hsmith wrote:If you check it from the command line, is the value correct?

No it is returning 1225
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Change SNMP data

Post 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.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Change SNMP data

Post by rkennedy »

Thanks @gormank!

As @gormank mentioned - please post the script that you're using to check.
Former Nagios Employee
csayre
Posts: 9
Joined: Mon Jan 04, 2016 3:09 pm

Re: Change SNMP data

Post 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;
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: Change SNMP data

Post 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.
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Change SNMP data

Post 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?
Be sure to check out our Knowledgebase for helpful articles and solutions!
csayre
Posts: 9
Joined: Mon Jan 04, 2016 3:09 pm

Re: Change SNMP data

Post 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
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Change SNMP data

Post by rkennedy »

Did you try @jolson's script? It should work for you.
Former Nagios Employee
Locked