-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial support for EoIP, GRE and IPIP
- Loading branch information
Showing
8 changed files
with
208 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# coding=utf8 | ||
## Copyright (c) 2024 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.interface_ds import InterfaceMetricsDataSource | ||
from mktxp.utils.utils import parse_mkt_uptime | ||
|
||
|
||
class EOIPCollector(BaseCollector): | ||
''' EoIP Metrics collector | ||
''' | ||
@staticmethod | ||
def collect(router_entry): | ||
if not router_entry.config_entry.eoip: | ||
return | ||
|
||
default_labels = ['name', 'local_address', 'remote_address', 'tunnel_id'] | ||
translation_table = { | ||
'running': lambda value: '1' if value == 'true' else '0', | ||
'disabled': lambda value: '1' if value == 'true' else '0' | ||
} | ||
monitor_records = InterfaceMetricsDataSource.metric_records( | ||
router_entry, | ||
kind='eoip', | ||
additional_proplist=['actual-mtu', 'l2mtu', 'local-address', 'mtu', 'remote-address', 'tunnel-id'], | ||
translation_table=translation_table | ||
) | ||
|
||
if monitor_records: | ||
yield BaseCollector.gauge_collector('interface_status', | ||
'Current status of the interface', | ||
monitor_records, | ||
metric_key='running', | ||
metric_labels=default_labels + ['disabled']) | ||
|
||
yield BaseCollector.gauge_collector('interface_l2mtu', | ||
'Current used layer 2 mtu for this interface', | ||
monitor_records, | ||
metric_key='actual_mtu', | ||
metric_labels=default_labels) | ||
|
||
yield BaseCollector.gauge_collector('interface_mtu', | ||
'Current used mut for this interface', | ||
monitor_records, | ||
metric_key='actual_mtu', | ||
metric_labels=default_labels + ['mtu']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# coding=utf8 | ||
## Copyright (c) 2024 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.interface_ds import InterfaceMetricsDataSource | ||
from mktxp.utils.utils import parse_mkt_uptime | ||
|
||
|
||
class GRECollector(BaseCollector): | ||
''' GRE Metrics collector | ||
''' | ||
@staticmethod | ||
def collect(router_entry): | ||
if not router_entry.config_entry.gre: | ||
return | ||
|
||
default_labels = ['name', 'local_address', 'remote_address'] | ||
translation_table = { | ||
'running': lambda value: '1' if value == 'true' else '0', | ||
'disabled': lambda value: '1' if value == 'true' else '0' | ||
} | ||
monitor_records = InterfaceMetricsDataSource.metric_records( | ||
router_entry, | ||
kind='gre', | ||
additional_proplist=['mtu', 'actual-mtu', 'local-address', 'remote-address'], | ||
translation_table=translation_table | ||
) | ||
|
||
if monitor_records: | ||
yield BaseCollector.gauge_collector('interface_status', | ||
'Current status of the interface', | ||
monitor_records, | ||
metric_key='running', | ||
metric_labels=default_labels + ['disabled']) | ||
|
||
yield BaseCollector.gauge_collector('interface_mtu', | ||
'Current used MTU for this interface', | ||
monitor_records, | ||
metric_key='actual_mtu', | ||
metric_labels=default_labels + ['mtu']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# coding=utf8 | ||
## Copyright (c) 2024 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.interface_ds import InterfaceMetricsDataSource | ||
from mktxp.utils.utils import parse_mkt_uptime | ||
|
||
|
||
class IPIPCollector(BaseCollector): | ||
''' IPIP Metrics collector | ||
''' | ||
@staticmethod | ||
def collect(router_entry): | ||
if not router_entry.config_entry.ipip: | ||
return | ||
|
||
default_labels = ['name', 'local_address', 'remote_address'] | ||
translation_table = { | ||
'running': lambda value: '1' if value == 'true' else '0', | ||
'disabled': lambda value: '1' if value == 'true' else '0' | ||
} | ||
interface_records = InterfaceMetricsDataSource.metric_records( | ||
router_entry, | ||
kind='ipip', | ||
additional_proplist=['mtu', 'actual-mtu', 'local-address', 'remote-address'], | ||
translation_table=translation_table | ||
) | ||
|
||
if interface_records: | ||
yield BaseCollector.gauge_collector('interface_status', | ||
'Current status of the interface', | ||
interface_records, | ||
metric_key='running', | ||
metric_labels=default_labels + ['disabled']) | ||
|
||
yield BaseCollector.gauge_collector('interface_mtu', | ||
'Current used MTU for this interface', | ||
interface_records, | ||
metric_key='actual_mtu', | ||
metric_labels=default_labels + ['mtu']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters