APC

APC SmartUPS check if UPS is on batteries or cable

Description:

APC SmartUPS check if UPS is on batteries or cable

Current Version

1.0

Last Release Date

2010-09-01

Compatible With

  • Nagios 2.x
  • Nagios 3.x

Owner

License

Other


Project Files
Project Notes
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 "; 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) Add a Review
Doesn't Work
by nishith, January 31, 2013

./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



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
1 (2)
Favorites
0
Views
101,913