automatically load all temperature include files, moved almost all of them over to internal snmp functions, PLEASE TEST

git-svn-id: http://www.observium.org/svn/observer/trunk@1325 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2010-07-09 22:38:46 +00:00
parent 70de9b5694
commit 5c97185974
16 changed files with 246 additions and 219 deletions
+3 -3
View File
@@ -4,9 +4,9 @@
if($device['os'] == "junos")
{
echo("JUNOS : ");
$processors_array = snmpwalk_cache_multi_oid($device, "jnxOperatingCPU", $processors_array, "JUNIPER-MIB" , "+".$config['install_dir']."/mibs/junos");
$processors_array = snmpwalk_cache_multi_oid($device, "jnxOperatingDRAMSize", $processors_array, "JUNIPER-MIB" , "+".$config['install_dir']."/mibs/junos");
$processors_array = snmpwalk_cache_multi_oid($device, "jnxOperatingDescr", $processors_array, "JUNIPER-MIB" , "+".$config['install_dir']."/mibs/junos");
$processors_array = snmpwalk_cache_multi_oid($device, "jnxOperatingCPU", $processors_array, "JUNIPER-MIB" , '+'.$config['install_dir']."/mibs/junos");
$processors_array = snmpwalk_cache_multi_oid($device, "jnxOperatingDRAMSize", $processors_array, "JUNIPER-MIB" , '+'.$config['install_dir']."/mibs/junos");
$processors_array = snmpwalk_cache_multi_oid($device, "jnxOperatingDescr", $processors_array, "JUNIPER-MIB" , '+'.$config['install_dir']."/mibs/junos");
if($debug) { print_r($processors_array); }
if(is_array($processors_array[$device['device_id']])) {
+1 -13
View File
@@ -9,19 +9,7 @@ echo("Temperatures : ");
$valid_temp = array();
#include("temperatures/adva.inc.php"); ## Disabled needing rewrite
include("temperatures/akcp.inc.php");
include("temperatures/areca.inc.php");
include("temperatures/cisco-envmon.inc.php");
include("temperatures/dell.inc.php");
include("temperatures/ironware.inc.php");
include("temperatures/junose.inc.php");
include("temperatures/junos.inc.php");
include("temperatures/lm-sensors.inc.php");
include("temperatures/netmanplus.inc.php");
include("temperatures/observer-custom.inc.php");
include("temperatures/papouch-tme.inc.php");
include("temperatures/supermicro.inc.php");
include_dir("includes/discovery/temperatures");
if($debug) { print_r($valid_temp); }
@@ -1,4 +1,7 @@
<?php
/*
Disabled needing rewrite
$id = $device['device_id'];
$hostname = $device['hostname'];
$community = $device['community'];
@@ -81,4 +84,5 @@
}
$temp_exists[] = "$id $oid_hss2";
}
*/
?>
+28 -27
View File
@@ -1,40 +1,41 @@
<?php
global $valid_temp;
if($device['os'] == "akcp" || $device['os'] == "minkelsrms")
if ($device['os'] == "akcp" || $device['os'] == "minkelsrms")
{
$oids = snmp_walk($device, ".1.3.6.1.4.1.3854.1.2.2.1.16.1.4", "-Osqn", "");
if ($debug) { echo($oids."\n"); }
$oids = trim($oids);
if ($oids) echo("AKCP ");
foreach(explode("\n", $oids) as $data)
$oids = snmp_walk($device, ".1.3.6.1.4.1.3854.1.2.2.1.16.1.4", "-Osqn", "");
if ($debug) { echo($oids."\n"); }
$oids = trim($oids);
if ($oids) echo("AKCP ");
foreach(explode("\n", $oids) as $data)
{
$data = trim($data);
if ($data)
{
$data = trim($data);
if ($data)
list($oid,$status) = explode(" ", $data,2);
if ($status == 2) # 2 = normal, 0 = not connected
{
list($oid,$status) = explode(" ", $data,2);
if ($status == 2) # 2 = normal, 0 = not connected
{
$split_oid = explode('.',$oid);
$temp_id = $split_oid[count($split_oid)-1];
$descr_oid = ".1.3.6.1.4.1.3854.1.2.2.1.16.1.1.$temp_id";
$temp_oid = ".1.3.6.1.4.1.3854.1.2.2.1.16.1.3.$temp_id";
$warnlimit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.16.1.7.$temp_id";
$limit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.16.1.8.$temp_id";
# .9 = low warn limit
$lowlimit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.16.1.10.$temp_id";
$split_oid = explode('.',$oid);
$temp_id = $split_oid[count($split_oid)-1];
$descr_oid = ".1.3.6.1.4.1.3854.1.2.2.1.16.1.1.$temp_id";
$temp_oid = ".1.3.6.1.4.1.3854.1.2.2.1.16.1.3.$temp_id";
$warnlimit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.16.1.7.$temp_id";
$limit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.16.1.8.$temp_id";
# .9 = low warn limit
$lowlimit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.16.1.10.$temp_id";
$descr = trim(snmp_get($device, $descr_oid, "-Oqv", ""),'"');
$temp = snmp_get($device, $temp_oid, "-Oqv", "");
$warnlimit = snmp_get($device, $warnlimit_oid, "-Oqv", "");
$limit = snmp_get($device, $limit_oid, "-Oqv", "");
$lowlimit = snmp_get($device, $lowlimit_oid, "-Oqv", "");
$descr = trim(snmp_get($device, $descr_oid, "-Oqv", ""),'"');
$temp = snmp_get($device, $temp_oid, "-Oqv", "");
$warnlimit = snmp_get($device, $warnlimit_oid, "-Oqv", "");
$limit = snmp_get($device, $limit_oid, "-Oqv", "");
$lowlimit = snmp_get($device, $lowlimit_oid, "-Oqv", "");
# FIXME no warnlimit in table/discover function yet...
discover_temperature($valid_temp, $device, $temp_oid, $temp_id, "akcp", $descr, 1, $lowlimit, $limit, $temp);
}
# FIXME no warnlimit in table/discover function yet...
discover_temperature($valid_temp, $device, $temp_oid, $temp_id, "akcp", $descr, 1, $lowlimit, $limit, $temp);
}
}
}
}
?>
+40 -37
View File
@@ -1,46 +1,49 @@
<?php
if($device['os'] == "areca") {
$oids = shell_exec($config['snmpwalk'] . " -M " . $config['mibdir'] . " -$snmpver -CI -Osqn -c $community $hostname:$port SNMPv2-SMI::enterprises.18928.1.1.2.14.1.2");
if ($debug) { echo($oids."\n"); }
$oids = trim($oids);
if ($oids) echo("Areca Harddisk ");
foreach(explode("\n", $oids) as $data)
global $valid_temp;
if ($device['os'] == "areca")
{
$oids = snmp_walk($device, "1.3.6.1.4.1.18928.1.1.2.14.1.2", "-Osqn", "");
if ($debug) { echo($oids."\n"); }
$oids = trim($oids);
if ($oids) echo("Areca Harddisk ");
foreach(explode("\n", $oids) as $data)
{
$data = trim($data);
if ($data)
{
$data = trim($data);
if ($data)
list($oid,$descr) = explode(" ", $data,2);
$split_oid = explode('.',$oid);
$temp_id = $split_oid[count($split_oid)-1];
$temp_oid = "1.3.6.1.4.1.18928.1.1.2.14.1.2.$temp_id";
$temp = snmp_get($device, $temp_oid, "-Oqv", "");
$descr = "Hard disk $temp_id";
if ($temp != -128) # -128 = not measured/present
{
list($oid,$descr) = explode(" ", $data,2);
$split_oid = explode('.',$oid);
$temp_id = $split_oid[count($split_oid)-1];
$temp_oid = "1.3.6.1.4.1.18928.1.1.2.14.1.2.$temp_id";
$temp = trim(shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -O qv -$snmpver -c $community $hostname:$port $temp_oid"));
$descr = "Hard disk $temp_id";
if ($temp != -128) # -128 = not measured/present
{
discover_temperature($valid_temp, $device, $temp_oid, zeropad($temp_id), "areca", $descr, 1, NULL, NULL, $temp);
}
}
}
$oids = snmp_walk($device, "1.3.6.1.4.1.18928.1.2.2.1.10.1.2", "-OsqnU", "");
if ($debug) { echo($oids."\n"); }
if ($oids) echo("Areca Controller ");
$precision = 1;
$type = "areca";
foreach(explode("\n", $oids) as $data)
{
$data = trim($data);
if ($data)
{
list($oid,$descr) = explode(" ", $data,2);
$split_oid = explode('.',$oid);
$index = $split_oid[count($split_oid)-1];
$oid = "1.3.6.1.4.1.18928.1.2.2.1.10.1.3." . $index;
$current = snmp_get($device, $oid, "-Oqv", "");
discover_temperature($valid_temp, $device, $oid, $index, $type, trim($descr,'"'), $precision, NULL, NULL, $current);
discover_temperature($valid_temp, $device, $temp_oid, zeropad($temp_id), "areca", $descr, 1, NULL, NULL, $temp);
}
}
}
$oids = snmp_walk($device, "1.3.6.1.4.1.18928.1.2.2.1.10.1.2", "-OsqnU", "");
if ($debug) { echo($oids."\n"); }
if ($oids) echo("Areca Controller ");
$precision = 1;
$type = "areca";
foreach(explode("\n", $oids) as $data)
{
$data = trim($data);
if ($data)
{
list($oid,$descr) = explode(" ", $data,2);
$split_oid = explode('.',$oid);
$index = $split_oid[count($split_oid)-1];
$oid = "1.3.6.1.4.1.18928.1.2.2.1.10.1.3." . $index;
$current = snmp_get($device, $oid, "-Oqv", "");
discover_temperature($valid_temp, $device, $oid, $index, $type, trim($descr,'"'), $precision, NULL, NULL, $current);
}
}
}
?>
@@ -1,33 +1,33 @@
<?php
if($device['os'] == "ios" || $device['os_group'] == "ios")
global $valid_temp;
if ($device['os'] == "ios" || $device['os_group'] == "ios")
{
echo("Cisco ");
$oids = shell_exec($config['snmpwalk'] . " -M " . $config['mibdir'] . " -m CISCO-ENVMON-MIB -$snmpver -CI -Osqn -c $community $hostname:$port .1.3.6.1.4.1.9.9.13.1.3.1.2 | sed s/.1.3.6.1.4.1.9.9.13.1.3.1.2.//g");
$oids = trim($oids);
foreach(explode("\n", $oids) as $data)
echo("Cisco ");
$oids = snmp_walk($device, ".1.3.6.1.4.1.9.9.13.1.3.1.2", "-Osqn", "CISCO-ENVMON-MIB");
$oids = str_replace('.1.3.6.1.4.1.9.9.13.1.3.1.2.','',$oids);
$oids = trim($oids);
foreach(explode("\n", $oids) as $data)
{
$data = trim($data);
if ($data)
{
$data = trim($data);
if ($data)
list($index) = explode(" ", $data);
$oid = ".1.3.6.1.4.1.9.9.13.1.3.1.3.$index";
$descr_oid = ".1.3.6.1.4.1.9.9.13.1.3.1.2.$index";
$descr = snmp_get($device, $descr_oid, "-Oqv", "CISCO-ENVMON-MIB");
$temp = snmp_get($device, $oid, "-Oqv", "CISCO-ENVMON-MIB");
if (!strstr($descr, "No") && !strstr($temp, "No") && $descr != "" )
{
list($index) = explode(" ", $data);
$oid = ".1.3.6.1.4.1.9.9.13.1.3.1.3.$index";
$descr_oid = ".1.3.6.1.4.1.9.9.13.1.3.1.2.$index";
$descr = snmp_get($device, $descr_oid, "-Oqv", "CISCO-ENVMON-MIB");
$temp = snmp_get($device, $oid, "-Oqv", "CISCO-ENVMON-MIB");
if (!strstr($descr, "No") && !strstr($temp, "No") && $descr != "" )
{
$descr = str_replace("\"", "", $descr);
$descr = str_replace("temperature", "", $descr);
$descr = str_replace("temp", "", $descr);
$descr = trim($descr);
discover_temperature($valid_temp, $device, $oid, $index, "cisco", $descr, "1", NULL, NULL, $temp);
}
$descr = str_replace("\"", "", $descr);
$descr = str_replace("temperature", "", $descr);
$descr = str_replace("temp", "", $descr);
$descr = trim($descr);
discover_temperature($valid_temp, $device, $oid, $index, "cisco", $descr, "1", NULL, NULL, $temp);
}
}
}
}
?>
+4 -2
View File
@@ -1,8 +1,10 @@
<?php
global $valid_temp;
if (strstr($device['hardware'], "dell"))
{
$oids = shell_exec($config['snmpwalk'] . " -M " . $config['mibdir'] . " -m MIB-Dell-10892 -$snmpver -CI -Osqn -c $community $hostname:$port .1.3.6.1.4.1.674.10892.1.700.20.1.8");
$oids = snmp_walk($device, ".1.3.6.1.4.1.674.10892.1.700.20.1.8", "-Osqn", "MIB-Dell-10892");
$oids = trim($oids);
if ($oids) echo("Dell OMSA ");
foreach(explode("\n",$oids) as $oid)
@@ -11,7 +13,7 @@ if (strstr($device['hardware'], "dell"))
list($oid) = explode(" ", $oid);
if ($oid != "")
{
$descr_query = $config['snmpget'] . " -M " . $config['mibdir'] . " -m MIB-Dell-10892 -$snmpver -Onvq -c $community $hostname:$port .1.3.6.1.4.1.674.10892.1.700.20.1.8.$oid";
$descr_query = snmp_get($device, ".1.3.6.1.4.1.674.10892.1.700.20.1.8.$oid", "-Onvq", "MIB-Dell-10892");
$descr = trim(str_replace("\"", "", shell_exec($descr_query)));
$fulloid = ".1.3.6.1.4.1.674.10892.1.700.20.1.6.$oid";
discover_temperature($valid_temp, $device, $fulloid, $oid, "dell", $descr, "10", NULL, NULL, NULL);
@@ -1,35 +1,38 @@
<?php
if($device['os'] == "ironware") {
echo("IronWare ");
$oids = shell_exec($config['snmpwalk'] . " -M " . $config['mibdir'] . " -$snmpver -CI -Osqn -m FOUNDRY-SN-AGENT-MIB:FOUNDRY-SN-ROOT-MIB -c $community $hostname:$port snAgentTempSensorDescr");
$oids = trim($oids);
$oids = str_replace(".1.3.6.1.4.1.1991.1.1.2.13.1.1.3.", "", $oids);
foreach(explode("\n", $oids) as $data)
global $valid_temp;
if($device['os'] == "ironware")
{
echo("IronWare ");
$oids = snmp_walk($device,"snAgentTempSensorDescr","-Osqn","FOUNDRY-SN-AGENT-MIB:FOUNDRY-SN-ROOT-MIB");
$oids = trim($oids);
$oids = str_replace(".1.3.6.1.4.1.1991.1.1.2.13.1.1.3.", "", $oids);
foreach(explode("\n", $oids) as $data)
{
$data = trim($data);
if ($data != "")
{
$data = trim($data);
if ($data != "")
list($oid) = explode(" ", $data);
$temp_oid = ".1.3.6.1.4.1.1991.1.1.2.13.1.1.4.$oid";
$descr_oid = ".1.3.6.1.4.1.1991.1.1.2.13.1.1.3.$oid";
$descr = snmp_get($device,$descr_oid,"-Oqv","");
$temp = snmp_get($device,$temp_oid,"-Oqv","");
if (!strstr($descr, "No") && !strstr($temp, "No") && $descr != "" && $temp != "0")
{
list($oid) = explode(" ", $data);
$temp_oid = ".1.3.6.1.4.1.1991.1.1.2.13.1.1.4.$oid";
$descr_oid = ".1.3.6.1.4.1.1991.1.1.2.13.1.1.3.$oid";
$descr = trim(shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -O qv -$snmpver -c $community $hostname:$port $descr_oid"));
$temp = trim(shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -O qv -$snmpver -c $community $hostname:$port $temp_oid"));
if (!strstr($descr, "No") && !strstr($temp, "No") && $descr != "" && $temp != "0")
{
$descr = str_replace("\"", "", $descr);
$descr = str_replace("temperature", "", $descr);
$descr = str_replace("temp", "", $descr);
$descr = str_replace("sensor", "Sensor", $descr);
$descr = str_replace("Line module", "Slot", $descr);
$descr = str_replace("Switch Fabric module", "Fabric", $descr);
$descr = str_replace("Active management module", "Mgmt Module", $descr);
$descr = str_replace(" ", " ", $descr);
$descr = trim($descr);
discover_temperature($valid_temp, $device, $temp_oid, $oid, "ironware", $descr, "2", NULL, NULL, $temp);
}
$descr = str_replace("\"", "", $descr);
$descr = str_replace("temperature", "", $descr);
$descr = str_replace("temp", "", $descr);
$descr = str_replace("sensor", "Sensor", $descr);
$descr = str_replace("Line module", "Slot", $descr);
$descr = str_replace("Switch Fabric module", "Fabric", $descr);
$descr = str_replace("Active management module", "Mgmt Module", $descr);
$descr = str_replace(" ", " ", $descr);
$descr = trim($descr);
discover_temperature($valid_temp, $device, $temp_oid, $oid, "ironware", $descr, "2", NULL, NULL, $temp);
}
}
}
}
?>
@@ -1,9 +1,11 @@
<?php
global $valid_temp;
if ($device['os'] == "junos" || $device['os_group'] == "junos")
{
echo("JunOS ");
$oids = shell_exec($config['snmpwalk'] . " -M " . $config['mibdir'] . " -M +".$config['install_dir']."/mibs/junos -m JUNIPER-MIB -$snmpver -CI -Osqn -c $community $hostname:$port 1.3.6.1.4.1.2636.3.1.13.1.7");
$oids = snmp_walk($device,"1.3.6.1.4.1.2636.3.1.13.1.7","-Osqn","JUNIPER-MIB", '+'.$config['install_dir']."/mibs/junos");
$oids = trim($oids);
foreach(explode("\n", $oids) as $data)
{
@@ -14,8 +16,8 @@ if ($device['os'] == "junos" || $device['os_group'] == "junos")
list($oid) = explode(" ", $data);
$temp_oid = "1.3.6.1.4.1.2636.3.1.13.1.7.$oid";
$descr_oid = "1.3.6.1.4.1.2636.3.1.13.1.5.$oid";
$descr = trim(shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -M +".$config['install_dir']."/mibs/junos -m JUNIPER-MIB -O qv -$snmpver -c $community $hostname:$port $descr_oid"));
$temp = trim(shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -M +".$config['install_dir']."/mibs/junos -m JUNIPER-MIB -O qv -$snmpver -c$community $hostname:$port $temp_oid"));
$descr = snmp_get($device,$descr_oid,"-Oqv","JUNIPER-MIB", '+'.$config['install_dir']."/mibs/junos");
$temp = snmp_get($device,$temp_oid,"-Oqv","JUNIPER-MIB", '+'.$config['install_dir']."/mibs/junos");
if (!strstr($descr, "No") && !strstr($temp, "No") && $descr != "" && $temp != "0")
{
$descr = str_replace("\"", "", $descr);
@@ -25,11 +27,9 @@ if ($device['os'] == "junos" || $device['os_group'] == "junos")
$descr = trim($descr);
discover_temperature($valid_temp, $device, $temp_oid, $oid, "junos", $descr, "1", NULL, NULL, $temp);
}
}
}
}
?>
@@ -1,14 +1,19 @@
<?php
global $valid_temp;
## JunOSe Temperatures
if ($device['os'] == "junose")
{
echo("JunOSe: ");
$oids = snmpwalk_cache_multi_oid($device, "juniSystemTempValue", array(), "Juniper-System-MIB", "+".$config['install_dir']."/mibs/junose");
if(is_array($oids[$device['device_id']])) {
foreach($oids[$device[device_id]] as $index => $entry) {
if(is_numeric($entry['juniSystemTempValue']) && is_numeric($index) && $entry['juniSystemTempValue'] > "0") {
if(is_array($oids[$device['device_id']]))
{
foreach($oids[$device[device_id]] as $index => $entry)
{
if(is_numeric($entry['juniSystemTempValue']) && is_numeric($index) && $entry['juniSystemTempValue'] > "0")
{
$entPhysicalIndex = snmp_get($device, "juniSystemTempPhysicalIndex.".$index, "-Oqv", "Juniper-System-MIB", "+".$config['install_dir']."/mibs/junose");
$descr = snmp_get($device, "entPhysicalDescr.".$entPhysicalIndex, "-Oqv", "ENTITY-MIB");
$descr = preg_replace("/^Juniper\ [0-9a-zA-Z\-]+/", "", $descr); ## Wipe out ugly Juniper crap. Why put vendor and model in here? Idiots!
@@ -1,9 +1,10 @@
<?php
if($device['os'] == "linux")
global $valid_temp;
if ($device['os'] == "linux")
{
## FIX ME SNMP_WALK
$oids = shell_exec($config['snmpwalk'] . " -M " . $config['mibdir'] . " -m LM-SENSORS-MIB -$snmpver -CI -Osqn -c $community $hostname:$port lmTempSensorsDevice");
$oids = snmp_walk($device, "lmTempSensorsDevice", "-Osqn", "LM-SENSORS-MIB");
if ($debug) { echo($oids."\n"); }
$oids = trim($oids);
if ($oids) echo("LM-SENSORS ");
@@ -25,8 +26,6 @@ if($device['os'] == "linux")
}
}
}
}
?>
@@ -1,26 +1,27 @@
<?php
global $valid_temp;
if($device['os'] == "netmanplus")
{
$oids = snmp_walk($device, "1.3.6.1.2.1.33.1.2.7", "-Osqn", "UPS-MIB");
if ($debug) { echo($oids."\n"); }
$oids = trim($oids);
if ($oids) echo("NetMan Plus Battery Temperature ");
foreach(explode("\n", $oids) as $data)
$oids = snmp_walk($device, "1.3.6.1.2.1.33.1.2.7", "-Osqn", "UPS-MIB");
if ($debug) { echo($oids."\n"); }
$oids = trim($oids);
if ($oids) echo("NetMan Plus Battery Temperature ");
foreach(explode("\n", $oids) as $data)
{
$data = trim($data);
if ($data)
{
$data = trim($data);
if ($data)
{
list($oid,$descr) = explode(" ", $data,2);
$split_oid = explode('.',$oid);
$temp_id = $split_oid[count($split_oid)-1];
$temp_oid = "1.3.6.1.2.1.33.1.2.7.$temp_id";
$temp = snmp_get($device, $temp_oid, "-Ovq");
$descr = "Battery" . (count(explode("\n",$oids)) == 1 ? '' : ' ' . ($temp_id+1));
discover_temperature($valid_temp, $device, $temp_oid, $temp_id, "netmanplus", $descr, 1, NULL, NULL, $temp);
}
list($oid,$descr) = explode(" ", $data,2);
$split_oid = explode('.',$oid);
$temp_id = $split_oid[count($split_oid)-1];
$temp_oid = "1.3.6.1.2.1.33.1.2.7.$temp_id";
$temp = snmp_get($device, $temp_oid, "-Ovq");
$descr = "Battery" . (count(explode("\n",$oids)) == 1 ? '' : ' ' . ($temp_id+1));
discover_temperature($valid_temp, $device, $temp_oid, $temp_id, "netmanplus", $descr, 1, NULL, NULL, $temp);
}
}
}
?>
@@ -1,22 +1,26 @@
<?php
if($device['os_group'] == "unix") {
# Observer-style temperature
$oids = shell_exec($config['snmpwalk'] . " -M " . $config['mibdir'] . " -M " . $config['mibdir'] . " -$snmpver -m SNMPv2-SMI -Osqn -CI -c $community $hostname:$port .1.3.6.1.4.1.2021.7891 | sed s/.1.3.6.1.4.1.2021.7891.// | grep '.1.1 ' | grep -v '.101.' | cut -d'.' -f 1");
$oids = trim($oids);
if ($oids) echo("Observer-Style ");
foreach(explode("\n",$oids) as $oid)
global $valid_temp;
if($device['os_group'] == "unix")
{
# FIXME snmp_walk
# Observer-style temperature
$oids = shell_exec($config['snmpwalk'] . " -M " . $config['mibdir'] . " -M " . $config['mibdir'] . " -".$device['snmpver']." -m SNMPv2-SMI -Osqn -CI -c ".$device['community']." ".$device['hostname'].":".$device['port']." .1.3.6.1.4.1.2021.7891 | sed s/.1.3.6.1.4.1.2021.7891.// | grep '.1.1 ' | grep -v '.101.' | cut -d'.' -f 1");
$oids = trim($oids);
if ($oids) echo("Observer-Style ");
foreach(explode("\n",$oids) as $oid)
{
$oid = trim($oid);
if ($oid != "")
{
$oid = trim($oid);
if ($oid != "")
{
$descr_query = $config['snmpget'] . " -M " . $config['mibdir'] . " -$snmpver -m SNMPv2-SMI -Osqn -c $community $hostname:$port .1.3.6.1.4.1.2021.7891.$oid.2.1 | sed s/.1.3.6.1.4.1.2021.7891.$oid.2.1\ //";
$descr = trim(str_replace("\"", "", shell_exec($descr_query)));
$fulloid = ".1.3.6.1.4.1.2021.7891.$oid.101.1";
discover_temperature($valid_temp, $device, $fulloid, $oid, "observer", $descr, "1", NULL, NULL, NULL);
}
# FIXME snmp_get
$descr_query = $config['snmpget'] . " -M " . $config['mibdir'] . " -".$device['snmpver']." -m SNMPv2-SMI -Osqn -c ".$device['community']." ".$device['hostname'].":".$device['port']." .1.3.6.1.4.1.2021.7891.$oid.2.1 | sed s/.1.3.6.1.4.1.2021.7891.$oid.2.1\ //";
$descr = trim(str_replace("\"", "", shell_exec($descr_query)));
$fulloid = ".1.3.6.1.4.1.2021.7891.$oid.101.1";
discover_temperature($valid_temp, $device, $fulloid, $oid, "observer", $descr, "1", NULL, NULL, NULL);
}
}
}
?>
@@ -1,21 +1,20 @@
<?php
if($device['os'] == "papouch-tme") {
global $valid_temp;
if ($device['os'] == "papouch-tme")
{
echo("Papouch TME ");
echo("Papouch TME ");
#$descr = trim(shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -O qv -$snmpver -c $community $hostname:$port SNMPv2-SMI::enterprises.18248.1.1.3.0"));
#$temp = trim(shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -O qv -$snmpver -c $community $hostname:$port SNMPv2-SMI::enterprises.18248.1.1.1.0")) / 10;
$descr = snmp_get($device, "SNMPv2-SMI::enterprises.18248.1.1.3.0", "-Oqv");
$temp = snmp_get($device, "SNMPv2-SMI::enterprises.18248.1.1.1.0", "-Oqv") / 10;
if (!strstr($descr, "No") && !strstr($temp, "No") && $descr != "" && $temp != "0")
{
$temp_oid = ".1.3.6.1.4.1.18248.1.1.1.0";
$descr = trim(str_replace("\"", "", $descr));
discover_temperature($valid_temp, $device, $temp_oid, "1", "ironware", $descr, "10", NULL, NULL, $temp);
}
$descr = snmp_get($device, "SNMPv2-SMI::enterprises.18248.1.1.3.0", "-Oqv");
$temp = snmp_get($device, "SNMPv2-SMI::enterprises.18248.1.1.1.0", "-Oqv") / 10;
if ($descr != "" && $temp != "0")
{
$temp_oid = ".1.3.6.1.4.1.18248.1.1.1.0";
$descr = trim(str_replace("\"", "", $descr));
discover_temperature($valid_temp, $device, $temp_oid, "1", "ironware", $descr, "10", NULL, NULL, $temp);
}
}
?>
@@ -1,42 +1,41 @@
<?php
global $valid_temp;
if($device['os'] == "linux")
{
# Supermicro sensors
## FIX ME snmp_walk snmp_get needed
## Fix this shit if you can test it.
$oids = snmp_walk($device, "1.3.6.1.4.1.10876.2.1.1.1.1.3", "-Osqn", "SUPERMICRO-HEALTH-MIB");
$oids = shell_exec($config['snmpwalk'] . " -M " . $config['mibdir'] . " -m SUPERMICRO-HEALTH-MIB -$snmpver -CI -Osqn -c $community $hostname:$port 1.3.6.1.4.1.10876.2.1.1.1.1.3 | sed s/1.3.6.1.4.1.10876.2.1.1.1.1.3.//g");
$oids = trim($oids);
if ($oids) echo("Supermicro ");
foreach(explode("\n", $oids) as $data)
# Supermicro sensors
$oids = snmp_walk($device, "1.3.6.1.4.1.10876.2.1.1.1.1.3", "-Osqn", "SUPERMICRO-HEALTH-MIB");
$oids = trim($oids);
if ($oids) echo("Supermicro ");
foreach(explode("\n", $oids) as $data)
{
$data = trim($data);
if ($data)
{
$data = trim($data);
if ($data)
list($oid,$type) = explode(" ", $data);
$oid_ex = explode('.',$oid);
$index = $oid_ex[count($oid_ex)-1];
if ($type == 2)
{
list($oid,$type) = explode(" ", $data);
if ($type == 2)
$temp_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.4.$index";
$descr_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.2.$index";
$limit_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.5.$index";
$divisor_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.9.$index";
$monitor_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.10.$index";
$descr = snmp_get($device, $descr_oid, "-Oqv", "SUPERMICRO-HEALTH-MIB");
$temp = snmp_get($device, $temp_oid, "-Oqv", "SUPERMICRO-HEALTH-MIB");
$limit = snmp_get($device, $limit_oid, "-Oqv", "SUPERMICRO-HEALTH-MIB");
$divisor = snmp_get($device, $divisor_oid, "-Oqv", "SUPERMICRO-HEALTH-MIB") || 1;
$monitor = snmp_get($device, $monitor_oid, "-Oqv", "SUPERMICRO-HEALTH-MIB");
if ($monitor == 'true')
{
$temp_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.4$oid";
$descr_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.2$oid";
$limit_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.5$oid";
$divisor_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.9$oid";
$monitor_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.10$oid";
$descr = trim(shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -m SUPERMICRO-HEALTH-MIB -O qv -$snmpver -c $community $hostname:$port $descr_oid"));
$temp = trim(shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -m SUPERMICRO-HEALTH-MIB -O qv -$snmpver -c $community $hostname:$port $temp_oid"));
$limit = trim(shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -m SUPERMICRO-HEALTH-MIB -O qv -$snmpver -c $community $hostname:$port $limit_oid"));
$divisor = trim(shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -m SUPERMICRO-HEALTH-MIB -O qv -$snmpver -c $community $hostname:$port $divisor_oid"));
$monitor = trim(shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -m SUPERMICRO-HEALTH-MIB -O qv -$snmpver -c $community $hostname:$port $monitor_oid"));
if ($monitor == 'true')
{
$descr = trim(str_ireplace("temperature", "", $descr));
discover_temperature($valid_temp, $device, $temp_oid, trim($oid,'.'), "supermicro", $descr, $divisor, $limit, NULL, $temp);
}
$descr = trim(str_ireplace("temperature", "", $descr));
discover_temperature($valid_temp, $device, $temp_oid, trim($index,'.'), "supermicro", $descr, $divisor, $limit, NULL, $temp);
}
}
}
}
}
?>
+19
View File
@@ -678,4 +678,23 @@ function isHexString($str)
return preg_match("/^[a-f0-9][a-f0-9]( [a-f0-9][a-f0-9])*$/is",trim($str));
}
# Include all .inc.php files in $dir
function include_dir($dir)
{
global $device, $config;
if ($handle = opendir($dir))
{
while (false !== ($file = readdir($handle)))
{
if (filetype($dir . '/' . $file) == 'file' && substr($file,strlen($file)-8) == '.inc.php')
{
include($dir . '/' . $file);
}
}
closedir($handle);
}
}
?>