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
This commit is contained in:
Adam Amstrong
2010-06-12 15:17:38 +00:00
parent f94aeee0ef
commit e696b60ba7
3 changed files with 7 additions and 5 deletions

View File

@@ -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')

View File

@@ -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);
}
}
}
}

View File

@@ -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);