diff --git a/pandora_agents/ChangeLog b/pandora_agents/ChangeLog index ef3cc2fa15..c2f1c9fe46 100644 --- a/pandora_agents/ChangeLog +++ b/pandora_agents/ChangeLog @@ -1,3 +1,12 @@ +2009-05-05 Evi Vanoost + + * mac_osx/plugins/ipmi2xml/impi2xml.php, + linux/plugins/ipmi2xml/impi2xml.php: Updated for latest ipmitool + and works with Apple XServe "Nehalem". See blog post for adapting it + + * mac_osx/plugins/ipmi2xml/README.txt, + linux/plugins/ipmi2xml/README.txt: Updated documentation for dependencies + 2009-04-29 Jorge Gonzalez * win32/bin/pandora_agent.conf: fixed typos. diff --git a/pandora_agents/linux/plugins/ipmi2xml/README.txt b/pandora_agents/linux/plugins/ipmi2xml/README.txt index c938032e4e..8e94e9b393 100644 --- a/pandora_agents/linux/plugins/ipmi2xml/README.txt +++ b/pandora_agents/linux/plugins/ipmi2xml/README.txt @@ -1,8 +1,18 @@ This is a simple script that could be called from within pandora_user.conf -It will call an IPMI-capable host (IP-address) and acquire it's sensors, then parse them into an understandable XML file for Pandora FMS. +It will call an IPMI-capable host (IP-address) and acquire it's sensors, +then parse them into an understandable XML file for Pandora FMS. -Make sure you set up a the correct name for the agent configuration if the monitoring is done from another host than the one the IPMI chip is located at. +Make sure you set up a the correct name for the agent configuration if the +monitoring is done from another host than the one the IPMI chip is located at. -This script might not work and has only been tested so far against an Intel-based Apple XServe but the script is built up so it should acquire any. +This script might not work and has only been tested so far against an +Intel-based Apple XServe and XServe Nehalem but the script is built up so it +should acquire any other sensors. -ipmitool and php (tested 5, 4 should work too) is required on the machine the agent is running on. \ No newline at end of file +ipmitool and php (tested 5, 4 should work too) is required on the machine the +agent is running on. This incarnation of ipmi2xml has been tested with +ipmitool 2.1.8 (which is part of Apple Server Admin Tools 1.7). Previous +versions might not work (check SVN history for older versions. + +Check guruevi's blog post on http://blog.pandorafms.org for more information +on adapting this tool. \ No newline at end of file diff --git a/pandora_agents/linux/plugins/ipmi2xml/ipmi2xml.php b/pandora_agents/linux/plugins/ipmi2xml/ipmi2xml.php new file mode 100644 index 0000000000..144918627a --- /dev/null +++ b/pandora_agents/linux/plugins/ipmi2xml/ipmi2xml.php @@ -0,0 +1,123 @@ +#!/usr/bin/php +".$name."".$data."".$type.""; +} + +$output['chassis'] = shell_exec($cmd['chassis']); +$output['sensor'] = shell_exec($cmd['sensor']); + +//Chassis +/* Sample output +System Power : on +Power Overload : false +Power Interlock : inactive +Main Power Fault : false +Power Control Fault : false +Power Restore Policy : always-on +Last Power Event : +Chassis Intrusion : inactive +Front-Panel Lockout : active +Drive Fault : false +Cooling/Fan Fault : false +Front Panel Light : off +*/ +/* Sample XML +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) { + ## False is good + case "Power Overload": + case "Main Power Fault": + case "Power Control Fault": + case "Drive Fault": + case "Cooling/Fan Fault": + $data = ($data == "false" ? 1 : 0); + print_xml_sensor ($name, $data); + break; + ## Inactive is good + case "Power Interlock": + $data = ($data == "inactive" ? 1 : 0); + print_xml_sensor ($name, $data); + break; + ## On is good + case "System Power": + $data = ($data == "on" ? 1 : 0); + print_xml_sensor ($name, $data); + break; + ## Off is good + case "Front Panel Light": + $data = ($data == "off" ? 1 : 0); + print_xml_sensor ($name, $data); + break; + ## Ignore the following values + case "Last Power Event": + case "Power Restore Policy": + default: + break; + + } +} +unset($status); +//End of Chassis + +//Begin of Sensor +$array = explode("\n",$output['sensor']); +foreach ($array as $value) { + if($value != "") { + $tmp[] = explode("|",$value); + } +} + +/* +Sample $tmp: +[1] => Array + ( + [0] => CPU A Core + [1] => 1.264 + [2] => Volts + [3] => ok + [4] => na + [5] => na + [6] => 1.000 + [7] => 1.368 + [8] => na + [9] => na + ) + +*/ +unset ($tmp[0]); +foreach ($tmp as $value_arr) { + if (trim($value_arr[1]) == "na") { + continue; + } elseif (trim($value_arr[2]) == "discrete") { + continue; + } + print_xml_sensor (trim($value_arr[0]).' ('.trim($value_arr[2]).')', trim ($value_arr[1]), "generic_data"); +} + +//End of Sensor + +?> \ No newline at end of file diff --git a/pandora_agents/linux/plugins/ipmi2xml/ipmi2xml.txt b/pandora_agents/linux/plugins/ipmi2xml/ipmi2xml.txt deleted file mode 100644 index 3d39741a3c..0000000000 --- a/pandora_agents/linux/plugins/ipmi2xml/ipmi2xml.txt +++ /dev/null @@ -1,147 +0,0 @@ -#!/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 - -?> diff --git a/pandora_agents/mac_osx/plugins/ipmi2xml/README.txt b/pandora_agents/mac_osx/plugins/ipmi2xml/README.txt index 4ee0469912..8e94e9b393 100644 --- a/pandora_agents/mac_osx/plugins/ipmi2xml/README.txt +++ b/pandora_agents/mac_osx/plugins/ipmi2xml/README.txt @@ -1,8 +1,18 @@ -This is a plugin that can be called from within the Pandora configuration file. +This is a simple script that could be called from within pandora_user.conf +It will call an IPMI-capable host (IP-address) and acquire it's sensors, +then parse them into an understandable XML file for Pandora FMS. -It will call an IPMI-capable host (IP-address) and acquire it's sensors, then parse them into an understandable XML file for Pandora FMS. -Make sure you set up a the correct name for the agent configuration if the monitoring is done from another host than the one the IPMI chip is located at. +Make sure you set up a the correct name for the agent configuration if the +monitoring is done from another host than the one the IPMI chip is located at. -This script might not work and has only been tested so far against an Intel-based Apple XServe but the script is built up so it should acquire any. +This script might not work and has only been tested so far against an +Intel-based Apple XServe and XServe Nehalem but the script is built up so it +should acquire any other sensors. -Requires ipmitool and php (4 or 5) on the machine the agent is running on. +ipmitool and php (tested 5, 4 should work too) is required on the machine the +agent is running on. This incarnation of ipmi2xml has been tested with +ipmitool 2.1.8 (which is part of Apple Server Admin Tools 1.7). Previous +versions might not work (check SVN history for older versions. + +Check guruevi's blog post on http://blog.pandorafms.org for more information +on adapting this tool. \ No newline at end of file diff --git a/pandora_agents/mac_osx/plugins/ipmi2xml/ipmi2xml.php b/pandora_agents/mac_osx/plugins/ipmi2xml/ipmi2xml.php index 3d39741a3c..5a003d40ca 100644 --- a/pandora_agents/mac_osx/plugins/ipmi2xml/ipmi2xml.php +++ b/pandora_agents/mac_osx/plugins/ipmi2xml/ipmi2xml.php @@ -1,8 +1,8 @@ #!/usr/bin/php ".$name."".$data."".$type.""; +} $output['chassis'] = shell_exec($cmd['chassis']); $output['sensor'] = shell_exec($cmd['sensor']); @@ -46,100 +48,74 @@ unset($tmp); foreach ($status as $name => $data) { switch($name) { - case "Power Interlock": - case "Last Power Event": - case "System Power": - case "Power Restore Policy": - break; + ## False is good 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 "Power Control Fault": + case "Drive Fault": + case "Cooling/Fan Fault": + $data = ($data == "false" ? 1 : 0); + print_xml_sensor ($name, $data); + break; + ## Inactive is good + case "Power Interlock": + $data = ($data == "inactive" ? 1 : 0); + print_xml_sensor ($name, $data); + break; + ## On is good + case "System Power": + $data = ($data == "on" ? 1 : 0); + print_xml_sensor ($name, $data); + break; + ## Off is good case "Front Panel Light": - $data_out = ($data="off" ? "1" : "0"); - echo "" . $name . "" . $data_out . "generic_proc"; - } + $data = ($data == "off" ? 1 : 0); + print_xml_sensor ($name, $data); + break; + ## Ignore the following values + case "Last Power Event": + case "Power Restore Policy": + default: + break; + + } } unset($status); //End of Chassis //Begin of Sensor -$array = explode("\n\n",$output['sensor']); +$array = explode("\n",$output['sensor']); foreach ($array as $value) { if($value != "") { - $tmp[] = explode("\n",$value); + $tmp[] = explode("|",$value); } } +/* +Sample $tmp: +[1] => Array + ( + [0] => CPU A Core + [1] => 1.264 + [2] => Volts + [3] => ok + [4] => na + [5] => na + [6] => 1.000 + [7] => 1.368 + [8] => na + [9] => na + ) + +*/ +unset ($tmp[0]); 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); + if (trim($value_arr[1]) == "na") { + continue; + } elseif (trim($value_arr[2]) == "discrete") { + continue; + } + print_xml_sensor (trim($value_arr[0]).' ('.trim($value_arr[2]).')', trim ($value_arr[1]), "generic_data"); } //End of Sensor