From 84fdfdf542918e3b2d31a68e538a5ebb61b84cd4 Mon Sep 17 00:00:00 2001 From: bergroth Date: Wed, 13 Dec 2017 03:27:10 +0100 Subject: [PATCH] Junos dwdm interface sensor support (#7714) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Junos dwdm interface sensor support … four new sensors Chromatic Dispersion ps/nm Delay s (seconds) Q_factor (dB) preFEC_BER (ratio) reuse of SNR, dbm, temperature, current * new dwdm sensors more generic, ber and quality_factor * new sensors updated * renamed html graphs new sensors * fixed ber polling * Change to base SI Hz and s. * update sensor divisors to bigint * rename sql-schema/216.sql to 218.sql * YAML junos dwmd sensor definitions, except BER * bigint divisor fixed * deafult 1 divisior * small fixes including schema change for another PR * schema fix --- doc/Developing/os/Health-Information.md | 4 + html/includes/graphs/device/ber.inc.php | 8 ++ .../device/chromatic_dispersion.inc.php | 7 ++ html/includes/graphs/device/delay.inc.php | 7 ++ .../graphs/device/quality_factor.inc.php | 7 ++ html/includes/graphs/sensor/ber.inc.php | 26 +++++ .../sensor/chromatic_dispersion.inc.php | 24 +++++ html/includes/graphs/sensor/current.inc.php | 6 +- html/includes/graphs/sensor/delay.inc.php | 24 +++++ html/includes/graphs/sensor/frequency.inc.php | 4 +- .../graphs/sensor/quality_factor.inc.php | 24 +++++ html/includes/print-menubar.php | 5 + html/pages/device/health.inc.php | 25 ++++- html/pages/device/health/ber.inc.php | 7 ++ .../health/chromatic_dispersion.inc.php | 7 ++ html/pages/device/health/delay.inc.php | 7 ++ .../device/health/quality_factor.inc.php | 7 ++ html/pages/device/overview.inc.php | 4 + .../pages/device/overview/sensors/ber.inc.php | 8 ++ .../sensors/chromatic_dispersion.inc.php | 8 ++ .../device/overview/sensors/delay.inc.php | 8 ++ .../overview/sensors/quality_factor.inc.php | 8 ++ html/pages/health.inc.php | 16 +++ html/pages/health/ber.inc.php | 7 ++ .../pages/health/chromatic_dispersion.inc.php | 7 ++ html/pages/health/delay.inc.php | 7 ++ html/pages/health/quality_factor.inc.php | 7 ++ includes/common.php | 2 +- includes/definitions/discovery/junos.yaml | 102 ++++++++++++++++++ includes/discovery/functions.inc.php | 4 + includes/discovery/sensors.inc.php | 4 + includes/discovery/sensors/ber/junos.inc.php | 34 ++++++ .../discovery/sensors/current/junos.inc.php | 2 +- .../discovery/sensors/pre-cache/junos.inc.php | 6 ++ includes/polling/functions.inc.php | 3 +- includes/polling/sensors/ber/junos.inc.php | 9 ++ misc/db_schema.yaml | 4 +- sql-schema/223.sql | 1 + 38 files changed, 439 insertions(+), 11 deletions(-) create mode 100644 html/includes/graphs/device/ber.inc.php create mode 100644 html/includes/graphs/device/chromatic_dispersion.inc.php create mode 100644 html/includes/graphs/device/delay.inc.php create mode 100644 html/includes/graphs/device/quality_factor.inc.php create mode 100644 html/includes/graphs/sensor/ber.inc.php create mode 100644 html/includes/graphs/sensor/chromatic_dispersion.inc.php create mode 100644 html/includes/graphs/sensor/delay.inc.php create mode 100644 html/includes/graphs/sensor/quality_factor.inc.php create mode 100644 html/pages/device/health/ber.inc.php create mode 100644 html/pages/device/health/chromatic_dispersion.inc.php create mode 100644 html/pages/device/health/delay.inc.php create mode 100644 html/pages/device/health/quality_factor.inc.php create mode 100644 html/pages/device/overview/sensors/ber.inc.php create mode 100644 html/pages/device/overview/sensors/chromatic_dispersion.inc.php create mode 100644 html/pages/device/overview/sensors/delay.inc.php create mode 100644 html/pages/device/overview/sensors/quality_factor.inc.php create mode 100644 html/pages/health/ber.inc.php create mode 100644 html/pages/health/chromatic_dispersion.inc.php create mode 100644 html/pages/health/delay.inc.php create mode 100644 html/pages/health/quality_factor.inc.php create mode 100644 includes/definitions/discovery/junos.yaml create mode 100644 includes/discovery/sensors/ber/junos.inc.php create mode 100644 includes/polling/sensors/ber/junos.inc.php create mode 100644 sql-schema/223.sql diff --git a/doc/Developing/os/Health-Information.md b/doc/Developing/os/Health-Information.md index 3ec34ed5c4..ba2a95f4e0 100644 --- a/doc/Developing/os/Health-Information.md +++ b/doc/Developing/os/Health-Information.md @@ -25,6 +25,10 @@ Currently we have support for the following health metrics along with the values | state | # | | temperature | C | | voltage | V | +| delay | s | +| quality_factor | dB | +| chromatic_disperision | ps/nm | +| ber | ratio | #### Simple health discovery diff --git a/html/includes/graphs/device/ber.inc.php b/html/includes/graphs/device/ber.inc.php new file mode 100644 index 0000000000..7d61a26753 --- /dev/null +++ b/html/includes/graphs/device/ber.inc.php @@ -0,0 +1,8 @@ + 'thermometer-empty', 'cooling' => 'thermometer-full', 'airflow' => 'angle-double-right', + 'delay' => 'clock-o', + 'chromatic_dispersion' => 'indent', + 'ber' => 'sort-amount-desc', + 'quality_factor' => 'arrows', + ); foreach (array('fanspeed','humidity','temperature','signal') as $item) { if (isset($menu_sensors[$item])) { diff --git a/html/pages/device/health.inc.php b/html/pages/device/health.inc.php index 8bf865ac8a..0a9e091d6f 100644 --- a/html/pages/device/health.inc.php +++ b/html/pages/device/health.inc.php @@ -22,6 +22,10 @@ $airflow = dbFetchCell("select count(*) from sensors WHERE sensor_class='ai $snr = dbFetchCell("select count(*) from sensors WHERE sensor_class='snr' AND device_id = ?", array($device['device_id'])); $pressure = dbFetchCell("select count(*) from sensors WHERE sensor_class='pressure' AND device_id = ?", array($device['device_id'])); $cooling = dbFetchCell("select count(*) from sensors WHERE sensor_class='cooling' AND device_id = ?", array($device['device_id'])); +$delay = dbFetchCell("select count(*) from sensors WHERE sensor_class='delay' AND device_id = ?", array($device['device_id'])); +$quality_factor = dbFetchCell("select count(*) from sensors WHERE sensor_class='quality_factor' AND device_id = ?", array($device['device_id'])); +$chromatic_dispersion = dbFetchCell("select count(*) from sensors WHERE sensor_class='chromatic_dispersion' AND device_id = ?", array($device['device_id'])); +$ber = dbFetchCell("select count(*) from sensors WHERE sensor_class='ber' AND device_id = ?", array($device['device_id'])); unset($datas); $datas[] = 'overview'; @@ -109,6 +113,22 @@ if ($cooling) { $datas[] = 'cooling'; } +if ($delay) { + $datas[] = 'delay'; +} + +if ($quality_factor) { + $datas[] = 'quality_factor'; +} + +if ($chromatic_dispersion) { + $datas[] = 'chromatic_dispersion'; +} + +if ($ber) { + $datas[] = 'ber'; +} + $type_text['overview'] = 'Overview'; $type_text['charge'] = 'Battery Charge'; $type_text['temperature'] = 'Temperature'; @@ -131,6 +151,10 @@ $type_text['airflow'] = 'Airflow'; $type_text['snr'] = 'SNR'; $type_text['pressure'] = 'Pressure'; $type_text['cooling'] = 'Cooling'; +$type_text['delay'] = 'Delay'; +$type_text['quality_factor'] = 'Quality factor'; +$type_text['chromatic_dispersion'] = 'Chromatic Dispersion'; +$type_text['ber'] = 'Bit Error Rate'; $link_array = array( 'page' => 'device', @@ -149,7 +173,6 @@ if (!$vars['metric']) { unset($sep); foreach ($datas as $type) { echo $sep; - if ($vars['metric'] == $type) { echo ''; } diff --git a/html/pages/device/health/ber.inc.php b/html/pages/device/health/ber.inc.php new file mode 100644 index 0000000000..8cb947b16c --- /dev/null +++ b/html/pages/device/health/ber.inc.php @@ -0,0 +1,7 @@ + static-config ? $type_text['overview'] = "Overview"; @@ -77,6 +89,10 @@ $type_text['snr'] = "SNR"; $type_text['pressure'] = "Pressure"; $type_text['cooling'] = "Cooling"; $type_text['toner'] = 'Toner'; +$type_text['delay'] = 'Delay'; +$type_text['quality_factor'] = 'Quality factor'; +$type_text['chromatic_dispersion'] = 'Chromatic Dispersion'; +$type_text['ber'] = 'Bit Error Rate'; if (!$vars['metric']) { $vars['metric'] = "processor"; diff --git a/html/pages/health/ber.inc.php b/html/pages/health/ber.inc.php new file mode 100644 index 0000000000..7eae9c6109 --- /dev/null +++ b/html/pages/health/ber.inc.php @@ -0,0 +1,7 @@ + + * 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 + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + *tis*/ + +echo 'JunOS '; + +$multiplier = 1; +$divisor = 1; +foreach ($pre_cache['junos_ifotn_oids'] as $index => $entry) { + if (is_numeric($entry['jnxoptIfOTNPMCurrentFECBERMantissa'])) { + $index = substr_replace($index, '', -2); + $oid = '.1.3.6.1.4.1.2636.3.73.1.3.3.8.1.5.'.$index.'.1'; + $interface = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', array($index, $device['device_id'])); + $descr = $interface . ' preFEC BER'; + + $limit_low = null; + $warn_limit_low = null; + $limit = null; + $warn_limit = null; + $tmp_exp = $pre_cache['junos_ifotn_oids'][$index.".1"]['jnxoptIfOTNPMCurrentFECBERExponent']; + $current = ($entry['jnxoptIfOTNPMCurrentFECBERMantissa']/100)*pow(10, (-$tmp_exp)); + $entPhysicalIndex = $index; + $entPhysicalIndex_measured = 'ports'; + discover_sensor($valid['sensor'], 'ber', $device, $oid, $index, 'junos', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured); + } +} diff --git a/includes/discovery/sensors/current/junos.inc.php b/includes/discovery/sensors/current/junos.inc.php index 1f4aab61db..f5edc21139 100644 --- a/includes/discovery/sensors/current/junos.inc.php +++ b/includes/discovery/sensors/current/junos.inc.php @@ -17,7 +17,7 @@ $divisor = 1000000; foreach ($pre_cache['junos_oids'] as $index => $entry) { if (is_numeric($entry['jnxDomCurrentTxLaserBiasCurrent']) && $entry['jnxDomCurrentTxLaserBiasCurrent'] != 0 && $entry['jnxDomCurrentTxLaserBiasCurrentLowAlarmThreshold'] != 0) { $oid = '.1.3.6.1.4.1.2636.3.60.1.1.1.1.6.' . $index; - $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' Rx Current'; + $descr = dbFetchCell('SELECT `ifDescr` FROM `ports` WHERE `ifIndex`= ? AND `device_id` = ?', array($index, $device['device_id'])) . ' Tx Current'; $limit_low = $entry['jnxDomCurrentTxLaserBiasCurrentLowAlarmThreshold'] / $divisor; $warn_limit_low = $entry['jnxDomCurrentTxLaserBiasCurrentLowWarningThreshold'] / $divisor; $limit = $entry['jnxDomCurrentTxLaserBiasCurrentHighAlarmThreshold'] / $divisor; diff --git a/includes/discovery/sensors/pre-cache/junos.inc.php b/includes/discovery/sensors/pre-cache/junos.inc.php index 97e4809313..f21737ac54 100644 --- a/includes/discovery/sensors/pre-cache/junos.inc.php +++ b/includes/discovery/sensors/pre-cache/junos.inc.php @@ -15,3 +15,9 @@ $pre_cache['junos_oids'] = snmpwalk_cache_multi_oid($device, 'JnxDomCurrentEntry echo 'JnxDomCurrentLaneEntry '; $pre_cache['junos_multilane_oids'] = snmpwalk_cache_multi_oid($device, 'JnxDomCurrentLaneEntry', array(), 'JUNIPER-DOM-MIB', 'junos'); + +echo 'jnxoptIfOTNPMFECCurrentTable'; +$pre_cache['junos_ifotn_oids'] = snmpwalk_cache_multi_oid($device, 'jnxoptIfOTNPMFECCurrentTable', array(), 'JNX-OPT-IF-EXT-MIB', 'junos', '-OQUsb'); + +echo 'JnxoptIfOTNPMFECCurrentEntry '; +$pre_cache['junos_prefec_oids'] = snmpwalk_cache_multi_oid($device, 'jnxoptIfOTNPMCurrentFECMinBERMantissa', array(), 'JNX-OPT-IF-EXT-MIB', 'junos'); diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index 324d7ca326..095ae877af 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -166,7 +166,8 @@ function record_sensor_data($device, $all_sensors) } $rrd_name = get_sensor_rrd_name($device, $sensor); - $rrd_def = RrdDefinition::make()->addDataset('sensor', 'GAUGE', -20000, 20000); + + $rrd_def = RrdDefinition::make()->addDataset('sensor', 'GAUGE'); echo "$sensor_value $unit\n"; diff --git a/includes/polling/sensors/ber/junos.inc.php b/includes/polling/sensors/ber/junos.inc.php new file mode 100644 index 0000000000..3d8e9902e1 --- /dev/null +++ b/includes/polling/sensors/ber/junos.inc.php @@ -0,0 +1,9 @@ +