Merge pull request #127 from M0r13n/main

feat: adds additional metrics for DHCP
This commit is contained in:
Arseniy Kuznetsov
2024-03-31 08:18:22 +02:00
committed by GitHub
2 changed files with 14 additions and 17 deletions

View File

@@ -25,7 +25,7 @@ class DHCPCollector(BaseCollector):
if not router_entry.config_entry.dhcp:
return
dhcp_lease_labels = ['active_address', 'address', 'mac_address', 'host_name', 'comment', 'server', 'expires_after']
dhcp_lease_labels = ['active_address', 'address', 'mac_address', 'host_name', 'comment', 'server', 'expires_after', 'client_id', 'active_mac_address']
dhcp_lease_records = DHCPMetricsDataSource.metric_records(router_entry, metric_labels = dhcp_lease_labels)
if dhcp_lease_records:
# calculate number of leases per DHCP server
@@ -56,4 +56,3 @@ class DHCPCollector(BaseCollector):
#if router_entry.config_entry.dhcp_lease:
# dhcp_lease_metrics = BaseCollector.info_collector('dhcp_lease', 'DHCP Active Leases', dhcp_lease_records, dhcp_lease_labels)
# yield dhcp_lease_metrics

View File

@@ -22,7 +22,7 @@ class DHCPMetricsDataSource:
@staticmethod
def metric_records(router_entry, *, metric_labels = None, add_router_id = True, dhcp_cache = True, translate = True, bound = False):
if metric_labels is None or dhcp_cache:
metric_labels = ['host_name', 'comment', 'active_address', 'address', 'mac_address', 'server', 'expires_after']
metric_labels = ['host_name', 'comment', 'active_address', 'address', 'mac_address', 'server', 'expires_after', 'client_id', 'active_mac_address']
if dhcp_cache and router_entry.dhcp_records:
return router_entry.dhcp_records
@@ -51,5 +51,3 @@ class DHCPMetricsDataSource:
except Exception as exc:
print(f'Error getting dhcp info from router{router_entry.router_name}@{router_entry.config_entry.hostname}: {exc}')
return None