connections stats collector / cmd output, remote dhcp resolver, fixes / optimizations

This commit is contained in:
Arseniy Kuznetsov
2023-02-04 20:48:51 +01:00
parent 18ddbe3311
commit 9a381d028c
21 changed files with 351 additions and 161 deletions

View File

@@ -13,7 +13,8 @@
from mktxp.collector.base_collector import BaseCollector
from mktxp.datasource.connection_ds import IPConnectionDatasource
from mktxp.flow.processor.output import BaseOutputProcessor
from mktxp.datasource.connection_ds import IPConnectionDatasource, IPConnectionStatsDatasource
class IPConnectionCollector(BaseCollector):
@@ -21,11 +22,20 @@ class IPConnectionCollector(BaseCollector):
'''
@staticmethod
def collect(router_entry):
if not router_entry.config_entry.connections:
return
connection_records = IPConnectionDatasource.metric_records(router_entry)
if connection_records:
if router_entry.config_entry.connections:
connection_records = IPConnectionDatasource.metric_records(router_entry)
if connection_records:
connection_metrics = BaseCollector.gauge_collector('ip_connections_total', 'Number of IP connections', connection_records, 'count',)
yield connection_metrics
if router_entry.config_entry.connection_stats:
connection_stats_records = IPConnectionStatsDatasource.metric_records(router_entry)
for connection_stat_record in connection_stats_records:
BaseOutputProcessor.augment_record(router_entry, connection_stat_record, id_key = 'src_address')
connection_stats_labels = ['src_address', 'dst_addresses', 'dhcp_name']
connection_stats_metrics_gauge = BaseCollector.gauge_collector('connection_stats', 'Open connection stats',
connection_stats_records, 'connection_count', connection_stats_labels)
yield connection_stats_metrics_gauge
connection_metrics = BaseCollector.gauge_collector('ip_connections_total', 'Number of IP connections', connection_records, 'count',)
yield connection_metrics