diff --git a/includes/discovery/sensors/current/comware.inc.php b/includes/discovery/sensors/current/comware.inc.php index 527cbf6a84..dde2fb6d59 100644 --- a/includes/discovery/sensors/current/comware.inc.php +++ b/includes/discovery/sensors/current/comware.inc.php @@ -16,7 +16,7 @@ $multiplier = 1; $divisor = 100000; $divisor_alarm = 1000000; foreach ($pre_cache['comware_oids'] as $index => $entry) { - if (is_numeric($entry['hh3cTransceiverBiasCurrent']) && $entry['hh3cTransceiverBiasCurrent'] != 2147483647) { + if (is_numeric($entry['hh3cTransceiverBiasCurrent']) && $entry['hh3cTransceiverBiasCurrent'] != 2147483647 && isset($entry['hh3cTransceiverDiagnostic'])) { $oid = '.1.3.6.1.4.1.25506.2.70.1.1.1.17.' . $index; $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", array( $index, @@ -30,7 +30,7 @@ foreach ($pre_cache['comware_oids'] as $index => $entry) { $entPhysicalIndex = $index; $entPhysicalIndex_measured = 'ports'; foreach ($dbquery as $dbindex => $dbresult) { - $descr = $dbresult['ifDescr'] . ' Bias Current'; + $descr = makeshortif($dbresult['ifDescr']) . ' Bias Current'; discover_sensor($valid['sensor'], 'current', $device, $oid, 'bias-' . $index, 'comware', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured); } } diff --git a/includes/discovery/sensors/dbm/comware.inc.php b/includes/discovery/sensors/dbm/comware.inc.php index be1382eb1f..768ea6fdd7 100644 --- a/includes/discovery/sensors/dbm/comware.inc.php +++ b/includes/discovery/sensors/dbm/comware.inc.php @@ -2,7 +2,7 @@ /* * LibreNMS * - * Copyright (c) 2016 Søren Friis Rosiak + * Copyright (c) 2016 Søren Friis Rosiak * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your @@ -11,44 +11,44 @@ */ echo 'Comware '; - + $multiplier = 1; $divisor = 100; foreach ($pre_cache['comware_oids'] as $index => $entry) { - if (is_numeric($entry['hh3cTransceiverCurRXPower']) && $entry['hh3cTransceiverCurRXPower'] != 2147483647) { + if (is_numeric($entry['hh3cTransceiverCurRXPower']) && $entry['hh3cTransceiverCurRXPower'] != 2147483647 && isset($entry['hh3cTransceiverDiagnostic'])) { $oid = '.1.3.6.1.4.1.25506.2.70.1.1.1.12.' . $index; $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", array( $index, $device['device_id'] )); - $limit_low = uw_to_dbm($entry['hh3cTransceiverRcvPwrLoAlarm'] / 10); - $warn_limit_low = uw_to_dbm($entry['hh3cTransceiverRcvPwrLoWarn'] / 10); - $limit = uw_to_dbm($entry['hh3cTransceiverRcvPwrHiAlarm'] / 10); - $warn_limit = uw_to_dbm($entry['hh3cTransceiverRcvPwrHiWarn'] / 10); + $limit_low = round(uw_to_dbm($entry['hh3cTransceiverRcvPwrLoAlarm'] / 10), 2); + $warn_limit_low = round(uw_to_dbm($entry['hh3cTransceiverRcvPwrLoWarn'] / 10), 2); + $limit = round(uw_to_dbm($entry['hh3cTransceiverRcvPwrHiAlarm'] / 10), 2); + $warn_limit = round(uw_to_dbm($entry['hh3cTransceiverRcvPwrHiWarn'] / 10), 2); $current = $entry['hh3cTransceiverCurRXPower'] / $divisor; $entPhysicalIndex = $index; $entPhysicalIndex_measured = 'ports'; foreach ($dbquery as $dbindex => $dbresult) { - $descr = $dbresult['ifDescr'] . ' Rx Power'; + $descr = makeshortif($dbresult['ifDescr']) . ' Receive Power'; discover_sensor($valid['sensor'], 'dbm', $device, $oid, 'rx-' . $index, 'comware', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured); } } - - if (is_numeric($entry['hh3cTransceiverCurTXPower']) && $entry['hh3cTransceiverCurTXPower'] != 2147483647) { + + if (is_numeric($entry['hh3cTransceiverCurTXPower']) && $entry['hh3cTransceiverCurTXPower'] != 2147483647 && isset($entry['hh3cTransceiverDiagnostic'])) { $oid = '.1.3.6.1.4.1.25506.2.70.1.1.1.9.' . $index; $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", array( $index, $device['device_id'] )); - $limit_low = uw_to_dbm($entry['hh3cTransceiverPwrOutLoAlarm'] / 10); - $warn_limit_low = uw_to_dbm($entry['hh3cTransceiverPwrOutLoWarn'] / 10); - $limit = uw_to_dbm($entry['hh3cTransceiverPwrOutHiAlarm'] / 10); - $warn_limit = uw_to_dbm($entry['hh3cTransceiverPwrOutHiWarn'] / 10); + $limit_low = round(uw_to_dbm($entry['hh3cTransceiverPwrOutLoAlarm'] / 10), 2); + $warn_limit_low = round(uw_to_dbm($entry['hh3cTransceiverPwrOutLoWarn'] / 10), 2); + $limit = round(uw_to_dbm($entry['hh3cTransceiverPwrOutHiAlarm'] / 10), 2); + $warn_limit = round(uw_to_dbm($entry['hh3cTransceiverPwrOutHiWarn'] / 10), 2); $current = $entry['hh3cTransceiverCurTXPower'] / $divisor; $entPhysicalIndex = $index; $entPhysicalIndex_measured = 'ports'; foreach ($dbquery as $dbindex => $dbresult) { - $descr = $dbresult['ifDescr'] . ' Tx Power'; + $descr = makeshortif($dbresult['ifDescr']) . ' Transmit Power'; discover_sensor($valid['sensor'], 'dbm', $device, $oid, 'tx-' . $index, 'comware', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured); } } diff --git a/includes/discovery/sensors/temperature/comware.inc.php b/includes/discovery/sensors/temperature/comware.inc.php index 39ba5d41f4..fb3cda7764 100644 --- a/includes/discovery/sensors/temperature/comware.inc.php +++ b/includes/discovery/sensors/temperature/comware.inc.php @@ -48,7 +48,7 @@ $multiplier = 1; $divisor = 1; $divisor_alarm = 1000; foreach ($pre_cache['comware_oids'] as $index => $entry) { - if (is_numeric($entry['hh3cTransceiverTemperature']) && $entry['hh3cTransceiverTemperature'] != 2147483647) { + if (is_numeric($entry['hh3cTransceiverTemperature']) && $entry['hh3cTransceiverTemperature'] != 2147483647 && isset($entry['hh3cTransceiverDiagnostic'])) { $oid = '.1.3.6.1.4.1.25506.2.70.1.1.1.15.' . $index; $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", array($index,$device['device_id'])); $limit_low = $entry['hh3cTransceiverTempLoAlarm'] / $divisor_alarm; @@ -59,7 +59,7 @@ foreach ($pre_cache['comware_oids'] as $index => $entry) { $entPhysicalIndex = $index; $entPhysicalIndex_measured = 'ports'; foreach ($dbquery as $dbindex => $dbresult) { - $descr = $dbresult['ifDescr'] . ' Temperature'; + $descr = makeshortif($dbresult['ifDescr']) . ' Module'; discover_sensor($valid['sensor'], 'temperature', $device, $oid, 'temp-trans-' . $index, 'comware', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured); } } diff --git a/includes/discovery/sensors/voltage/comware.inc.php b/includes/discovery/sensors/voltage/comware.inc.php index 5b88535c65..2b32ffdd01 100644 --- a/includes/discovery/sensors/voltage/comware.inc.php +++ b/includes/discovery/sensors/voltage/comware.inc.php @@ -16,7 +16,7 @@ $multiplier = 1; $divisor = 100; $divisor_alarm = 10000; foreach ($pre_cache['comware_oids'] as $index => $entry) { - if (is_numeric($entry['hh3cTransceiverVoltage']) && $entry['hh3cTransceiverVoltage'] != 2147483647) { + if (is_numeric($entry['hh3cTransceiverVoltage']) && $entry['hh3cTransceiverVoltage'] != 2147483647 && isset($entry['hh3cTransceiverDiagnostic'])) { $oid = '.1.3.6.1.4.1.25506.2.70.1.1.1.16.' . $index; $dbquery = dbFetchRows("SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ? AND `ifAdminStatus` = 'up'", array( $index, @@ -30,7 +30,7 @@ foreach ($pre_cache['comware_oids'] as $index => $entry) { $entPhysicalIndex = $index; $entPhysicalIndex_measured = 'ports'; foreach ($dbquery as $dbindex => $dbresult) { - $descr = $dbresult['ifDescr'] . ' Voltage'; + $descr = makeshortif($dbresult['ifDescr']) . ' Supply Voltage'; discover_sensor($valid['sensor'], 'voltage', $device, $oid, 'volt-' . $index, 'comware', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured); } } diff --git a/includes/rewrites.php b/includes/rewrites.php index aff84311df..060ce835af 100644 --- a/includes/rewrites.php +++ b/includes/rewrites.php @@ -166,22 +166,23 @@ function translate_ifAdminStatus($ifAdminStatus) function makeshortif($if) { $rewrite_shortif = array( - 'tengigabitethernet' => 'Te', - 'tengige' => 'Te', - 'gigabitethernet' => 'Gi', - 'fastethernet' => 'Fa', - 'ethernet' => 'Et', - 'serial' => 'Se', - 'pos' => 'Pos', - 'port-channel' => 'Po', - 'atm' => 'Atm', - 'null' => 'Null', - 'loopback' => 'Lo', - 'dialer' => 'Di', - 'vlan' => 'Vlan', - 'tunnel' => 'Tunnel', - 'serviceinstance' => 'SI', - 'dwdm' => 'DWDM', + 'tengigabitethernet' => 'Te', + 'ten-gigabitethernet' => 'Te', + 'tengige' => 'Te', + 'gigabitethernet' => 'Gi', + 'fastethernet' => 'Fa', + 'ethernet' => 'Et', + 'serial' => 'Se', + 'pos' => 'Pos', + 'port-channel' => 'Po', + 'atm' => 'Atm', + 'null' => 'Null', + 'loopback' => 'Lo', + 'dialer' => 'Di', + 'vlan' => 'Vlan', + 'tunnel' => 'Tunnel', + 'serviceinstance' => 'SI', + 'dwdm' => 'DWDM', ); $if = fixifName($if);