Skip to content

Commit

Permalink
More System/Health metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
akpw committed May 31, 2024
1 parent b6e233d commit 556a503
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 5 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ mktxp edit -i
verbose_mode = False # Set it on for troubleshooting
fetch_routers_in_parallel = False # Set to True if you want to fetch multiple routers in parallel
fetch_routers_in_parallel = False # Perform fetching metrics from multiple routers in parallel / sequentially
max_worker_threads = 5 # Max number of worker threads that can fetch routers (parallel fetch only)
max_scrape_duration = 10 # Max duration of individual routers' metrics collection (parallel fetch only)
total_max_scrape_duration = 30 # Max overall duration of all metrics collection (parallel fetch only)
Expand Down Expand Up @@ -296,7 +296,7 @@ While most of the [mktxp options](https://github.com/akpw/mktxp#getting-started)
### Remote DHCP resolution
When gathering various IP address-related metrics, MKTXP automatically resolves IP addresses whenever DHCP info is available. In many cases however, the exported devices do not have this information locally and instead rely on central DHCP servers. To improve readability / usefulness of the exported metrics, MKTXP supports remote DHCP server calls via the following option:
```
remote_dhcp_entry = None # An MKTXP entry for remote DHCP info resolution in capsman/wireless
remote_dhcp_entry = None # An MKTXP entry to provide for remote DHCP info / resolution
```
`MKTXP entry` in this context can be any other mktxp.conf entry, and for the sole purpose of providing DHCP info it does not even need to be enabled. An example:
```
Expand All @@ -307,6 +307,20 @@ remote_dhcp_entry = None # An MKTXP entry for remote DHCP info resolution
remote_dhcp_entry = RouterA # Will resolve via RouterA
```

### Remote CAPsMAN info
Similar to remote DHCP resolution, mktxp allows collecting CAPsMAN-related metrics via the following option:
```
remote_capsman_entry = None # An MKTXP entry to provide for remote capsman info
```
`MKTXP entry` in this context can be any other mktxp.conf entry, and for the sole purpose of collecting CAPsMAN-related metrics it does not even need to be enabled. An example:
```
[RouterA]
... # RouterA settings as normal
[RouterB]
remote_capsman_entry = RouterA # Will collect the CAPsMAN-related info via router A
```

### Connections stats
With many connected devices everywhere, one can often only guess where do they go to and what they actually do with all the information from your network environment. MKTXP let's you easily track those with a single option, with results available both from [mktxp dashboard](https://grafana.com/grafana/dashboards/13679-mikrotik-mktxp-exporter/) and the command line:

Expand Down
2 changes: 1 addition & 1 deletion mktxp/cli/config/_mktxp.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

verbose_mode = False # Set it on for troubleshooting

fetch_routers_in_parallel = False # Set to True if you want to fetch multiple routers parallel
fetch_routers_in_parallel = False # Perform fetching metrics from multiple routers in parallel / sequentially
max_worker_threads = 5 # Max number of worker threads that can fetch routers (parallel fetch only)
max_scrape_duration = 30 # Max duration of individual routers' metrics collection (parallel fetch only)
total_max_scrape_duration = 90 # Max overall duration of all metrics collection (parallel fetch only)
Expand Down
45 changes: 44 additions & 1 deletion mktxp/collector/health_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ class HealthCollector(BaseCollector):
'''
@staticmethod
def collect(router_entry):
health_labels = ['voltage', 'temperature', 'phy_temperature', 'cpu_temperature', 'switch_temperature', 'fan1_speed', 'fan2_speed', 'fan3_speed', 'fan4_speed', 'power_consumption']
health_labels = ['voltage', 'temperature', 'phy_temperature', 'cpu_temperature', 'switch_temperature',
'fan1_speed', 'fan2_speed', 'fan3_speed', 'fan4_speed', 'power_consumption', ' board_temperature1', 'board_temperature2',
'psu1_voltage', 'psu2_voltage', 'psu1_current', 'psu2_current', 'poe_out_consumption', 'jack_voltage', '2pin_voltage', 'poe_in_voltage', ]
health_records = HealthMetricsDataSource.metric_records(router_entry, metric_labels = health_labels)
if health_records:
for record in health_records:
Expand Down Expand Up @@ -63,3 +65,44 @@ def collect(router_entry):
if 'power_consumption' in record:
power_consumption_metrics = BaseCollector.gauge_collector('system_power_consumption', 'System Power Consumption', [record, ], 'power_consumption')
yield power_consumption_metrics

if 'board_temperature1' in record:
board_temperature1_metrics = BaseCollector.gauge_collector('system_board_temperature1', 'System board temperature 1', [record, ], 'board_temperature1')
yield board_temperature1_metrics

if 'board_temperature2' in record:
board_temperature2_metrics = BaseCollector.gauge_collector('system_board_temperature2', 'System board temperature 2', [record, ], 'board_temperature2')
yield board_temperature2_metrics

if 'psu1_voltage' in record:
psu1_voltage_metrics = BaseCollector.gauge_collector('system_psu1_voltage', 'System PSU1 voltage', [record, ], 'psu1_voltage')
yield psu1_voltage

if 'psu2_voltage' in record:
psu2_voltage_metrics = BaseCollector.gauge_collector('system_psu2_voltage', 'System PSU2 voltage', [record, ], 'psu2_voltage')
yield psu2_voltage_metrics

if 'psu1_current' in record:
psu1_current_metrics = BaseCollector.gauge_collector('system_psu1_current', 'System PSU1 current', [record, ], 'psu1_current')
yield psu1_current_metrics

if 'psu2_current' in record:
psu2_current_metrics = BaseCollector.gauge_collector('system_psu2_current', 'System PSU2 current', [record, ], 'psu2_current')
yield psu2_current_metrics

if 'poe_out_consumption' in record:
poe_out_consumption_metrics = BaseCollector.gauge_collector('system_poe_out_consumption', 'System POE-out consumption', [record, ], 'poe_out_consumption')
yield poe_out_consumption_metrics

if 'jack_voltage' in record:
jack_voltage_metrics = BaseCollector.gauge_collector('system_jack_voltage', 'System Jack Voltage', [record, ], 'jack_voltage')
yield jack_voltage_metrics

if '2pin_voltage' in record:
pin_voltage_metrics = BaseCollector.gauge_collector('system_2pin_voltage', 'System 2pin Voltage', [record, ], '2pin_voltage')
yield pin_voltage_metrics

if 'poe_in_voltage' in record:
poe_in_voltage_metrics = BaseCollector.gauge_collector('system_poe_in_voltage', 'System POE-in Voltage', [record, ], 'poe_in_voltage')
yield poe_in_voltage_metrics

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

setup(
name='mktxp',
version='1.2.7',
version='1.2.6',

url='https://github.com/akpw/mktxp',

Expand Down

0 comments on commit 556a503

Please sign in to comment.