diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index 4cd7e2f58f..4a0d26aca5 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -187,7 +187,7 @@ function discover_device($device, $options = null) // Discover sensors -function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr, $divisor = '1', $multiplier = '1', $low_limit = null, $low_warn_limit = null, $warn_limit = null, $high_limit = null, $current = null, $poller_type = 'snmp', $entPhysicalIndex = null, $entPhysicalIndex_measured = null) +function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr, $divisor = 1, $multiplier = 1, $low_limit = null, $low_warn_limit = null, $warn_limit = null, $high_limit = null, $current = null, $poller_type = 'snmp', $entPhysicalIndex = null, $entPhysicalIndex_measured = null) { $low_limit = set_null($low_limit); @@ -199,27 +199,27 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr, $divisor = 1; } - d_echo("Discover sensor: $oid, $index, $type, $descr, $poller_type, $precision, $entPhysicalIndex\n"); + d_echo("Discover sensor: $oid, $index, $type, $descr, $poller_type, $divisor, $multiplier, $entPhysicalIndex, $current\n"); if (is_null($low_warn_limit) && !is_null($warn_limit)) { // Warn limits only make sense when we have both a high and a low limit $low_warn_limit = null; $warn_limit = null; - } elseif ($low_warn_limit > $warn_limit) { + } elseif (!is_null($warn_limit) && $low_warn_limit > $warn_limit) { // Fix high/low thresholds (i.e. on negative numbers) list($warn_limit, $low_warn_limit) = array($low_warn_limit, $warn_limit); } if (dbFetchCell('SELECT COUNT(sensor_id) FROM `sensors` WHERE `poller_type`= ? AND `sensor_class` = ? AND `device_id` = ? AND sensor_type = ? AND `sensor_index` = ?', array($poller_type, $class, $device['device_id'], $type, $index)) == '0') { - if (!$high_limit) { + if (is_null($high_limit)) { $high_limit = sensor_limit($class, $current); } - if (!$low_limit) { + if (is_null($low_limit)) { $low_limit = sensor_low_limit($class, $current); } - if ($low_limit > $high_limit) { + if (!is_null($high_limit) && $low_limit > $high_limit) { // Fix high/low thresholds (i.e. on negative numbers) list($high_limit, $low_limit) = array($low_limit, $high_limit); } diff --git a/includes/discovery/sensors/charge/rfc1628.inc.php b/includes/discovery/sensors/charge/rfc1628.inc.php index 4b7e4db415..ab93f57cae 100644 --- a/includes/discovery/sensors/charge/rfc1628.inc.php +++ b/includes/discovery/sensors/charge/rfc1628.inc.php @@ -19,6 +19,6 @@ foreach (explode("\n", $oids) as $data) { $type = 'rfc1628'; $index = (500 + $current_id); - discover_sensor($valid['sensor'], 'charge', $device, $current_oid, $index, $type, $descr, '1', '1', null, null, null, null, $current); + discover_sensor($valid['sensor'], 'charge', $device, $current_oid, $index, $type, $descr, 1, 1, 15, 50, null, 101, $current); } } diff --git a/includes/discovery/sensors/power/rfc1628.inc.php b/includes/discovery/sensors/power/rfc1628.inc.php index ee8ef9bacf..0563c66e33 100644 --- a/includes/discovery/sensors/power/rfc1628.inc.php +++ b/includes/discovery/sensors/power/rfc1628.inc.php @@ -16,7 +16,9 @@ for ($i = 1; $i <= $numPhase; $i++) { $precision = 1; $index = 300+$i; - discover_sensor($valid['sensor'], 'power', $device, $current_oid, $index, $type, $descr, '1', '1', null, null, null, null, $current); + if (is_numeric($current)) { + discover_sensor($valid['sensor'], 'power', $device, $current_oid, $index, $type, $descr, '1', '1', null, null, null, null, $current); + } } $oids = trim(snmp_walk($device, ".1.3.6.1.2.1.33.1.3.2.0", "-OsqnU")); @@ -33,7 +35,9 @@ for ($i = 1; $i <= $numPhase; $i++) { $precision = 1; $index = 100+$i; - discover_sensor($valid['sensor'], 'power', $device, $current_oid, $index, $type, $descr, '1', '1', null, null, null, null, $current); + if (is_numeric($current)) { + discover_sensor($valid['sensor'], 'power', $device, $current_oid, $index, $type, $descr, '1', '1', null, null, null, null, $current); + } } $oids = trim(snmp_walk($device, ".1.3.6.1.2.1.33.1.5.2.0", "-OsqnU")); @@ -50,5 +54,7 @@ for ($i = 1; $i <= $numPhase; $i++) { $precision = 1; $index = 200+$i; - discover_sensor($valid['sensor'], 'power', $device, $current_oid, $index, $type, $descr, '1', '1', null, null, null, null, $current); + if (is_numeric($current)) { + discover_sensor($valid['sensor'], 'power', $device, $current_oid, $index, $type, $descr, '1', '1', null, null, null, null, $current); + } }