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:
@@ -33,6 +33,9 @@ class BandwidthCollector(BaseCollector):
|
||||
self.last_call_timestamp = 0
|
||||
|
||||
def collect(self):
|
||||
if not config_handler.system_entry().bandwidth:
|
||||
return
|
||||
|
||||
if result_list:
|
||||
result_dict = result_list[0]
|
||||
bandwidth_records = [{'direction': key, 'bandwidth': str(result_dict[key])} for key in ('download', 'upload')]
|
||||
|
||||
@@ -25,7 +25,7 @@ class MonitorCollector(BaseCollector):
|
||||
if not router_entry.config_entry.monitor:
|
||||
return
|
||||
|
||||
monitor_labels = ('status', 'rate', 'full_duplex', 'name')
|
||||
monitor_labels = ['status', 'rate', 'full_duplex', 'name']
|
||||
monitor_records = InterfaceMonitorMetricsDataSource.metric_records(router_entry, metric_labels = monitor_labels, include_comments = True)
|
||||
if monitor_records:
|
||||
# translate records to appropriate values
|
||||
|
||||
34
mktxp/collector/poe_collector.py
Normal file
34
mktxp/collector/poe_collector.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# coding=utf8
|
||||
## 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.
|
||||
|
||||
|
||||
from mktxp.collector.base_collector import BaseCollector
|
||||
from mktxp.flow.processor.output import BaseOutputProcessor
|
||||
from mktxp.datasource.poe_ds import POEMetricsDataSource
|
||||
|
||||
|
||||
class POECollector(BaseCollector):
|
||||
''' POE Metrics collector
|
||||
'''
|
||||
@staticmethod
|
||||
def collect(router_entry):
|
||||
if not router_entry.config_entry.poe:
|
||||
return
|
||||
|
||||
poe_labels = ['name', 'poe_out', 'poe_priority', 'poe_voltage', 'poe_out_status', 'poe_out_voltage', 'poe_out_current', 'poe_out_power']
|
||||
poe_records = POEMetricsDataSource.metric_records(router_entry, include_comments = True, metric_labels = poe_labels)
|
||||
|
||||
if poe_records:
|
||||
poe_metrics = BaseCollector.info_collector('poe', 'POE Metrics', poe_records, poe_labels)
|
||||
yield poe_metrics
|
||||
|
||||
Reference in New Issue
Block a user