mirror of
https://github.com/KevinMidboe/mktxp-no-cli.git
synced 2025-10-29 09:40:23 +00:00
initial wifiwave2 capsman support
This commit is contained in:
32
mktxp/_mktxp.conf
Normal file
32
mktxp/_mktxp.conf
Normal file
@@ -0,0 +1,32 @@
|
||||
## Copyright (c) 2020 Arseniy Kuznetsov
|
||||
##
|
||||
## 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 2
|
||||
## of the License, or (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
|
||||
|
||||
[MKTXP]
|
||||
port = 49090
|
||||
socket_timeout = 2
|
||||
|
||||
initial_delay_on_failure = 120
|
||||
max_delay_on_failure = 900
|
||||
delay_inc_div = 5
|
||||
|
||||
bandwidth = True # Turns metrics bandwidth metrics collection on / off
|
||||
bandwidth_test_interval = 420 # Interval for colllecting bandwidth metrics
|
||||
minimal_collect_interval = 5 # Minimal metric collection interval
|
||||
|
||||
verbose_mode = False # Set it on for troubleshooting
|
||||
|
||||
fetch_routers_in_parallel = False # Set to True if you want to fetch multiple routers parallel
|
||||
max_worker_threads = 5 # Max number of worker threads that can fetch routers. Meaningless if fetch_routers_in_parallel is set to False
|
||||
|
||||
max_scrape_duration = 10 # Max duration of individual routers' metrics collection
|
||||
total_max_scrape_duration = 30 # Max overall duration of all metrics collection
|
||||
@@ -28,6 +28,7 @@ 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)
|
||||
|
||||
@@ -28,6 +28,7 @@ class WLANCollector(BaseCollector):
|
||||
return
|
||||
|
||||
monitor_labels = ['channel', 'noise_floor', 'overall_tx_ccq', 'registered_clients']
|
||||
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
|
||||
|
||||
@@ -13,6 +13,23 @@
|
||||
|
||||
|
||||
from mktxp.datasource.base_ds import BaseDSProcessor
|
||||
from mktxp.datasource.wireless_ds import WirelessMetricsDataSource
|
||||
|
||||
|
||||
class CapsmanInfo:
|
||||
@staticmethod
|
||||
def capsman_path(router_entry):
|
||||
if WirelessMetricsDataSource.wireless_package(router_entry) == WirelessMetricsDataSource.WIFIWAVE2:
|
||||
return '/interface/wifiwave2/capsman'
|
||||
else:
|
||||
return '/caps-man'
|
||||
|
||||
@staticmethod
|
||||
def registration_table_path(router_entry):
|
||||
if WirelessMetricsDataSource.wireless_package(router_entry) == WirelessMetricsDataSource.WIFIWAVE2:
|
||||
return '/interface/wifiwave2/registration-table'
|
||||
else:
|
||||
return '/caps-man/registration-table'
|
||||
|
||||
class CapsmanCapsMetricsDataSource:
|
||||
''' Caps Metrics data provider
|
||||
@@ -22,10 +39,11 @@ class CapsmanCapsMetricsDataSource:
|
||||
if metric_labels is None:
|
||||
metric_labels = []
|
||||
try:
|
||||
remote_caps_records = router_entry.api_connection.router_api().get_resource('/caps-man/remote-cap').get()
|
||||
capsman_path = CapsmanInfo.capsman_path(router_entry)
|
||||
remote_caps_records = router_entry.api_connection.router_api().get_resource(f'{capsman_path}/remote-cap').get()
|
||||
return BaseDSProcessor.trimmed_records(router_entry, router_records = remote_caps_records, metric_labels = metric_labels)
|
||||
except Exception as exc:
|
||||
print(f'Error getting caps-man remote caps info from router{router_entry.router_name}@{router_entry.config_entry.hostname}: {exc}')
|
||||
print(f'Error getting CAPsMAN remote caps info from router{router_entry.router_name}@{router_entry.config_entry.hostname}: {exc}')
|
||||
return None
|
||||
|
||||
|
||||
@@ -37,10 +55,11 @@ class CapsmanRegistrationsMetricsDataSource:
|
||||
if metric_labels is None:
|
||||
metric_labels = []
|
||||
try:
|
||||
registration_table_records = router_entry.api_connection.router_api().get_resource('/caps-man/registration-table').get()
|
||||
registration_table_path = CapsmanInfo.registration_table_path(router_entry)
|
||||
registration_table_records = router_entry.api_connection.router_api().get_resource(f'{registration_table_path}').get()
|
||||
return BaseDSProcessor.trimmed_records(router_entry, router_records = registration_table_records, metric_labels = metric_labels, add_router_id = add_router_id)
|
||||
except Exception as exc:
|
||||
print(f'Error getting caps-man registration table info from router{router_entry.router_name}@{router_entry.config_entry.hostname}: {exc}')
|
||||
print(f'Error getting CAPsMAN registration table info from router{router_entry.router_name}@{router_entry.config_entry.hostname}: {exc}')
|
||||
return None
|
||||
|
||||
|
||||
@@ -50,11 +69,13 @@ class CapsmanInterfacesDatasource:
|
||||
|
||||
@staticmethod
|
||||
def metric_records(router_entry, *, metric_labels = None):
|
||||
if WirelessMetricsDataSource.wireless_package(router_entry) == WirelessMetricsDataSource.WIFIWAVE2:
|
||||
return None
|
||||
if metric_labels is None:
|
||||
metric_labels = []
|
||||
try:
|
||||
caps_interfaces = router_entry.api_connection.router_api().get_resource('/caps-man/interface').get()
|
||||
return BaseDSProcessor.trimmed_records(router_entry, router_records = caps_interfaces, metric_labels = metric_labels)
|
||||
except Exception as exc:
|
||||
print(f'Error getting caps-man interfaces info from router{router_entry.router_name}@{router_entry.config_entry.hostname}: {exc}')
|
||||
print(f'Error getting CAPsMAN interfaces info from router{router_entry.router_name}@{router_entry.config_entry.hostname}: {exc}')
|
||||
return None
|
||||
|
||||
@@ -31,7 +31,7 @@ class PackageMetricsDataSource:
|
||||
|
||||
|
||||
@staticmethod
|
||||
def is_package_installed (router_entry, package_name = ''):
|
||||
def is_package_installed (router_entry, package_name = None):
|
||||
if package_name:
|
||||
try:
|
||||
package_records = router_entry.api_connection.router_api().get_resource('/system/package').get()
|
||||
|
||||
@@ -19,6 +19,10 @@ from mktxp.datasource.package_ds import PackageMetricsDataSource
|
||||
class WirelessMetricsDataSource:
|
||||
''' Wireless Metrics data provider
|
||||
'''
|
||||
WIFIWAVE2 = 'wifiwave2'
|
||||
WIRELESS = 'wireless'
|
||||
|
||||
|
||||
@staticmethod
|
||||
def metric_records(router_entry, *, metric_labels = None, add_router_id = True):
|
||||
if metric_labels is None:
|
||||
@@ -41,4 +45,7 @@ class WirelessMetricsDataSource:
|
||||
|
||||
@staticmethod
|
||||
def wireless_package(router_entry):
|
||||
return 'wifiwave2' if PackageMetricsDataSource.is_package_installed(router_entry, package_name = 'wifiwave2') else 'wireless'
|
||||
if not router_entry.wifi_package:
|
||||
ww2_installed = PackageMetricsDataSource.is_package_installed(router_entry, package_name = WirelessMetricsDataSource.WIFIWAVE2)
|
||||
router_entry.wifi_package = WirelessMetricsDataSource.WIFIWAVE2 if ww2_installed else WirelessMetricsDataSource.WIRELESS
|
||||
return router_entry.wifi_package
|
||||
|
||||
@@ -27,6 +27,7 @@ class RouterEntry:
|
||||
MKTXPConfigKeys.ROUTERBOARD_NAME: self.router_name,
|
||||
MKTXPConfigKeys.ROUTERBOARD_ADDRESS: self.config_entry.hostname
|
||||
}
|
||||
self.wifi_package = None
|
||||
self.time_spent = { 'IdentityCollector': 0,
|
||||
'SystemResourceCollector': 0,
|
||||
'HealthCollector': 0,
|
||||
|
||||
Reference in New Issue
Block a user