diff --git a/tools/cmk-plugins/wifi_intefaces/agent_based/wifi_interfaces.py b/tools/cmk-plugins/wifi_intefaces/agent_based/wifi_interfaces.py index 090ecc0..095929e 100644 --- a/tools/cmk-plugins/wifi_intefaces/agent_based/wifi_interfaces.py +++ b/tools/cmk-plugins/wifi_intefaces/agent_based/wifi_interfaces.py @@ -2,10 +2,13 @@ from .agent_based_api.v1 import * -def check_wifi_status(item, section): - print(item) - print(section) +def __try_parse_int(val: str, default: int) -> int: + try: + return int(val) + except ValueError: + return default +def check_wifi_status(item, section): for interface in section: if interface['name'] == item: usage = interface['delta_ch_time_busy'] / interface['delta_ch_time'] * 100 @@ -23,7 +26,6 @@ def check_wifi_status(item, section): yield Result(state = State.CRIT, summary = f"Clients: {interface['client_count']}, Channel usage: {usage:.02f}%") def discover_wifi_status(section): - print(section) for interface in section: yield Service(item=interface['name']) @@ -34,8 +36,8 @@ def parse_wifi_interfaces(string_table): 'ch_time' : int(row[1]), 'ch_time_busy' : int(row[2]), 'noise' : int(row[3]), - 'delta_ch_time' : int(row[4]), - 'delta_ch_time_busy' : int(row[5]), + 'delta_ch_time' : __try_parse_int(row[4], 1), + 'delta_ch_time_busy' : __try_parse_int(row[5], 0), 'client_count' : int(row[6]), } for row in string_table] diff --git a/tools/cmk-plugins/wifi_intefaces/build.py b/tools/cmk-plugins/wifi_intefaces/build.py index 56c9f67..aad1c27 100755 --- a/tools/cmk-plugins/wifi_intefaces/build.py +++ b/tools/cmk-plugins/wifi_intefaces/build.py @@ -7,7 +7,7 @@ mkp.dist({'author': 'Albert Stefanov ', 'name': 'wifi_interfaces', 'title': 'OpenWRT Wi-Fi Interfaces', 'download_url': 'https://github.com/openfest/openfest-network-2023', - 'version': '0.0.2', + 'version': '0.0.3', 'version.min_required': '2.0.0', }, path='.') diff --git a/tools/cmk-plugins/wifi_intefaces/web/plugins/metrics/wifi_interfaces.py b/tools/cmk-plugins/wifi_intefaces/web/plugins/metrics/wifi_interfaces.py index 1454a22..3a6d854 100644 --- a/tools/cmk-plugins/wifi_intefaces/web/plugins/metrics/wifi_interfaces.py +++ b/tools/cmk-plugins/wifi_intefaces/web/plugins/metrics/wifi_interfaces.py @@ -69,7 +69,7 @@ graph_info["noise_floor"] = { graph_info["channel_times"] = { "title": _("Channel Times"), "metrics": [ - ("delta_ch_time", "stack"), - ("delta_ch_time_busy", "stack") + ("delta_ch_time", "line"), + ("delta_ch_time_busy", "area") ], -} +} \ No newline at end of file