mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge pull request #971 from laf/issue-963
Added Temperature sensor support for NetApp
This commit is contained in:
@@ -135,7 +135,7 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr,
|
||||
|
||||
if ($debug) { echo("Discover sensor: $oid, $index, $type, $descr, $poller_type, $precision, $entPhysicalIndex\n"); }
|
||||
|
||||
if (is_null($low_warn_limit) || !is_null($warn_limit))
|
||||
if (is_null($low_warn_limit) && !is_null($warn_limit))
|
||||
{
|
||||
// Warn limits only make sense when we have both a high and a low limit
|
||||
$low_warn_limit = NULL;
|
||||
|
||||
36
includes/discovery/temperatures/netapp.inc.php
Normal file
36
includes/discovery/temperatures/netapp.inc.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
if ($device['os'] == "netapp") {
|
||||
$main_oid = ".1.3.6.1.4.1.789.1.21.1.2.1";
|
||||
$oids = snmp_walk($device, $main_oid.'.25', "-Osqn");
|
||||
if ($debug) {
|
||||
echo $oids."\n";
|
||||
}
|
||||
$oids = trim($oids);
|
||||
if ($oids) {
|
||||
echo "NetApp ";
|
||||
foreach (explode("\n", $oids) as $data) {
|
||||
list($oid,$descr) = explode(" ", $data,2);
|
||||
$split_oid = explode('.', $oid);
|
||||
$temperature_id = $split_oid[count($split_oid)-1];
|
||||
$x=1;
|
||||
preg_match_all("/([0-9]+C)+/", $descr, $temps);
|
||||
preg_match_all("/([0-9]+C)+/", snmp_get($device, $main_oid.'.26.'.$temperature_id, "-Ovq"), $over_fail);
|
||||
preg_match_all("/([0-9]+C)+/", snmp_get($device, $main_oid.'.27.'.$temperature_id, "-Ovq"), $over_warn);
|
||||
preg_match_all("/([0-9]+C)+/", snmp_get($device, $main_oid.'.28.'.$temperature_id, "-Ovq"), $under_fail);
|
||||
preg_match_all("/([0-9]+C)+/", snmp_get($device, $main_oid.'.29.'.$temperature_id, "-Ovq"), $under_warn);
|
||||
$x = 0;
|
||||
foreach ($temps[0] as $temperature) {
|
||||
$low_limit = str_replace("C","",$under_fail[0][$x]);
|
||||
$low_warn_limit = str_replace("C","",$under_warn[0][$x]);
|
||||
$warn_limit = str_replace("C","",$over_warn[0][$x]);
|
||||
$high_limit = str_replace("C","",$over_fail[0][$x]);
|
||||
$temperature_oid = $main_oid . ".25." . $temperature_id;
|
||||
$temp_id = $temperature_id . "." . $x;
|
||||
$descr = "Temp Sensor";
|
||||
$x++;
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, $temp_id, 'netapp', $descr, '1', '1', $low_limit, $low_warn_limit, $warn_limit, $high_limit, $temperature);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,17 +18,21 @@ function poll_sensor($device, $class, $unit)
|
||||
}
|
||||
if ($class == "temperature")
|
||||
{
|
||||
for ($i = 0;$i < 5;$i++) # Try 5 times to get a valid temp reading
|
||||
{
|
||||
if ($debug) echo("Attempt $i ");
|
||||
$sensor_value = trim(str_replace("\"", "", snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB$mib")));
|
||||
preg_match("/[\d\.]+/",$sensor_value,$temp_response);
|
||||
if (!empty($temp_response[0])) {
|
||||
$sensor_value = $temp_response[0];
|
||||
}
|
||||
if ($device['os'] == 'netapp') {
|
||||
require "includes/polling/temperatures/netapp.inc.php";
|
||||
} else {
|
||||
for ($i = 0;$i < 5;$i++) # Try 5 times to get a valid temp reading
|
||||
{
|
||||
if ($debug) echo("Attempt $i ");
|
||||
$sensor_value = trim(str_replace("\"", "", snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB$mib")));
|
||||
preg_match("/[\d\.]+/",$sensor_value,$temp_response);
|
||||
if (!empty($temp_response[0])) {
|
||||
$sensor_value = $temp_response[0];
|
||||
}
|
||||
|
||||
if (is_numeric($sensor_value) && $sensor_value != 9999) break; # TME sometimes sends 999.9 when it is right in the middle of an update;
|
||||
sleep(1); # Give the TME some time to reset
|
||||
if (is_numeric($sensor_value) && $sensor_value != 9999) break; # TME sometimes sends 999.9 when it is right in the middle of an update;
|
||||
sleep(1); # Give the TME some time to reset
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($sensor['sensor_type'] == 'apc') {
|
||||
|
||||
6
includes/polling/temperatures/netapp.inc.php
Normal file
6
includes/polling/temperatures/netapp.inc.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
$sensor_value = trim(str_replace("\"", "", snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "")));
|
||||
preg_match_all("/([0-9]+C)+/", $sensor_value, $temps);
|
||||
list(,$index) = split("\.", $sensor['sensor_index']);
|
||||
$sensor_value = $temps[0][$index];
|
||||
Reference in New Issue
Block a user