Checking APC UPS battery runtime

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
rdobbsmacu
Posts: 36
Joined: Tue Apr 28, 2015 3:11 pm

Re: Checking APC UPS battery runtime

Post by rdobbsmacu »

after every script change I have been forcing the checks.

Here is you screenshot you asked for.

https://support.nagios.com/forum/downlo ... w&id=11456
You do not have the required permissions to view the files attached to this post.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Checking APC UPS battery runtime

Post by rkennedy »

This is bizarre, the only difference I'm doing over here is setting $runtime statically, as I don't have a UPS to test with.

Can you try modifying the 3 lines that echo the result to include the $runtime so that we can get some debugging? For example -

Code: Select all

echo "Current Battery Runtime $(($min)) Minutes ($runtime)""|calles=$runtime;27000;12000"
Former Nagios Employee
rdobbsmacu
Posts: 36
Joined: Tue Apr 28, 2015 3:11 pm

Re: Checking APC UPS battery runtime

Post by rdobbsmacu »

here is the output after that change

# ./check_apc_runtime 172.18.100.65
Current Battery Runtime 95 Minutes (570000)|calles=570000;27000;12000

in the interface is now displaying this Current Battery Runtime 0 Minutes (). still warning status.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Checking APC UPS battery runtime

Post by rkennedy »

Can you verify the permission of check_snmp?

Code: Select all

ls -l /usr/local/nagios/libexec/check_snmp
Former Nagios Employee
rdobbsmacu
Posts: 36
Joined: Tue Apr 28, 2015 3:11 pm

Re: Checking APC UPS battery runtime

Post by rdobbsmacu »

-rwxr-xr-x 1 root root 251289 Apr 23 2015 /usr/local/nagios/libexec/check_snmp
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Checking APC UPS battery runtime

Post by rkennedy »

Can you try running the following, and then force a check? -

Code: Select all

chown apache:nagios check_snmp
Former Nagios Employee
rdobbsmacu
Posts: 36
Joined: Tue Apr 28, 2015 3:11 pm

Re: Checking APC UPS battery runtime

Post by rdobbsmacu »

ok ran the chown and forced check no change.
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: Checking APC UPS battery runtime

Post by jolson »

I cleaned up the code a little bit and quoted some values - can you give this a try?

Code: Select all

#!/bin/bash

if [ $# == 0 -o "$1" == "-h" -o  $# -gt 1 ]; then
        echo "Usage: ./snmp_upc.sh <host>"
        exit 3
fi

CHK="/usr/local/nagios/libexec/check_snmp"
MIB=".1.3.6.1.4.1.318.1.1.1.2.2.3.0"

RUNTIME=$($CHK -H "$1" -C macu-pub -o "$MIB" | awk '{print $5}'| grep -o '[0-9]*')
MIN=$(expr $RUNTIME / 6000);

a=27000
b=12000

### If then beginning ###

    ### OK State ###
if [[ "$RUNTIME" -gt "$a" ]]
    then
    echo "Current Battery Runtime $(($MIN)) Minutes""|calles=$RUNTIME;27000;12000"
    exit 0

    ### Warning State ###
elif [[ "$RUNTIME" -le "$a" ]]
    then
    echo "Current Battery Runtime $(($MIN)) Minutes""|calles=$RUNTIME;27000;12000"
    exit 1

    ### Critical State ###
elif [[ "$RUNTIME" -le "$b" ]]
    then
    echo "Current Battery Runtime $(($MIN)) Minutes""|calles=$RUNTIME;27000;12000"
    exit 2

    ### Catchall else ###
else
    echo "Unkown error"
    exit 3
fi
    ### Catchall close ###
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.
rdobbsmacu
Posts: 36
Joined: Tue Apr 28, 2015 3:11 pm

Re: Checking APC UPS battery runtime

Post by rdobbsmacu »

OK I updated the script with what you gave.

Here is the command I ran and it's output from the command line

./check_apc_runtime 172.18.100.65
Current Battery Runtime 95 Minutes|calles=570000;27000;12000


in the web interface shows this after forcing check.

https://support.nagios.com/forum/downlo ... w&id=11477
You do not have the required permissions to view the files attached to this post.
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: Checking APC UPS battery runtime

Post by jolson »

Could you please show us your command definition from the GUI? I am also interested in seeing your service definition. You can find them in 'Configure -> Core Config Manager'.
2015-12-21 09_32_02-Nagios XI - Nagios Core Config Manager.png
You do not have the required permissions to view the files attached to this post.
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.
Locked