Checking APC UPS battery runtime
-
rdobbsmacu
- Posts: 36
- Joined: Tue Apr 28, 2015 3:11 pm
Re: Checking APC UPS battery runtime
Ok that resolved the command line output but nagios web interface is still displaying as in warning state and 0 Minutes.
Any thoughts?
and thank you for all your help so far.
Any thoughts?
and thank you for all your help so far.
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Checking APC UPS battery runtime
Check to make sure valid values are being returned by echoing the varibales:
Add these lines after your a and b variables.
Code: Select all
echo "runtime: $runtime"
echo "min: $min"As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
rdobbsmacu
- Posts: 36
- Joined: Tue Apr 28, 2015 3:11 pm
Re: Checking APC UPS battery runtime
Yes those values are returning correctly plus I also echoed stateid in all three sections.
Getting current battery runtime 95 minutes |calls=$runtime;27000;12000
Stateid 0
And nagios interface is showing warning and sending notifications.
Getting current battery runtime 95 minutes |calls=$runtime;27000;12000
Stateid 0
And nagios interface is showing warning and sending notifications.
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Checking APC UPS battery runtime
Can you show us your command and service definitions.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
rdobbsmacu
- Posts: 36
- Joined: Tue Apr 28, 2015 3:11 pm
Re: Checking APC UPS battery runtime
Here is the my updated script
Here is the command i'm running and the output from the above script
Here is the a screenshot of the service and command in nagios.
https://support.nagios.com/forum/downlo ... w&id=11444
https://support.nagios.com/forum/downlo ... w&id=11445
Code: Select all
#!/bin/bash
host=$1
runtime=$(/usr/local/nagios/libexec/check_snmp -H $host -C macu-pub -o .1.3.6.1.4.1.318.1.1.1.2.2.3.0|awk '{print $5}'| grep -o '[0-9]*')
echo $runtime
min=$(expr $runtime / 6000);
echo $min
a=27000
b=12000
##### IF else then begining #####
##### OK State #####
if [[ "$runtime" -gt "$a" ]]
then
echo "Current Battery Runtime $(($min)) Minutes""|calles=$runtime;27000;12000"
stateid=0
echo $stateid
######Warning State ######
elif [[ "$runtime" -le "$a" ]]
then
echo "Current Battery Runtime $(($min)) Minutes""|calles=$runtime;27000;12000"
stateid=1
echo $stateid
######Critical State #####
elif [[ "$runtime" -le "$b" ]]
then
echo "Current Battery Runtime $(($min)) Minutes""|calles=$runtime;27000;12000"
stateid=2
echo $stateid
##### End of If Else Then ######
fi
exit $stateidCode: Select all
./check_apc_runtime 172.18.100.65
570000
95
Current Battery Runtime 95 Minutes|calles=570000;27000;12000
0Here is the a screenshot of the service and command in nagios.
https://support.nagios.com/forum/downlo ... w&id=11444
https://support.nagios.com/forum/downlo ... w&id=11445
You do not have the required permissions to view the files attached to this post.
Last edited by tmcdonald on Thu Dec 17, 2015 3:00 pm, edited 1 time in total.
Reason: Please use [code][/code] tags around code/terminal output
Reason: Please use [code][/code] tags around code/terminal output
-
rdobbsmacu
- Posts: 36
- Joined: Tue Apr 28, 2015 3:11 pm
Re: Checking APC UPS battery runtime
I also have another script that i use to verify my equipment closets and rooms don't drop blow a set temperatures. The command line output is right but the nagios interface is also saying it is in a warning state when the temp is above the warning temp by 15 dergrees.
here is my low temp script
here is my low temp script
Code: Select all
#!/bin/bash
host=$1
temp=$(/usr/local/nagios/libexec/check_snmp -H $host -C macu-pub -o .1.3.6.1.4.1.318.1.1.25.1.2.1.5.1.1|awk '{print $4}'| grep -o '[0-9]*')
a=59
b=48
####### If statement normal ############
if [[ "$temp" -gt "$a" ]]
then
echo "Current Room Temperature is $(($temp))""|calls=$temp;59;48"
stateid=0
#echo $stateid
######## If statement warning ##########
elif [[ "$temp" -le "$a" ]]
then
echo "Currrent Room Temperature is $(($temp))""|calls=$temp;59;48"
stateid=1
#echo $stateid
######### If statement critical #########
elif [[ "$temp" -le "$b" ]]
then
echo "Current Room Temperature is $(($temp))""|calls=$temp;59;48"
stateid=2
#echo $stateid
fi
exit $stateid
Last edited by tmcdonald on Thu Dec 17, 2015 2:59 pm, edited 1 time in total.
Reason: Please use [code][/code] tags around code/terminal output
Reason: Please use [code][/code] tags around code/terminal output
Re: Checking APC UPS battery runtime
Let's try to stick the conversation to the initial script posted, and get that fixed - because they are so related I think it'll fix things all around.
Can you give this a try and let us know the result? -
Can you give this a try and let us know the result? -
Code: Select all
#!/bin/bash
host=$1
runtime=$(/usr/local/nagios/libexec/check_snmp -H $host -C macu-pub -o .1.3.6.1.4.1.318.1.1.1.2.2.3.0|awk '{print $5}'| grep -o '[0-9]*')
min=$(expr $runtime / 6000);
a=27000
b=12000
##### IF else then begining #####
##### 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
##### End of If Else Then ######
##### Catchall else #####
else
echo "Unkown error"
exit 3
fi
##### Catchall close #####
You do not have the required permissions to view the files attached to this post.
Former Nagios Employee
-
rdobbsmacu
- Posts: 36
- Joined: Tue Apr 28, 2015 3:11 pm
Re: Checking APC UPS battery runtime
If I run the script from the command line and then right after the script completes I run echo $stateid and get a blank line. Almost like it is not setting the stateid value.
-
rdobbsmacu
- Posts: 36
- Joined: Tue Apr 28, 2015 3:11 pm
Re: Checking APC UPS battery runtime
updated the script but the status is still in the warning status .
output from command line
libexec]# ./check_apc_runtime 172.18.100.64
Current Battery Runtime 90 Minutes|calles=540000;27000;12000
https://support.nagios.com/forum/downlo ... 394f1c760l in the warning.
output from command line
libexec]# ./check_apc_runtime 172.18.100.64
Current Battery Runtime 90 Minutes|calles=540000;27000;12000
https://support.nagios.com/forum/downlo ... 394f1c760l in the warning.
You do not have the required permissions to view the files attached to this post.
Re: Checking APC UPS battery runtime
I took out the stateid variable, and lead directly to an exit value in each if statement.rdobbsmacu wrote:If I run the script from the command line and then right after the script completes I run echo $stateid and get a blank line. Almost like it is not setting the stateid value.
Can you force a check and see if it changes? It looks like the service is checking only every 30 minutes.
Can you post a screenshot of the advanced tab for me to take a look at?
Former Nagios Employee