#!/usr/local/bin/php \n"; 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); } ?>