From 4696c7f02a179fc2969e9f5e540caa254217c9aa Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Fri, 30 Jul 2010 16:11:09 +0000 Subject: [PATCH] fixes to sensor detection (next comes more filtering) git-svn-id: http://www.observium.org/svn/observer/trunk@1548 61d68cd4-352d-0410-923a-c4978735b2b8 --- includes/discovery/cisco-entity-sensor.inc.php | 3 +++ includes/discovery/entity-sensor.inc.php | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/discovery/cisco-entity-sensor.inc.php b/includes/discovery/cisco-entity-sensor.inc.php index 606d6ac22..e3d22f89f 100644 --- a/includes/discovery/cisco-entity-sensor.inc.php +++ b/includes/discovery/cisco-entity-sensor.inc.php @@ -12,6 +12,7 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios") $oids = snmpwalk_cache_multi_oid($device, "entSensorScale", $oids, "CISCO-ENTITY-SENSOR-MIB"); $oids = snmpwalk_cache_multi_oid($device, "entSensorValue", $oids, "CISCO-ENTITY-SENSOR-MIB"); $oids = snmpwalk_cache_multi_oid($device, "entSensorMeasuredEntity", $oids, "CISCO-ENTITY-SENSOR-MIB"); + $oids = snmpwalk_cache_multi_oid($device, "entSensorPrecision", $oids, "CISCO-ENTITY-SENSOR-MIB"); if($debug) { print_r($oids); } @@ -59,6 +60,8 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios") if($entry['entSensorScale'] == "kilo") { $divisor = "1"; $multiplier = "1000"; } if($entry['entSensorScale'] == "mega") { $divisor = "1"; $multiplier = "1000000"; } if($entry['entSensorScale'] == "giga") { $divisor = "1"; $multiplier = "1000000000"; } + if(is_numeric($entry['entSensorPrecision']) && $entry['entSensorPrecision'] > "0") { $divisor = $divisor . str_pad('', $entry['entSensorPrecision'], "0"); } + $current = $current * $multiplier / $divisor; $current = $current * $multiplier / $divisor; discover_sensor($valid_sensor, $type, $device, $oid, $index, 'cisco-entity-sensor', $descr, $divisor, $multiplier, NULL, NULL, NULL, NULL, $temperature); diff --git a/includes/discovery/entity-sensor.inc.php b/includes/discovery/entity-sensor.inc.php index 31348cbe7..3311d5907 100644 --- a/includes/discovery/entity-sensor.inc.php +++ b/includes/discovery/entity-sensor.inc.php @@ -54,11 +54,12 @@ if(is_array($oids[$device['device_id']])) if($entry['entPhySensorScale'] == "mega") { $divisor = "1"; $multiplier = "1000000"; } if($entry['entPhySensorScale'] == "giga") { $divisor = "1"; $multiplier = "1000000000"; } - if(is_numeric($entry['entPhySensorPrecision']) && $entry['entPhySensorPrecision'] > "0") { $multiplier = $multiplier . str_pad('', $entry['entPhySensorPrecision'], "0"); } + if(is_numeric($entry['entPhySensorPrecision']) && $entry['entPhySensorPrecision'] > "0") { $divisor = $divisor . str_pad('', $entry['entPhySensorPrecision'], "0"); } $current = $current * $multiplier / $divisor; if($type == "temperature") { if($current > "200"){ $valid = FALSE; } $descr = preg_replace("/[T|t]emperature[|s]/", "", $descr); } + #echo($descr . "|" . $index . "|" .$current . "|" . $multiplier . "|" . $divisor ."|" . $entry['entPhySensorScale'] . "|" . $entry['entPhySensorPrecision'] . "\n"); if($valid && mysql_result(mysql_query("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = '".$device['device_id']."' AND `sensor_class` = '".$type."' AND `sensor_type` = 'cisco-entity-sensor' AND `sensor_index` = '".$index."'"),0) == "0") ## Check to make sure we've not already seen this sensor via cisco's entity sensor mib