mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
2009-05-05 Evi Vanoost <vanooste@rcbi.rochester.edu>
* 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 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1677 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
5f91d81532
commit
a39a672b01
@ -1,3 +1,12 @@
|
|||||||
|
2009-05-05 Evi Vanoost <vanooste@rcbi.rochester.edu>
|
||||||
|
|
||||||
|
* 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 <jorgegonz@artica.es>
|
2009-04-29 Jorge Gonzalez <jorgegonz@artica.es>
|
||||||
|
|
||||||
* win32/bin/pandora_agent.conf: fixed typos.
|
* win32/bin/pandora_agent.conf: fixed typos.
|
||||||
|
@ -1,8 +1,18 @@
|
|||||||
This is a simple script that could be called from within pandora_user.conf
|
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.
|
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.
|
123
pandora_agents/linux/plugins/ipmi2xml/ipmi2xml.php
Normal file
123
pandora_agents/linux/plugins/ipmi2xml/ipmi2xml.php
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
#!/usr/bin/php
|
||||||
|
<?php
|
||||||
|
$host = "yourserver.example.net";
|
||||||
|
$user = "youruser";
|
||||||
|
$pass = "yourpassword";
|
||||||
|
$path = "ipmitool";
|
||||||
|
|
||||||
|
$opt['chassis'] = "chassis status";
|
||||||
|
$opt['sensor'] = "sensor";
|
||||||
|
|
||||||
|
$cmd['chassis'] = $path . " -H " . $host . " -U " . $user . " -P " . $pass . " " . $opt['chassis'];
|
||||||
|
$cmd['sensor'] = $path . " -H " . $host . " -U " . $user . " -P " . $pass . " " . $opt['sensor'];
|
||||||
|
|
||||||
|
function print_xml_sensor ($name, $data, $type = "generic_proc") {
|
||||||
|
echo "<module><name>".$name."</name><data>".$data."</data><type>".$type."</type></module>";
|
||||||
|
}
|
||||||
|
|
||||||
|
$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
|
||||||
|
<module><data>28.5</data><name>DRIVE BAY</name><type>generic_data</type></module>
|
||||||
|
*/
|
||||||
|
$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
|
||||||
|
|
||||||
|
?>
|
@ -1,147 +0,0 @@
|
|||||||
#!/usr/bin/php
|
|
||||||
<?php
|
|
||||||
$host = "128.151.188.89";
|
|
||||||
$user = "pandora";
|
|
||||||
$pass = "";
|
|
||||||
$path = "ipmitool";
|
|
||||||
|
|
||||||
$opt['chassis'] = "chassis status";
|
|
||||||
$opt['sensor'] = "sensor";
|
|
||||||
|
|
||||||
$cmd['chassis'] = $path . " -H " . $host . " -U " . $user . " -P " . $pass . " " . $opt['chassis'];
|
|
||||||
$cmd['sensor'] = $path . " -H " . $host . " -U " . $user . " -P " . $pass . " " . $opt['sensor'];
|
|
||||||
|
|
||||||
//print_r($cmd);
|
|
||||||
|
|
||||||
$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
|
|
||||||
<module><data>28.5</data><name>DRIVE BAY</name><type>generic_data</type></module>
|
|
||||||
*/
|
|
||||||
$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 "<module><name>" . $name . "</name><data>" . $data_out . "</data><type>generic_proc</type></module>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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<module><name>" . $name . "</name>";
|
|
||||||
if($status["Lower Non-Critical"] != "na") {
|
|
||||||
$min = "<min>" . $status["Lower Non-Critical"] . "</min>";
|
|
||||||
}
|
|
||||||
if($status["Upper Non-Critical"] != "na") {
|
|
||||||
$max = "<max>" . $status["Upper Non-Critical"] . "</max>";
|
|
||||||
}
|
|
||||||
if($status["Lower Critical"] != "na") {
|
|
||||||
$min = "<min>" . $status["Lower Critical"] . "</min>";
|
|
||||||
}
|
|
||||||
if($status["Upper Critical"] != "na") {
|
|
||||||
$max = "<max>" . $status["Upper Critical"] . "</max>";
|
|
||||||
}
|
|
||||||
echo $min . $max . "<data>" . $data_tmp[0] . "</data><type>generic_data</type></module>";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//$data_out = ($data="false" ? "1" : "0");
|
|
||||||
//$data_out = ($data="off" ? "1" : "0");
|
|
||||||
|
|
||||||
unset($status);
|
|
||||||
}
|
|
||||||
|
|
||||||
//End of Sensor
|
|
||||||
|
|
||||||
?>
|
|
@ -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
|
||||||
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.
|
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.
|
@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/php
|
#!/usr/bin/php
|
||||||
<?php
|
<?php
|
||||||
$host = "128.151.188.89";
|
$host = "yourserver.example.net";
|
||||||
$user = "pandora";
|
$user = "youruser";
|
||||||
$pass = "";
|
$pass = "yourpassword";
|
||||||
$path = "ipmitool";
|
$path = "ipmitool";
|
||||||
|
|
||||||
$opt['chassis'] = "chassis status";
|
$opt['chassis'] = "chassis status";
|
||||||
@ -11,7 +11,9 @@ $opt['sensor'] = "sensor";
|
|||||||
$cmd['chassis'] = $path . " -H " . $host . " -U " . $user . " -P " . $pass . " " . $opt['chassis'];
|
$cmd['chassis'] = $path . " -H " . $host . " -U " . $user . " -P " . $pass . " " . $opt['chassis'];
|
||||||
$cmd['sensor'] = $path . " -H " . $host . " -U " . $user . " -P " . $pass . " " . $opt['sensor'];
|
$cmd['sensor'] = $path . " -H " . $host . " -U " . $user . " -P " . $pass . " " . $opt['sensor'];
|
||||||
|
|
||||||
//print_r($cmd);
|
function print_xml_sensor ($name, $data, $type = "generic_proc") {
|
||||||
|
echo "<module><name>".$name."</name><data>".$data."</data><type>".$type."</type></module>";
|
||||||
|
}
|
||||||
|
|
||||||
$output['chassis'] = shell_exec($cmd['chassis']);
|
$output['chassis'] = shell_exec($cmd['chassis']);
|
||||||
$output['sensor'] = shell_exec($cmd['sensor']);
|
$output['sensor'] = shell_exec($cmd['sensor']);
|
||||||
@ -46,100 +48,74 @@ unset($tmp);
|
|||||||
|
|
||||||
foreach ($status as $name => $data) {
|
foreach ($status as $name => $data) {
|
||||||
switch($name) {
|
switch($name) {
|
||||||
case "Power Interlock":
|
## False is good
|
||||||
case "Last Power Event":
|
|
||||||
case "System Power":
|
|
||||||
case "Power Restore Policy":
|
|
||||||
break;
|
|
||||||
case "Power Overload":
|
case "Power Overload":
|
||||||
case "Main Power Fault":
|
case "Main Power Fault":
|
||||||
case "Power Control Fault":
|
case "Power Control Fault":
|
||||||
case "Drive Fault":
|
case "Drive Fault":
|
||||||
case "Cooling/Fan Fault":
|
case "Cooling/Fan Fault":
|
||||||
$data_out = ($data="false" ? "1" : "0");
|
$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":
|
case "Front Panel Light":
|
||||||
$data_out = ($data="off" ? "1" : "0");
|
$data = ($data == "off" ? 1 : 0);
|
||||||
echo "<module><name>" . $name . "</name><data>" . $data_out . "</data><type>generic_proc</type></module>";
|
print_xml_sensor ($name, $data);
|
||||||
|
break;
|
||||||
|
## Ignore the following values
|
||||||
|
case "Last Power Event":
|
||||||
|
case "Power Restore Policy":
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($status);
|
unset($status);
|
||||||
//End of Chassis
|
//End of Chassis
|
||||||
|
|
||||||
//Begin of Sensor
|
//Begin of Sensor
|
||||||
$array = explode("\n\n",$output['sensor']);
|
$array = explode("\n",$output['sensor']);
|
||||||
foreach ($array as $value) {
|
foreach ($array as $value) {
|
||||||
if($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 ($tmp as $value_arr) {
|
||||||
foreach ($value_arr as $value) {
|
if (trim($value_arr[1]) == "na") {
|
||||||
if($value != "") {
|
continue;
|
||||||
$tmp2 = explode(":",$value);
|
} elseif (trim($value_arr[2]) == "discrete") {
|
||||||
$status[trim($tmp2[0])] = trim($tmp2[1]);
|
continue;
|
||||||
}
|
}
|
||||||
}
|
print_xml_sensor (trim($value_arr[0]).' ('.trim($value_arr[2]).')', trim ($value_arr[1]), "generic_data");
|
||||||
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<module><name>" . $name . "</name>";
|
|
||||||
if($status["Lower Non-Critical"] != "na") {
|
|
||||||
$min = "<min>" . $status["Lower Non-Critical"] . "</min>";
|
|
||||||
}
|
|
||||||
if($status["Upper Non-Critical"] != "na") {
|
|
||||||
$max = "<max>" . $status["Upper Non-Critical"] . "</max>";
|
|
||||||
}
|
|
||||||
if($status["Lower Critical"] != "na") {
|
|
||||||
$min = "<min>" . $status["Lower Critical"] . "</min>";
|
|
||||||
}
|
|
||||||
if($status["Upper Critical"] != "na") {
|
|
||||||
$max = "<max>" . $status["Upper Critical"] . "</max>";
|
|
||||||
}
|
|
||||||
echo $min . $max . "<data>" . $data_tmp[0] . "</data><type>generic_data</type></module>";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//$data_out = ($data="false" ? "1" : "0");
|
|
||||||
//$data_out = ($data="off" ? "1" : "0");
|
|
||||||
|
|
||||||
unset($status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//End of Sensor
|
//End of Sensor
|
||||||
|
Loading…
x
Reference in New Issue
Block a user