pandora_user.conf disappeared out of the Linux client but I find it quite useful. The Mac version reads out all types of sensory information (PowerMac, Intel's don't have it available)
Also: Added a tool for reading out IPMI-compatible chips. Requires php and ipmitool. Tested against Apple XServe's only. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@928 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
25591a3a35
commit
f0eeaa688c
|
@ -0,0 +1,81 @@
|
|||
# Pandora User-Defined adquisition script
|
||||
# This code is under GPL licence
|
||||
# This is the default user script file
|
||||
# If you're using this is because default config doest fit all your needs
|
||||
# You can use the following variables
|
||||
#
|
||||
# All STDOUT output will be written in final XML file sent to Pandora Server.
|
||||
#
|
||||
# Please refer documentatation for more example and a more depth usage instructions
|
||||
#
|
||||
|
||||
# ================================
|
||||
# Temperature monitoring Mac OS X
|
||||
# ===============================
|
||||
|
||||
echo `ioreg -n IOHWSensor | awk '/location/ || /current-value/ || /"type"/' | sed -e 's/\n//' -e 's/[^"]*"//' -e 's/" =//' -e 's/"//g' | awk '{ d=($2/65536); if ($1=="current-value") print "<module><data>" substr(d,1,7) "</data>"; if ($1=="location") print "<name>" $2 " " $3 " " $4 " " $5 "</name><type>generic_data</type></module>";}'`
|
||||
|
||||
# ================================
|
||||
# Check for WEBPage content change
|
||||
# ================================
|
||||
|
||||
#MYMD5=`echo -e "GET / HTTP/1.0\n\n\n" | nc -w 30 www.artica.es 80 | grep -v "Date:" | md5sum | awk '{ print $1 }'`
|
||||
#VALIDMD5=e85c0b9018a22c1086c8e0179cd224b1
|
||||
#if [ "$MYMD5" != "$VALIDMD5" ]
|
||||
#then
|
||||
# MD5SUM=0
|
||||
#else
|
||||
# MD5SUM=1
|
||||
#fi
|
||||
#echo "<module>"
|
||||
#echo "<name>www.artica.es_WEBContenct</name>"
|
||||
#echo "<type>generic_proc</type>"
|
||||
#echo "<data>$MD5SUM</data>"
|
||||
#echo "</module>"
|
||||
|
||||
# MODULE END ========================
|
||||
|
||||
# ================================
|
||||
# Check for DNS Entry change
|
||||
# ================================
|
||||
|
||||
#HOSTNAME=arcadia.genterara.com
|
||||
#MAXHOPS=1
|
||||
#MAXHOPS2=`expr $MAXHOPS + 1`
|
||||
#SALIDA=`traceroute -n $HOSTNAME -w 5 -m $MAXHOPS2 2> /dev/null | awk '{ print $1 }' | tail -1`
|
||||
# if SALIDA != MAXHOPS, error (more than MAXHOPS hop, if this is our local IP, no more than MAXHOPS hop its needed
|
||||
#if [ "$SALIDA" == "$MAXHOPS" ]
|
||||
#then
|
||||
# DNS_STATUS=1
|
||||
#else
|
||||
# DNS_STATUS=0
|
||||
#fi
|
||||
#echo "<module>"
|
||||
#echo "<name>DNS_CHECK</name>"
|
||||
#echo "<type>generic_proc</type>"
|
||||
#echo "<data>$DNS_STATUS</data>"
|
||||
#echo "</module>"
|
||||
|
||||
# MODULE END ========================
|
||||
|
||||
|
||||
# ================================
|
||||
# Check for DNS Entry change
|
||||
# on local interface ppp0
|
||||
# ================================
|
||||
|
||||
# PLC_DNS=`dig @194.179.1.101 plc.genterara.com A +short | tail -1 `
|
||||
# PLC_LOCAL=`ifconfig ppp0 | head -2 | tail -1 | tr -s ":" " " | awk ' { print $3 } '`
|
||||
# if [ "$PLC_DNS" == "$PLC_LOCAL" ]
|
||||
# then
|
||||
# PLC_STATUS=1
|
||||
# else
|
||||
# PLC_STATUS=0
|
||||
# fi
|
||||
#
|
||||
# echo "<module>"
|
||||
# echo "<name>PLC_DNS_CHECK</name>"
|
||||
# echo "<type>generic_proc</type>"
|
||||
# echo "<data>$PLC_STATUS</data>"
|
||||
# echo "</module>"
|
||||
# MODULE END ========================
|
|
@ -0,0 +1,8 @@
|
|||
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.
|
||||
|
||||
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.
|
||||
|
||||
ipmitool and php (tested 5, 4 should work too) is required on the machine the agent is running on.
|
|
@ -0,0 +1,147 @@
|
|||
#!/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
|
||||
|
||||
?>
|
Loading…
Reference in New Issue