From 8e46ec5cbd9f9560f5c5f47cd47dae72e2cfc08f Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Mon, 8 Feb 2010 00:45:59 +0000 Subject: [PATCH] drop temp- requirement, this is just to fool snmpd git-svn-id: http://www.observium.org/svn/observer/trunk@789 61d68cd4-352d-0410-923a-c4978735b2b8 --- includes/discovery/temperatures.php | 45 ++++++++++++++--------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/includes/discovery/temperatures.php b/includes/discovery/temperatures.php index 4086000fb..bf2cdb374 100755 --- a/includes/discovery/temperatures.php +++ b/includes/discovery/temperatures.php @@ -156,31 +156,28 @@ if ($device['os'] == "linux") if ($data) { list($oid,$descr) = explode(" ", $data,2); - if (substr($descr,0,5) == "temp-") + $split_oid = explode('.',$oid); + $temp_id = $split_oid[count($split_oid)-1]; + $temp_oid = "1.3.6.1.4.1.2021.13.16.2.1.3.$temp_id"; + $temp = trim(shell_exec($config['snmpget'] . " -m LM-SENSORS-MIB -O qv -$snmpver -c $community $hostname:$port $temp_oid")) / 1000; + $descr = str_ireplace("temp-", "", $descr); + $descr = trim($descr); + if (mysql_result(mysql_query("SELECT count(temp_id) FROM `temperature` WHERE temp_oid = '$temp_oid' AND temp_host = '$id'"),0) == '0') { - $split_oid = explode('.',$oid); - $temp_id = $split_oid[count($split_oid)-1]; - $temp_oid = "1.3.6.1.4.1.2021.13.16.2.1.3.$temp_id"; - $temp = trim(shell_exec($config['snmpget'] . " -m LM-SENSORS-MIB -O qv -$snmpver -c $community $hostname:$port $temp_oid")) / 1000; - $descr = str_ireplace("temp-", "", $descr); - $descr = trim($descr); - if (mysql_result(mysql_query("SELECT count(temp_id) FROM `temperature` WHERE temp_oid = '$temp_oid' AND temp_host = '$id'"),0) == '0') - { - $query = "INSERT INTO temperature (`temp_host`, `temp_oid`, `temp_descr`, `temp_precision`, `temp_limit`, `temp_current`) values ('$id', '$temp_oid', '$descr',1000, " . ($config['defaults']['temp_limit'] ? $config['defaults']['temp_limit'] : '60') . ", '$temp')"; - mysql_query($query); - echo("+"); - } - elseif (mysql_result(mysql_query("SELECT `temp_descr` FROM temperature WHERE `temp_host` = '$id' AND `temp_oid` = '$temp_oid'"), 0) != $descr) - { - echo("U"); - mysql_query("UPDATE temperature SET `temp_descr` = '$descr' WHERE `temp_host` = '$id' AND `temp_oid` = '$temp_oid'"); - } - else - { - echo("."); - } - $temp_exists[] = "$id $temp_oid"; - } + $query = "INSERT INTO temperature (`temp_host`, `temp_oid`, `temp_descr`, `temp_precision`, `temp_limit`, `temp_current`) values ('$id', '$temp_oid', '$descr',1000, " . ($config['defaults']['temp_limit'] ? $config['defaults']['temp_limit'] : '60') . ", '$temp')"; + mysql_query($query); + echo("+"); + } + elseif (mysql_result(mysql_query("SELECT `temp_descr` FROM temperature WHERE `temp_host` = '$id' AND `temp_oid` = '$temp_oid'"), 0) != $descr) + { + echo("U"); + mysql_query("UPDATE temperature SET `temp_descr` = '$descr' WHERE `temp_host` = '$id' AND `temp_oid` = '$temp_oid'"); + } + else + { + echo("."); + } + $temp_exists[] = "$id $temp_oid"; } } }