Home Directory Plugins Hardware UPS APC APC SmartUPS check if UPS is on batteries or cable

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

APC SmartUPS check if UPS is on batteries or cable

Rating
2 votes
Favoured:
0
Current Version
1.0
Last Release Date
2010-09-01
Compatible With
  • Nagios 2.x
  • Nagios 3.x
Owner
License
Other
Hits
101950
Files:
FileDescription
check_apccheck_apc
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
APC SmartUPS check if UPS is on batteries or cable
This script will check if the UPS is on batteries (and display the percent of battery which is left) or on cable power.

#!/usr/local/bin/php

/*
*
* Can check if your APC Smart UPS is on batteries or on power.
* Made by Soeren, sa@billetkontoret.dk 29-06-2010
*
*/

if(!isset($argv[1]))
{
echo "Usage: ./check_apc ";
exit(2);
}

$host = $argv[1];
$query = @snmpget("$host", "public", ".1.3.6.1.4.1.318.1.1.1.4.1.1.0", 1000000);
$snmp = str_replace(array("INTEGER: ", """),"",$query);

if ($query)
{
if ($snmp == 1)
{
$output = "State unknown";
echo $output;
exit(1);
}
if ($snmp == 2)
{
$output = "Power connected";
echo $output;
exit(0);
}
if ($snmp == 3)
{
$query3 = @snmpget("$host", "public", ".1.3.6.1.4.1.318.1.1.1.2.2.1.0", 1000000);
$charge = str_replace(array("Gauge32: ", """),"",$query3);
$output = "Power lost. Running on batteries. $charge% left.";
echo $output;
exit(1);
}
if ($snmp == 7)
{
$output = "UPS turned off";
echo $output;
exit(1);
}
if ($snmp == 8)
{
$output = "UPS is rebooting";
echo $output;
exit(1);
}
if ($snmp == 11)
{
$output = "UPS is sleeping until power returns";
echo $output;
exit(1);
}

}
else
{
echo "Cannot read data from host.";
exit(2);
}

?>

Remember to change /usr/local/bin/php to whereever your php-binary is located. Also chmod +x check_apc

commands.cfg:

define command{
command_name check_apc
command_line $USER1$/check_apc_on_battery $HOSTADDRESS$
}

services.cfg:

define service{
use default-critical
host_name apc
service_description UPS Status
check_command check_apc! $HOSTADDRESS$
max_check_attempts 1
notification_interval 5
}
Reviews (1)
bynishith, January 24, 2013
0 of 1 people found this review helpful
./check_apc.php 10.0.64.191 public
No Result

php check_apc.php 10.0.64.191 public
No Result

php check_apc.php 10.0.64.191
No Result