mirror of
https://github.com/KevinMidboe/mktxp-no-cli.git
synced 2025-10-29 17:50:23 +00:00
POE collector, bandwidth metrics on/off switch, fixes/optimizations
This commit is contained in:
@@ -18,12 +18,12 @@ class BaseDSProcessor:
|
||||
|
||||
@staticmethod
|
||||
def trimmed_records(router_entry, *, router_records = [], metric_labels = [], add_router_id = True, translation_table = {}):
|
||||
dash2_ = lambda x : x.replace('-', '_')
|
||||
if len(metric_labels) == 0 and len(router_records) > 0:
|
||||
metric_labels = router_records[0].keys()
|
||||
metric_labels = [dash2_(key) for key in router_records[0].keys()]
|
||||
metric_labels = set(metric_labels)
|
||||
|
||||
labeled_records = []
|
||||
dash2_ = lambda x : x.replace('-', '_')
|
||||
for router_record in router_records:
|
||||
translated_record = {dash2_(key): value for (key, value) in router_record.items() if dash2_(key) in metric_labels}
|
||||
|
||||
|
||||
@@ -23,18 +23,20 @@ class POEMetricsDataSource:
|
||||
try:
|
||||
poe_records = router_entry.api_connection.router_api().get_resource('/interface/ethernet/poe').get()
|
||||
for int_num, poe_record in enumerate(poe_records):
|
||||
poe_monitor_record = router_entry.api_connection.router_api().get_resource('/interface/ethernet/poe').call('monitor', {'once':'', 'numbers':f'{int_num}'})
|
||||
if poe_monitor_record[0].get('poe_out_status'):
|
||||
poe_record['poe_out_status'] = poe_monitor_record[0]['poe_out_status']
|
||||
poe_monitor_records = router_entry.api_connection.router_api().get_resource('/interface/ethernet/poe').call('monitor', {'once':'', 'numbers':f'{int_num}'})
|
||||
poe_monitor_records = BaseDSProcessor.trimmed_records(router_entry, router_records = poe_monitor_records)
|
||||
|
||||
if poe_monitor_record[0].get('poe_out_voltage'):
|
||||
poe_record['poe_out_voltage'] = poe_monitor_record[0]['poe_out_voltage']
|
||||
if poe_monitor_records[0].get('poe_out_status'):
|
||||
poe_record['poe_out_status'] = poe_monitor_records[0]['poe_out_status']
|
||||
|
||||
if poe_monitor_record[0].get('poe_out_current'):
|
||||
poe_record['poe_out_current'] = poe_monitor_record[0]['poe_out_current']
|
||||
if poe_monitor_records[0].get('poe_out_voltage'):
|
||||
poe_record['poe_out_voltage'] = poe_monitor_records[0]['poe_out_voltage']
|
||||
|
||||
if poe_monitor_record[0].get('poe_out_power'):
|
||||
poe_record['poe_out_power'] = poe_monitor_record[0]['poe_out_power']
|
||||
if poe_monitor_records[0].get('poe_out_current'):
|
||||
poe_record['poe_out_current'] = poe_monitor_records[0]['poe_out_current']
|
||||
|
||||
if poe_monitor_records[0].get('poe_out_power'):
|
||||
poe_record['poe_out_power'] = poe_monitor_records[0]['poe_out_power']
|
||||
|
||||
if include_comments:
|
||||
interfaces = router_entry.api_connection.router_api().get_resource('/interface/ethernet').get()
|
||||
|
||||
Reference in New Issue
Block a user