From ae6d475ce6798251c4fe033d535cd8a82282d5f7 Mon Sep 17 00:00:00 2001 From: Arseniy Kuznetsov Date: Sun, 20 Oct 2024 09:32:20 +0100 Subject: [PATCH] Routing stats metrics adjustments --- deploy/kubernetes/secret.yaml | 1 + mktxp/cli/config/config.py | 3 ++- mktxp/cli/config/mktxp.conf | 2 +- mktxp/collector/routing_stats_collector.py | 11 +++++++++++ mktxp/datasource/routing_stats_ds.py | 14 +++++++++++++- mktxp/flow/collector_registry.py | 2 +- 6 files changed, 29 insertions(+), 4 deletions(-) diff --git a/deploy/kubernetes/secret.yaml b/deploy/kubernetes/secret.yaml index e72d1bd..0b7ab9f 100644 --- a/deploy/kubernetes/secret.yaml +++ b/deploy/kubernetes/secret.yaml @@ -110,6 +110,7 @@ stringData: queue = True # Queues metrics bgp = False # BGP sessions metrics + routing_stats = False # Routing process stats certificate = False # Certificates metrics remote_dhcp_entry = None # An MKTXP entry to provide for remote DHCP info / resolution diff --git a/mktxp/cli/config/config.py b/mktxp/cli/config/config.py index d456267..a14b0bf 100755 --- a/mktxp/cli/config/config.py +++ b/mktxp/cli/config/config.py @@ -104,7 +104,6 @@ class MKTXPConfigKeys: FE_USER_KEY = 'user' FE_QUEUE_KEY = 'queue' FE_BGP_KEY = 'bgp' - FE_ROUTING_STATS_KEY = 'routing_stats' FE_REMOTE_DHCP_ENTRY = 'remote_dhcp_entry' FE_REMOTE_CAPSMAN_ENTRY = 'remote_capsman_entry' @@ -113,7 +112,9 @@ class MKTXPConfigKeys: FE_KID_CONTROL_DEVICE = 'kid_control_assigned' FE_KID_CONTROL_DYNAMIC = 'kid_control_dynamic' + FE_CERTIFICATE_KEY = 'certificate' + FE_ROUTING_STATS_KEY = 'routing_stats' MKTXP_SOCKET_TIMEOUT = 'socket_timeout' MKTXP_INITIAL_DELAY = 'initial_delay_on_failure' diff --git a/mktxp/cli/config/mktxp.conf b/mktxp/cli/config/mktxp.conf index ceb43e0..4143b7e 100644 --- a/mktxp/cli/config/mktxp.conf +++ b/mktxp/cli/config/mktxp.conf @@ -69,7 +69,7 @@ queue = True # Queues metrics bgp = False # BGP sessions metrics - routing_stats = False # routing process stats + routing_stats = False # Routing process stats certificate = False # Certificates metrics remote_dhcp_entry = None # An MKTXP entry to provide for remote DHCP info / resolution diff --git a/mktxp/collector/routing_stats_collector.py b/mktxp/collector/routing_stats_collector.py index 0862b4b..ac8be90 100644 --- a/mktxp/collector/routing_stats_collector.py +++ b/mktxp/collector/routing_stats_collector.py @@ -1,4 +1,15 @@ # 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.datasource.routing_stats_ds import RoutingStatsMetricsDataSource diff --git a/mktxp/datasource/routing_stats_ds.py b/mktxp/datasource/routing_stats_ds.py index 92abd69..46b3f4b 100644 --- a/mktxp/datasource/routing_stats_ds.py +++ b/mktxp/datasource/routing_stats_ds.py @@ -1,3 +1,15 @@ +# 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.datasource.base_ds import BaseDSProcessor from mktxp.datasource.system_resource_ds import SystemResourceMetricsDataSource @@ -17,7 +29,7 @@ def metric_records(router_entry, *, metric_labels = None, translation_table = No # legacy 6.x versions are untested ver = SystemResourceMetricsDataSource.os_version(router_entry) if not routerOS7_version(ver): - return + raise Exception("Routing stats for legacy 6.x versions are not supported at the moment") routing_stats_records = router_entry.api_connection.router_api().get_resource(routing_stats).get() return BaseDSProcessor.trimmed_records(router_entry, router_records = routing_stats_records, metric_labels = metric_labels, translation_table = translation_table) diff --git a/mktxp/flow/collector_registry.py b/mktxp/flow/collector_registry.py index bcd32ac..f9913cb 100644 --- a/mktxp/flow/collector_registry.py +++ b/mktxp/flow/collector_registry.py @@ -82,10 +82,10 @@ def __init__(self): self.register(CollectorKeys.KID_CONTROL_DEVICE_COLLECTOR, KidDeviceCollector.collect) self.register(CollectorKeys.BGP_COLLECTOR, BGPCollector.collect) - self.register(CollectorKeys.ROUTING_STATS_COLLECTOR, RoutingStatsCollector.collect) self.register(CollectorKeys.LTE_COLLECTOR, LTECollector.collect) self.register(CollectorKeys.SWITCH_PORT_COLLECTOR, SwitchPortCollector.collect) + self.register(CollectorKeys.ROUTING_STATS_COLLECTOR, RoutingStatsCollector.collect) self.register(CollectorKeys.CERTIFICATE_COLLECTOR, CertificateCollector.collect) self.register(CollectorKeys.MKTXP_COLLECTOR, MKTXPCollector.collect)