From e696b60ba72d3f48303e5a655f24a25ce0096a59 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Sat, 12 Jun 2010 15:17:38 +0000 Subject: [PATCH] switch to preg_split (split deprecated). ignore temps >1000 and == 0 for lmsensors git-svn-id: http://www.observium.org/svn/observer/trunk@1150 61d68cd4-352d-0410-923a-c4978735b2b8 --- includes/discovery/functions.inc.php | 2 +- includes/discovery/temperatures.inc.php | 4 +++- includes/snmp.inc.php | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index e49619035..2e55a09e8 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -141,7 +141,7 @@ 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, $debug; - if($debug) { echo("$oid, $index, $type, $descr, $precision\n"); } + if($debug) { echo("$oid, $index, $type, $descr, $precision, $current\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') diff --git a/includes/discovery/temperatures.inc.php b/includes/discovery/temperatures.inc.php index 302814bfa..774fd8b5a 100755 --- a/includes/discovery/temperatures.inc.php +++ b/includes/discovery/temperatures.inc.php @@ -194,7 +194,9 @@ if ($device['os'] == "linux") $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); - discover_temperature($valid_temp, $device, $temp_oid, $temp_id, "lmsensors", $descr, "1000", NULL, NULL, NULL); + if($temp != "0" && $temp <= "1000") { + discover_temperature($valid_temp, $device, $temp_oid, $temp_id, "lmsensors", $descr, "1000", NULL, NULL, $temp); + } } } } diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index 2f4ba9324..9bda07f52 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -42,7 +42,7 @@ function snmp_cache_cip($oid, $device, $array, $mib = 0) $device_id = $device['device_id']; #echo("Caching: $oid\n"); foreach(explode("\n", $data) as $entry) { - list ($this_oid, $this_value) = split("=", $entry); + list ($this_oid, $this_value) = preg_split("/=/", $entry); $this_oid = trim($this_oid); $this_value = trim($this_value); $this_oid = substr($this_oid, 30); @@ -69,7 +69,7 @@ function snmp_cache_ifIndex($device) { $data = trim(shell_exec($cmd)); $device_id = $device['device_id']; foreach(explode("\n", $data) as $entry) { - list ($this_oid, $this_value) = split("=", $entry); + list ($this_oid, $this_value) = preg_split("/=/", $entry); list ($this_oid, $this_index) = explode(".", $this_oid); $this_index = trim($this_index); $this_oid = trim($this_oid); @@ -217,7 +217,7 @@ function snmp_cache_oid($oid, $device, $array, $mib = 0) { $device_id = $device['device_id']; #echo("Caching: $oid\n"); foreach(explode("\n", $data) as $entry) { - list ($this_oid, $this_value) = split("=", $entry); + list ($this_oid, $this_value) = preg_split("/=/", $entry); list ($this_oid, $this_index) = explode(".", $this_oid); $this_index = trim($this_index); $this_oid = trim($this_oid);