diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index 1691111a5b..de84193f2c 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -109,6 +109,30 @@ function discover_mempool(&$valid_mempool, $device, $index, $type, $descr, $prec } } +function discover_temperature(&$valid_temp, $device, $oid, $index, $type, $descr, $precision = 1, $low_limit = NULL, $high_limit = NULL, $current) +{ + global $config; global $debug; + if($debug) { echo("$oid, $index, $type, $descr, $precision\n"); } + if (mysql_result(mysql_query("SELECT COUNT(temp_id) FROM `temperature` WHERE temp_type = '$type' AND temp_index = '$index' AND device_id = '".$device['device_id']."'"),0) == '0') + { + $query = "INSERT INTO temperature (`device_id`, `temp_type`,`temp_index`,`temp_oid`, `temp_descr`, `temp_limit`, `temp_current`, `temp_precision`)"; + $query .= " values ('".$device['device_id']."', '$type','$index','$oid', '$descr','" . ($high_limit ? $high_limit : $config['defaults']['temp_limit']) . "', '$current', '$precision')"; + mysql_query($query); + echo("+"); + } else { + $entry = mysql_fetch_array(mysql_query("SELECT * FROM `temperature` WHERE device_id = '".$device['device_id']."' AND `temp_type` = '$type' AND `temp_index` = '$index'")); + echo(mysql_error()); + if($oid == $entry['temp_oid'] && $descr == $entry['temp_descr'] && $precision == $ntry['temp_precision']) { + echo("."); + } else { + mysql_query("UPDATE temperature SET `temp_descr` = '$descr', `temp_oid` = '$oid', `temp_precision` = '$precision' WHERE `temp_id` = '".$entry['temp_id']."'"); + echo("U"); + } + } + echo(mysql_error()); + $valid_temp[$type][$index] = 1; + return $return; +} function discover_fan($device, $oid, $index, $type, $descr, $precision = 1, $low_limit = NULL, $high_limit = NULL, $current = NULL) { diff --git a/includes/discovery/temperatures-junose.inc.php b/includes/discovery/temperatures-junose.inc.php new file mode 100644 index 0000000000..e7fae7b927 --- /dev/null +++ b/includes/discovery/temperatures-junose.inc.php @@ -0,0 +1,25 @@ + $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! + $descr = str_replace("temperature sensor on", "", trim($descr)); + $oid = ".1.3.6.1.4.1.4874.2.2.2.1.9.4.1.3.".$index; + $current = $entry['juniSystemTempValue']; + discover_temperature($valid_temp, $device, $oid, $index, "junose", $descr, "1", NULL, NULL, $current); + $temp_exists[] = $device['device_id'] . " $oid"; + } + } + } +} + +?> diff --git a/includes/discovery/temperatures.inc.php b/includes/discovery/temperatures.inc.php index 4fe78e0f6a..8ed4665baa 100755 --- a/includes/discovery/temperatures.inc.php +++ b/includes/discovery/temperatures.inc.php @@ -7,6 +7,8 @@ $port = $device['port']; echo("Temperatures : "); +include("temperatures-junose.inc.php"); + if($device['os'] == "ironware") {