APC

check_apcupsd

Description:

Nagios plugin to monitor APC Smart-UPSes using apcupsd.

Current Version

Last Release Date

June 11, 2009

Compatible With


Project Files
Project Photos
Project Notes
Monitor battery charge, internal temperature, load and time left on one or more APC Smart-UPSes. Compared to other similar plugins, this plugin allows you to specify hostname and port for apcupsd, which makes it possible to monitor UPSes connected to remote hosts and/or several UPSes connected to the local host. Look in the script for an example to get you started. Run the script without parameters to get full usage info. Remember to check out the nice screen shot :-) Note: The trick to monitor several local UPSes is to run several apcupsds on different ports.
Reviews (9) Add a Review
Great script
by CircaLucid, January 31, 2015

Great script. I added a fix to show the serial. Here's the patch: --- /usr/lib/nagios/plugins/check_apcupsd 2013-06-16 13:30:39.000000000 -0400 +++ /root/check_apcupsd.2 2015-01-20 12:43:31.437445687 -0500 @@ -96,7 +96,7 @@ { echo "usage: check_apcupsd [-c critical_value] [-h hostname] [-p port]" echo -n " [-w warning_value] " - echo "" + echo "" echo echo "hostname and port defaults to localhost and 3551, respectively." echo @@ -111,6 +111,7 @@ echo " measured in minutes." echo " linefail = Whether the line is OK or not (Back UPS only)" echo " status = Same as 'linefail' (Back UPS ES only - maybe others)" + echo " serial = Shows the device serial" echo " battstat = Whether the battery is OK or not (Back UPS only)" exit 3 } @@ -146,7 +147,7 @@ if [ "$ARG" != "bcharge" -a "$ARG" != "battv" -a "$ARG" != "itemp" -a "$ARG" != "loadpct" -a "$ARG" != "timeleft" -a "$ARG" != "linefail" - -a "$ARG" != "battstat" -a "$ARG" != "status" ]; then + -a "$ARG" != "battstat" -a "$ARG" != "status" -a "$ARG" != "serial" ]; then usage fi @@ -191,7 +192,7 @@ fi # Back UPS reports only an OK / ERR state -if [ "$ARG" != "linefail" -a "$ARG" != "battstat" -a "$ARG" != "status" ]; then +if [ "$ARG" != "linefail" -a "$ARG" != "battstat" -a "$ARG" != "status" -a "$ARG" != "serial" ]; then VALUE=`$APCACCESS status $HOSTNAME:$PORT | grep -i ^$ARG | sed 's/.*: *([0-9.][0-9.]*)[^0-9.].*/1/'` if [ -z "$VALUE" ]; then @@ -202,6 +203,23 @@ VALUE=`echo $VALUE | sed 's/^0*//'` fi ROUNDED=`echo $VALUE | sed 's/..*//'` +elif [ "$ARG" = "serial" ]; then + VALUE=`$APCACCESS status $HOSTNAME:$PORT | grep -i ^$ARG | + sed 's/.*: *([A-Z]*).*/1/'` + if [ -z "$VALUE" ]; then + echo "UPS does not support $ARG" + exit 3 + fi + if [ "$VALUE" = "AS" ]; then + ROUNDED=1 + else + ROUNDED=0 + fi + VALUE=`$APCACCESS status $HOSTNAME:$PORT | grep -i ^$ARG` + if [ -z "$VALUE" ]; then + echo "UPS does not support $ARG" + exit 3 + fi else VALUE=`$APCACCESS status $HOSTNAME:$PORT | grep -i ^$ARG | sed 's/.*: *([A-Z]*).*/1/'` @@ -363,6 +381,16 @@ fi echo "${STATUS} - Time Left: $VALUE Minutes|'minutes left'=${VALUE};$WARNVAL:;$CRITVAL:;;" ;; +serial) + if [ $ROUNDED -gt 0 ]; then + STATUS="OK" + EXITVALUE=0 + else + STATUS="CRITICAL" + EXITVALUE=2 + fi + echo "${STATUS} - ${VALUE}" + ;; esac exit $EXITVALUE



Nice, a little bug easy to fix
by ftrahan, December 31, 2013

High. Nice script. Though I found a little bug. When you clean leading zeros, you clean to many of them and a value of "0.0" becomes ".0" which is not detected by your script... Here's a patch : --- check_apcupsd.old 2013-12-02 10:20:28.395006242 -0500 +++ check_apcupsd 2013-12-02 10:20:59.751405840 -0500 @@ -158,7 +158,7 @@ VALUE=`$APCACCESS status $HOSTNAME:$PORT | grep -i ^$ARG | sed 's/.*: *([0-9.][0-9.]*)[^0-9.].*/1/'` -if [ "$VALUE" != "0" ]; then +if [ "$VALUE" != "0" -a "$VALUE" != "0.0" ]; then VALUE=`echo $VALUE | sed 's/^0*//'` fi ROUNDED=`echo $VALUE | sed 's/..*//'`



Showing No Output,But may work
by nishith, January 31, 2013

Below is the exercise,which I have done on Nagios Core 3.4.3. Command1 touch /sbin/apcaccess chmod +x /sbin/apcaccess Command2 ./check_apcupsd -h timeleft Output: OK - Time Left: Minutes Command3 /check_apcupsd -h ups1 bcharge OK - Battery Charge: % Means, it is not showing output in % properly. It seems that there is a need to modify the plugin again. Nishith N.Vyas



perfData patch for NagVis
by marcomc, January 31, 2013

I just created a very small patch to add a few perfData information to make the script compatible with NagVis gadgets



Multiple UPSs
by azteca61, June 30, 2012

How can I add ports to check_apcupsd plugin? I have apcupsd running ports 3551, 3552 and 3553 but Nagios only shows 3551. thanks



great, but dealing with an issue
by rclauff, June 30, 2012

We recently started monitoring all of our UPS's so this was extremely useful and the setup is fast and easy, BUT the only problem I have is if I have a host that has multiple UPS's and they're on different ports I am getting a null response. If i execute the same command from console i get a good response. Any suggestions? I have tried making separate services, putting them all on one host,tried adding the port option to the plugin, still nothing works.



very handy - one minor problem
by jsellens, July 31, 2011

Very handy plugin - ran into one minor problem in version 2.4 with the "status" command. check_apcupsd only looks at the first word in the STATUS: provided by apcaccess. Changing the check at line 188 from this: VALUE=`$APCACCESS status $HOSTNAME:$PORT | grep -i ^$ARG | sed 's/.*: *([A-Z]*).*/1/'` to this: VALUE=`$APCACCESS status $HOSTNAME:$PORT | grep -i ^$ARG | sed -e 's/^.*: *//' -e 's/ *$//'` seemed to do the trick for me - now our brand new UPS can report "ONLINE NOBATT" and we'll notice! Thanks! John



Excellent
by bshephard, November 30, 2010

An excellent plugin for APCUPSD but to expand it further it would be nice if it could provide performance data that can then be graphed by pnp4nagios and perhaps check a few more items reported on by apcaccess such as the mains voltage.



Brilliant
by Bhawks_2, September 30, 2010

Great plugin! In the text file sample commands and services are included. Took about 15 minutes to set up and displays all UPS info nicely in nagios Great work, thanks!



Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
4.1 (10)
Favorites
3
Views
385,030