mirror of
https://github.com/KevinMidboe/mktxp-no-cli.git
synced 2025-10-29 17:50:23 +00:00
kid control to monitor dynamic devices, optimisations/fixes
This commit is contained in:
@@ -19,12 +19,12 @@ class BGPMetricsDataSource:
|
||||
''' Wireless Metrics data provider
|
||||
'''
|
||||
@staticmethod
|
||||
def metric_records(router_entry, *, metric_labels = None, add_router_id = True):
|
||||
def metric_records(router_entry, *, metric_labels = None, translation_table = None):
|
||||
if metric_labels is None:
|
||||
metric_labels = []
|
||||
try:
|
||||
bgp_records = router_entry.api_connection.router_api().get_resource('/routing/bgp/session').get()
|
||||
return BaseDSProcessor.trimmed_records(router_entry, router_records = bgp_records, metric_labels = metric_labels, add_router_id = add_router_id)
|
||||
return BaseDSProcessor.trimmed_records(router_entry, router_records = bgp_records, metric_labels = metric_labels, translation_table = translation_table)
|
||||
except Exception as exc:
|
||||
print(f'Error getting BGP sessions info from router{router_entry.router_name}@{router_entry.config_entry.hostname}: {exc}')
|
||||
return None
|
||||
|
||||
@@ -34,7 +34,7 @@ class InterfaceMonitorMetricsDataSource:
|
||||
''' Interface Monitor Metrics data provider
|
||||
'''
|
||||
@staticmethod
|
||||
def metric_records(router_entry, *, metric_labels = None, kind = 'ethernet', include_comments = False, running_only = True):
|
||||
def metric_records(router_entry, *, metric_labels = None, translation_table = None, kind = 'ethernet', include_comments = False, running_only = True):
|
||||
if metric_labels is None:
|
||||
metric_labels = []
|
||||
try:
|
||||
@@ -60,7 +60,7 @@ class InterfaceMonitorMetricsDataSource:
|
||||
for interface_monitor_record in interface_monitor_records:
|
||||
if 'registered-peers' in interface_monitor_record:
|
||||
interface_monitor_record['registered-clients'] = interface_monitor_record['registered-peers']
|
||||
return BaseDSProcessor.trimmed_records(router_entry, router_records = interface_monitor_records, metric_labels = metric_labels)
|
||||
return BaseDSProcessor.trimmed_records(router_entry, router_records = interface_monitor_records, metric_labels = metric_labels, translation_table=translation_table)
|
||||
except Exception as exc:
|
||||
print(f'Error getting {kind} interface monitor info from router{router_entry.router_name}@{router_entry.config_entry.hostname}: {exc}')
|
||||
return None
|
||||
|
||||
@@ -20,16 +20,16 @@ class KidDeviceMetricsDataSource:
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def metric_records(router_entry, *, metric_labels=None):
|
||||
def metric_records(router_entry, *, metric_labels=None, translation_table = None):
|
||||
if metric_labels is None:
|
||||
metric_labels = []
|
||||
try:
|
||||
device_records = []
|
||||
records = router_entry.api_connection.router_api().get_resource('/ip/kid-control/device').get()
|
||||
for record in records:
|
||||
if record.get('user'):
|
||||
if record.get('user') or router_entry.config_entry.kid_control_dynamic:
|
||||
device_records.append(record)
|
||||
return BaseDSProcessor.trimmed_records(router_entry, router_records=device_records, metric_labels=metric_labels)
|
||||
return BaseDSProcessor.trimmed_records(router_entry, router_records=device_records, metric_labels=metric_labels, translation_table=translation_table)
|
||||
except Exception as exc:
|
||||
print(
|
||||
f'Error getting Kid-control device info from router{router_entry.router_name}@{router_entry.config_entry.hostname}: {exc}')
|
||||
|
||||
@@ -20,12 +20,12 @@ class SystemResourceMetricsDataSource:
|
||||
''' System Resource Metrics data provider
|
||||
'''
|
||||
@staticmethod
|
||||
def metric_records(router_entry, *, metric_labels = None):
|
||||
def metric_records(router_entry, *, metric_labels = None, translation_table=None):
|
||||
if metric_labels is None:
|
||||
metric_labels = []
|
||||
try:
|
||||
system_resource_records = router_entry.api_connection.router_api().get_resource('/system/resource').get()
|
||||
return BaseDSProcessor.trimmed_records(router_entry, router_records = system_resource_records, metric_labels = metric_labels)
|
||||
return BaseDSProcessor.trimmed_records(router_entry, router_records = system_resource_records, metric_labels = metric_labels, translation_table=translation_table)
|
||||
except Exception as exc:
|
||||
print(f'Error getting system resource info from router{router_entry.router_name}@{router_entry.config_entry.hostname}: {exc}')
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user