From d8097b0c218513cce4d0a265ce548878b661cc3c Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 2 Sep 2024 22:26:02 -0500 Subject: [PATCH] awplus sensor fixes (#16348) * awplus sensor fixes * Update test data --- .../discovery/sensors/current/awplus.inc.php | 4 +- includes/discovery/sensors/dbm/awplus.inc.php | 8 +-- .../sensors/temperature/awplus.inc.php | 4 +- .../discovery/sensors/voltage/awplus.inc.php | 4 +- includes/polling/ntp/awplus.inc.php | 8 +-- tests/data/awplus_sfp.json | 56 +++++++++---------- 6 files changed, 42 insertions(+), 42 deletions(-) diff --git a/includes/discovery/sensors/current/awplus.inc.php b/includes/discovery/sensors/current/awplus.inc.php index 902ef50cbf..d71be42914 100644 --- a/includes/discovery/sensors/current/awplus.inc.php +++ b/includes/discovery/sensors/current/awplus.inc.php @@ -23,12 +23,12 @@ if ($pre_cache['awplus-sfpddm']) { 'atPluggableDiagTxBiasStatusReading', 'SFP:' . $descr, $divisor, - null, // $multiplier, + 1, $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, - $value, + $data['atPluggableDiagTxBiasStatusReading'] / $divisor, 'snmp', $ifIndex, null, diff --git a/includes/discovery/sensors/dbm/awplus.inc.php b/includes/discovery/sensors/dbm/awplus.inc.php index 2a6d42793d..005553963d 100644 --- a/includes/discovery/sensors/dbm/awplus.inc.php +++ b/includes/discovery/sensors/dbm/awplus.inc.php @@ -23,12 +23,12 @@ if ($pre_cache['awplus-sfpddm']) { 'atPluggableDiagTxPowerStatusReading', 'SFP:' . $descr, $divisor, - null, // $multiplier, + 1, $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, - $value, + $data['atPluggableDiagTxPowerStatusReading'] / $divisor, 'snmp', $ifIndex, null, @@ -59,12 +59,12 @@ if ($pre_cache['awplus-sfpddm']) { 'atPluggableDiagRxPowerStatusReading', 'SFP:' . $descr, $divisor, - null, // $multiplier, + 1, $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, - $value, + $data['atPluggableDiagRxPowerStatusReading'] / $divisor, 'snmp', $ifIndex, null, diff --git a/includes/discovery/sensors/temperature/awplus.inc.php b/includes/discovery/sensors/temperature/awplus.inc.php index 5aa8490661..f62d3dc792 100644 --- a/includes/discovery/sensors/temperature/awplus.inc.php +++ b/includes/discovery/sensors/temperature/awplus.inc.php @@ -23,12 +23,12 @@ if ($pre_cache['awplus-sfpddm']) { 'atPluggableDiagTempStatusReading', 'SFP:' . $descr, $divisor, - null, // $multiplier, + 1, $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, - $value, + $data['atPluggableDiagTempStatusReading'] / $divisor, 'snmp', $ifIndex, null, diff --git a/includes/discovery/sensors/voltage/awplus.inc.php b/includes/discovery/sensors/voltage/awplus.inc.php index 9c9f3ded33..cc9d671c7a 100644 --- a/includes/discovery/sensors/voltage/awplus.inc.php +++ b/includes/discovery/sensors/voltage/awplus.inc.php @@ -23,12 +23,12 @@ if ($pre_cache['awplus-sfpddm']) { 'atPluggableDiagVccStatusReading', 'SFP:' . $descr, $divisor, - null, // $multiplier, + 1, $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, - $value, + $data['atPluggableDiagVccStatusReading'] / $divisor, 'snmp', $ifIndex, null, diff --git a/includes/polling/ntp/awplus.inc.php b/includes/polling/ntp/awplus.inc.php index 2497a832c6..bbc4ced27f 100644 --- a/includes/polling/ntp/awplus.inc.php +++ b/includes/polling/ntp/awplus.inc.php @@ -13,11 +13,11 @@ use LibreNMS\RRD\RrdDefinition; -$tmp_module = 'ntp'; +$type = 'ntp'; $component = new LibreNMS\Component(); $options = []; -$options['filter']['type'] = ['=', $tmp_module]; +$options['filter']['type'] = ['=', $type]; $options['filter']['disabled'] = ['=', 0]; $options['filter']['ignore'] = ['=', 0]; @@ -60,7 +60,7 @@ if ($components) { $rrd['delay'] = str_replace(' milliseconds', '', $rrd['delay']); $rrd['delay'] = $rrd['delay'] / 1000; // Convert to seconds $rrd['dispersion'] = $atNtpAssociationEntry[$array['UID']]['atNtpAssociationDisp']; - $tags = compact('ntp', 'rrd_name', 'rrd_def', 'peer'); + $tags = compact('type', 'rrd_name', 'rrd_def', 'peer'); data_update($device, 'ntp', $tags, $rrd); // Let's print some debugging info. @@ -81,4 +81,4 @@ if ($components) { } // end if count components // Clean-up after yourself! -unset($type, $components, $component, $options, $tmp_module); +unset($type, $components, $component, $options, $type); diff --git a/tests/data/awplus_sfp.json b/tests/data/awplus_sfp.json index e33fe40ffe..41016fb571 100644 --- a/tests/data/awplus_sfp.json +++ b/tests/data/awplus_sfp.json @@ -12,8 +12,8 @@ "sensor_descr": "SFP:", "group": "SFP", "sensor_divisor": 1000000, - "sensor_multiplier": 0, - "sensor_current": 0, + "sensor_multiplier": 1, + "sensor_current": 0.041124, "sensor_limit": null, "sensor_limit_warn": null, "sensor_limit_low": null, @@ -37,8 +37,8 @@ "sensor_descr": "SFP:", "group": "RX Power", "sensor_divisor": 10000, - "sensor_multiplier": 0, - "sensor_current": 0, + "sensor_multiplier": 1, + "sensor_current": 0.0092, "sensor_limit": null, "sensor_limit_warn": null, "sensor_limit_low": null, @@ -62,8 +62,8 @@ "sensor_descr": "SFP:", "group": "TX Power", "sensor_divisor": 10000, - "sensor_multiplier": 0, - "sensor_current": 0, + "sensor_multiplier": 1, + "sensor_current": 0.5738, "sensor_limit": null, "sensor_limit_warn": null, "sensor_limit_low": null, @@ -312,11 +312,11 @@ "sensor_descr": "SFP:", "group": "SFP Temperature", "sensor_divisor": 1000, - "sensor_multiplier": 0, - "sensor_current": 0, - "sensor_limit": 20, + "sensor_multiplier": 1, + "sensor_current": 57.984, + "sensor_limit": 77.984, "sensor_limit_warn": null, - "sensor_limit_low": -10, + "sensor_limit_low": 47.984, "sensor_limit_low_warn": null, "sensor_alert": 1, "sensor_custom": "No", @@ -387,11 +387,11 @@ "sensor_descr": "SFP:", "group": "SFP", "sensor_divisor": 10000, - "sensor_multiplier": 0, - "sensor_current": 0, - "sensor_limit": 0, + "sensor_multiplier": 1, + "sensor_current": 3.3065, + "sensor_limit": 3.802475, "sensor_limit_warn": null, - "sensor_limit_low": 0, + "sensor_limit_low": 2.810525, "sensor_limit_low_warn": null, "sensor_alert": 1, "sensor_custom": "No", @@ -606,7 +606,7 @@ "sensor_descr": "SFP:", "group": "SFP", "sensor_divisor": 1000000, - "sensor_multiplier": 0, + "sensor_multiplier": 1, "sensor_current": 0.041124, "sensor_limit": null, "sensor_limit_warn": null, @@ -616,7 +616,7 @@ "sensor_custom": "No", "entPhysicalIndex": "5028", "entPhysicalIndex_measured": null, - "sensor_prev": 0, + "sensor_prev": null, "user_func": null, "rrd_type": "GAUGE", "state_name": null @@ -631,7 +631,7 @@ "sensor_descr": "SFP:", "group": "RX Power", "sensor_divisor": 10000, - "sensor_multiplier": 0, + "sensor_multiplier": 1, "sensor_current": -20.362121726544, "sensor_limit": null, "sensor_limit_warn": null, @@ -641,7 +641,7 @@ "sensor_custom": "No", "entPhysicalIndex": "5028", "entPhysicalIndex_measured": null, - "sensor_prev": 0, + "sensor_prev": 0.0092, "user_func": "mw_to_dbm", "rrd_type": "GAUGE", "state_name": null @@ -656,7 +656,7 @@ "sensor_descr": "SFP:", "group": "TX Power", "sensor_divisor": 10000, - "sensor_multiplier": 0, + "sensor_multiplier": 1, "sensor_current": -2.4123945609002, "sensor_limit": null, "sensor_limit_warn": null, @@ -666,7 +666,7 @@ "sensor_custom": "No", "entPhysicalIndex": "5028", "entPhysicalIndex_measured": null, - "sensor_prev": 0, + "sensor_prev": 0.5738, "user_func": "mw_to_dbm", "rrd_type": "GAUGE", "state_name": null @@ -906,17 +906,17 @@ "sensor_descr": "SFP:", "group": "SFP Temperature", "sensor_divisor": 1000, - "sensor_multiplier": 0, + "sensor_multiplier": 1, "sensor_current": 57.984, - "sensor_limit": 20, + "sensor_limit": 77.984, "sensor_limit_warn": null, - "sensor_limit_low": -10, + "sensor_limit_low": 47.984, "sensor_limit_low_warn": null, "sensor_alert": 1, "sensor_custom": "No", "entPhysicalIndex": "5028", "entPhysicalIndex_measured": null, - "sensor_prev": 0, + "sensor_prev": null, "user_func": null, "rrd_type": "GAUGE", "state_name": null @@ -981,17 +981,17 @@ "sensor_descr": "SFP:", "group": "SFP", "sensor_divisor": 10000, - "sensor_multiplier": 0, + "sensor_multiplier": 1, "sensor_current": 3.3065, - "sensor_limit": 0, + "sensor_limit": 3.802475, "sensor_limit_warn": null, - "sensor_limit_low": 0, + "sensor_limit_low": 2.810525, "sensor_limit_low_warn": null, "sensor_alert": 1, "sensor_custom": "No", "entPhysicalIndex": "5028", "entPhysicalIndex_measured": null, - "sensor_prev": 0, + "sensor_prev": null, "user_func": null, "rrd_type": "GAUGE", "state_name": null