mirror of
https://github.com/KevinMidboe/mktxp-no-cli.git
synced 2025-10-29 17:50:23 +00:00
firewall/mktxp colllectors, fixes/optimizations
This commit is contained in:
@@ -21,61 +21,53 @@ class WLANCollector(BaseCollector):
|
||||
def collect(router_metric):
|
||||
monitor_labels = ['channel', 'noise_floor', 'overall_tx_ccq', 'registered_clients']
|
||||
monitor_records = router_metric.interface_monitor_records(monitor_labels, 'wireless')
|
||||
if not monitor_records:
|
||||
return range(0)
|
||||
if monitor_records:
|
||||
# sanitize records for relevant labels
|
||||
noise_floor_records = [monitor_record for monitor_record in monitor_records if monitor_record.get('noise_floor')]
|
||||
tx_ccq_records = [monitor_record for monitor_record in monitor_records if monitor_record.get('overall_tx_ccq')]
|
||||
registered_clients_records = [monitor_record for monitor_record in monitor_records if monitor_record.get('registered_clients')]
|
||||
|
||||
# sanitize records for relevant labels
|
||||
noise_floor_records = [monitor_record for monitor_record in monitor_records if monitor_record.get('noise_floor')]
|
||||
tx_ccq_records = [monitor_record for monitor_record in monitor_records if monitor_record.get('overall_tx_ccq')]
|
||||
registered_clients_records = [monitor_record for monitor_record in monitor_records if monitor_record.get('registered_clients')]
|
||||
if noise_floor_records:
|
||||
noise_floor_metrics = BaseCollector.gauge_collector('wlan_noise_floor', 'Noise floor threshold', noise_floor_records, 'noise_floor', ['channel'])
|
||||
yield noise_floor_metrics
|
||||
|
||||
if noise_floor_records:
|
||||
noise_floor_metrics = BaseCollector.gauge_collector('wlan_noise_floor', 'Noise floor threshold', noise_floor_records, 'noise_floor', ['channel'])
|
||||
yield noise_floor_metrics
|
||||
|
||||
if tx_ccq_records:
|
||||
overall_tx_ccq_metrics = BaseCollector.gauge_collector('wlan_overall_tx_ccq', 'Client Connection Quality for transmitting', tx_ccq_records, 'overall_tx_ccq', ['channel'])
|
||||
yield overall_tx_ccq_metrics
|
||||
|
||||
if registered_clients_records:
|
||||
registered_clients_metrics = BaseCollector.gauge_collector('wlan_registered_clients', 'Number of registered clients', registered_clients_records, 'registered_clients', ['channel'])
|
||||
yield registered_clients_metrics
|
||||
if tx_ccq_records:
|
||||
overall_tx_ccq_metrics = BaseCollector.gauge_collector('wlan_overall_tx_ccq', 'Client Connection Quality for transmitting', tx_ccq_records, 'overall_tx_ccq', ['channel'])
|
||||
yield overall_tx_ccq_metrics
|
||||
|
||||
if registered_clients_records:
|
||||
registered_clients_metrics = BaseCollector.gauge_collector('wlan_registered_clients', 'Number of registered clients', registered_clients_records, 'registered_clients', ['channel'])
|
||||
yield registered_clients_metrics
|
||||
|
||||
# the client info metrics
|
||||
if router_metric.router_entry.wireless_clients:
|
||||
registration_labels = ['interface', 'ssid', 'mac_address', 'tx_rate', 'rx_rate', 'uptime', 'bytes', 'signal_to_noise', 'tx_ccq', 'signal_strength']
|
||||
registration_records = router_metric.wireless_registration_table_records(registration_labels)
|
||||
if not registration_records:
|
||||
return range(0)
|
||||
if registration_records:
|
||||
dhcp_lease_labels = ['mac_address', 'address', 'host_name', 'comment']
|
||||
dhcp_lease_records = router_metric.dhcp_lease_records(dhcp_lease_labels)
|
||||
|
||||
for registration_record in registration_records:
|
||||
BaseOutputProcessor.augment_record(router_metric, registration_record, dhcp_lease_records)
|
||||
|
||||
dhcp_lease_labels = ['mac_address', 'address', 'host_name', 'comment']
|
||||
dhcp_lease_records = router_metric.dhcp_lease_records(dhcp_lease_labels)
|
||||
|
||||
for registration_record in registration_records:
|
||||
BaseOutputProcessor.augment_record(router_metric, registration_record, dhcp_lease_records)
|
||||
tx_byte_metrics = BaseCollector.counter_collector('wlan_clients_tx_bytes', 'Number of sent packet bytes', registration_records, 'tx_bytes', ['dhcp_name'])
|
||||
yield tx_byte_metrics
|
||||
|
||||
tx_byte_metrics = BaseCollector.counter_collector('wlan_clients_tx_bytes', 'Number of sent packet bytes', registration_records, 'tx_bytes', ['dhcp_name'])
|
||||
yield tx_byte_metrics
|
||||
rx_byte_metrics = BaseCollector.counter_collector('wlan_clients_rx_bytes', 'Number of received packet bytes', registration_records, 'rx_bytes', ['dhcp_name'])
|
||||
yield rx_byte_metrics
|
||||
|
||||
rx_byte_metrics = BaseCollector.counter_collector('wlan_clients_rx_bytes', 'Number of received packet bytes', registration_records, 'rx_bytes', ['dhcp_name'])
|
||||
yield rx_byte_metrics
|
||||
signal_strength_metrics = BaseCollector.gauge_collector('wlan_clients_signal_strength', 'Average strength of the client signal recevied by AP', registration_records, 'signal_strength', ['dhcp_name'])
|
||||
yield signal_strength_metrics
|
||||
|
||||
signal_strength_metrics = BaseCollector.gauge_collector('wlan_clients_signal_strength', 'Average strength of the client signal recevied by AP', registration_records, 'signal_strength', ['dhcp_name'])
|
||||
yield signal_strength_metrics
|
||||
signal_to_noise_metrics = BaseCollector.gauge_collector('wlan_clients_signal_to_noise', 'Client devices signal to noise ratio', registration_records, 'signal_to_noise', ['dhcp_name'])
|
||||
yield signal_to_noise_metrics
|
||||
|
||||
signal_to_noise_metrics = BaseCollector.gauge_collector('wlan_clients_signal_to_noise', 'Client devices signal to noise ratio', registration_records, 'signal_to_noise', ['dhcp_name'])
|
||||
yield signal_to_noise_metrics
|
||||
tx_ccq_metrics = BaseCollector.gauge_collector('wlan_clients_tx_ccq', 'Client Connection Quality (CCQ) for transmit', registration_records, 'tx_ccq', ['dhcp_name'])
|
||||
yield tx_ccq_metrics
|
||||
|
||||
tx_ccq_metrics = BaseCollector.gauge_collector('wlan_clients_tx_ccq', 'Client Connection Quality (CCQ) for transmit', registration_records, 'tx_ccq', ['dhcp_name'])
|
||||
yield tx_ccq_metrics
|
||||
|
||||
registration_metrics = BaseCollector.info_collector('wlan_clients_devices', 'Client devices info',
|
||||
registration_records, ['dhcp_name', 'dhcp_address', 'rx_signal', 'ssid', 'tx_rate', 'rx_rate', 'interface', 'mac_address', 'uptime'])
|
||||
yield registration_metrics
|
||||
|
||||
|
||||
return range(0)
|
||||
registration_metrics = BaseCollector.info_collector('wlan_clients_devices', 'Client devices info',
|
||||
registration_records, ['dhcp_name', 'dhcp_address', 'rx_signal', 'ssid', 'tx_rate', 'rx_rate', 'interface', 'mac_address', 'uptime'])
|
||||
yield registration_metrics
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user