#!/usr/bin/php 28.5DRIVE BAYgeneric_data */ $array = explode("\n",$output['chassis']); foreach ($array as $value) { if($value != "") { $tmp = explode(":",$value); $status[trim($tmp[0])] = trim($tmp[1]); } } unset($array); unset($tmp); foreach ($status as $name => $data) { switch($name) { case "Power Interlock": case "Last Power Event": case "System Power": case "Power Restore Policy": break; case "Power Overload": case "Main Power Fault": case "Power Control Fault": case "Drive Fault": case "Cooling/Fan Fault": $data_out = ($data="false" ? "1" : "0"); case "Front Panel Light": $data_out = ($data="off" ? "1" : "0"); echo "" . $name . "" . $data_out . "generic_proc"; } } unset($status); //End of Chassis //Begin of Sensor $array = explode("\n\n",$output['sensor']); foreach ($array as $value) { if($value != "") { $tmp[] = explode("\n",$value); } } foreach ($tmp as $value_arr) { foreach ($value_arr as $value) { if($value != "") { $tmp2 = explode(":",$value); $status[trim($tmp2[0])] = trim($tmp2[1]); } } unset($value_arr); unset($tmp2); /* Sample $status array [Sensor ID] => 'PSU1 Fan Out' (0x3c) [Entity ID] => 10.1 [Sensor Type (Analog)] => Fan [Sensor Reading] => 6784 (+/- 0) RPM [Status] => ok [Lower Non-Recoverable] => na [Lower Critical] => na [Lower Non-Critical] => 1024.000 [Upper Non-Critical] => 18048.000 [Upper Critical] => na [Upper Non-Recoverable] => na [Assertion Events] => [Assertions Enabled] => lnc- lnc+ unc- unc+ [Deassertions Enabled] => lnc- lnc+ unc- unc+ */ //Get the name without references $name_tmp = explode("'",$status["Sensor ID"]); /* //Get the Sensor Type if(array_key_exists("Sensor Type (Analog)",$status)) { $status["type"] = $status["Sensor Type (Analog)"]; } elseif(array_key_exists("Sensor Type (Discrete)",$status)) { $status["type"] = $status["Sensor Type (Discrete)"]; } else { echo "Unhandled Sensor Type"; print_r($status); die(); } */ $data_tmp = explode(" ",$status["Sensor Reading"]); if($data_tmp[3]) { $name = $name_tmp[1] . " (" . $data_tmp[3] . ($data_tmp[4] ? " " . $data_tmp[4] : "" ) . ")"; echo "\n" . $name . ""; if($status["Lower Non-Critical"] != "na") { $min = "" . $status["Lower Non-Critical"] . ""; } if($status["Upper Non-Critical"] != "na") { $max = "" . $status["Upper Non-Critical"] . ""; } if($status["Lower Critical"] != "na") { $min = "" . $status["Lower Critical"] . ""; } if($status["Upper Critical"] != "na") { $max = "" . $status["Upper Critical"] . ""; } echo $min . $max . "" . $data_tmp[0] . "generic_data"; } //$data_out = ($data="false" ? "1" : "0"); //$data_out = ($data="off" ? "1" : "0"); unset($status); } //End of Sensor ?>