Build precise queries to find exactly what you need
Press ESC to close
Your review has been submitted and is pending approval.
APC SmartUPS check if UPS is on batteries or cable
Current Version
1.0
Last Release Date
2010-09-01
Owner
Community Member
License
Other
Compatible With
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 <?php
/* * * Can check if your APC Smart UPS is on batteries or on power. * Made by Soeren, [email protected] 29-06-2010 * */
if(!isset($argv[1])) { echo "Usage: ./check_apc <hostname or IP-address> "; 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 }
./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
You must be logged in to submit a review.
To:
From:
We’ve completely redesigned the world’s largest repository of Nagios plugins and monitoring tools. Join thousands of users sharing monitoring solutions for servers, applications, and everything in between.
Due to our redesign, all existing accounts require a password reset to access your account again.
Ready to explore 6,100+ projects and contribute to the community?
Reset Password Create Account
Happy Monitoring!