From 01ded0f4978c36a5c88af05dc6a105035f633b91 Mon Sep 17 00:00:00 2001 From: Arseniy Kuznetsov Date: Tue, 17 Jan 2023 08:21:34 +0100 Subject: [PATCH] fixes/optimizations --- mktxp/collector/capsman_collector.py | 3 +-- mktxp/collector/wlan_collector.py | 1 - mktxp/flow/collector_handler.py | 4 ++-- mktxp/flow/router_entry.py | 12 +++++------- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/mktxp/collector/capsman_collector.py b/mktxp/collector/capsman_collector.py index caf7fba..b514b84 100644 --- a/mktxp/collector/capsman_collector.py +++ b/mktxp/collector/capsman_collector.py @@ -29,13 +29,12 @@ class CapsmanCollector(BaseCollector): return remote_caps_labels = ['identity', 'version', 'base_mac', 'board', 'base_mac'] - router_entry.wifi_package = None remote_caps_records = CapsmanCapsMetricsDataSource.metric_records(router_entry, metric_labels = remote_caps_labels) if remote_caps_records: remote_caps_metrics = BaseCollector.info_collector('capsman_remote_caps', 'CAPsMAN remote caps', remote_caps_records, remote_caps_labels) yield remote_caps_metrics - registration_labels = ['interface', 'ssid', 'mac_address', 'tx_rate', 'rx_rate', 'rx_signal', 'signal','uptime', 'bytes'] + registration_labels = ['interface', 'ssid', 'mac_address', 'tx_rate', 'rx_rate', 'rx_signal', 'signal', 'uptime', 'bytes'] registration_records = CapsmanRegistrationsMetricsDataSource.metric_records(router_entry, metric_labels = registration_labels) if registration_records: # calculate number of registrations per interface diff --git a/mktxp/collector/wlan_collector.py b/mktxp/collector/wlan_collector.py index 47ecbce..d342567 100644 --- a/mktxp/collector/wlan_collector.py +++ b/mktxp/collector/wlan_collector.py @@ -28,7 +28,6 @@ class WLANCollector(BaseCollector): return monitor_labels = ['channel', 'noise_floor', 'overall_tx_ccq', 'registered_clients', 'registered_peers'] - router_entry.wifi_package = None monitor_records = InterfaceMonitorMetricsDataSource.metric_records(router_entry, metric_labels = monitor_labels, kind = WirelessMetricsDataSource.wireless_package(router_entry)) if monitor_records: # sanitize records for relevant labels diff --git a/mktxp/flow/collector_handler.py b/mktxp/flow/collector_handler.py index e06aceb..b4a58e9 100644 --- a/mktxp/flow/collector_handler.py +++ b/mktxp/flow/collector_handler.py @@ -35,7 +35,7 @@ class CollectorHandler: Thus, the total runtime of this function scales linearly with the number of registered routers. """ for router_entry in self.entries_handler.router_entries: - if not router_entry.is_connected(): + if not router_entry.is_ready(): # let's pick up on things in the next run continue @@ -87,7 +87,7 @@ class CollectorHandler: print(f'Hit overall timeout while scraping router entry: {router_entry.router_id[MKTXPConfigKeys.ROUTERBOARD_NAME]}') break - if not router_entry.is_connected(): + if not router_entry.is_ready(): # let's pick up on things in the next run continue diff --git a/mktxp/flow/router_entry.py b/mktxp/flow/router_entry.py index b501610..f074090 100644 --- a/mktxp/flow/router_entry.py +++ b/mktxp/flow/router_entry.py @@ -54,16 +54,14 @@ class RouterEntry: 'MKTXPCollector': 0 } - def is_connected(self): - connected = True + def is_ready(self): + is_ready = True + self.wifi_package = None if not self.api_connection.is_connected(): - connected = False + is_ready = False # let's get connected now self.api_connection.connect() if self.dhcp_entry: self.dhcp_entry.api_connection.connect() - return connected - - - + return is_ready