From f663a574825b9f7ab51a563e0f91c4ec266f341f Mon Sep 17 00:00:00 2001 From: JaRo5493 <87316176+JaRo5493@users.noreply.github.com> Date: Fri, 11 Oct 2024 11:24:26 +0200 Subject: [PATCH 1/2] Fix Huawei WLC AP crash on offline APs Fix out-of-range access of aps_info2 when the Huawei WLC reports an AP that is offline or unavailable. --- cmk/base/legacy_checks/huawei_wlc_aps.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmk/base/legacy_checks/huawei_wlc_aps.py b/cmk/base/legacy_checks/huawei_wlc_aps.py index bf20f2ab90b..8871b67fd56 100644 --- a/cmk/base/legacy_checks/huawei_wlc_aps.py +++ b/cmk/base/legacy_checks/huawei_wlc_aps.py @@ -56,6 +56,11 @@ def parse_huawei_wlc_aps(string_table): # aps_info1 aps_info2 # [line] --> [2,4GHZ Info] # --> [5GHz Info] + + # Skip Access Points Reported by the Controller which have no Channel Information + if 2 * idx + 1 >= len(aps_info2): + continue + status, mem, cpu, temp, con_users = ap_info1 ap_id, radio_state_2GHz, ch_usage_2GHz, users_online_2GHz = aps_info2[2 * idx] _ap_id, radio_state_5GHz, ch_usage_5GHz, users_online_5GHz = aps_info2[2 * idx + 1] From 0d7e7fabeef4a4794efc1216db2b97ee8e93703a Mon Sep 17 00:00:00 2001 From: JaRo5493 <87316176+JaRo5493@users.noreply.github.com> Date: Fri, 8 Nov 2024 11:10:34 +0100 Subject: [PATCH 2/2] Change Logic to detect Offline Access Points --- cmk/base/legacy_checks/huawei_wlc_aps.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmk/base/legacy_checks/huawei_wlc_aps.py b/cmk/base/legacy_checks/huawei_wlc_aps.py index 8871b67fd56..4fea8c1f864 100644 --- a/cmk/base/legacy_checks/huawei_wlc_aps.py +++ b/cmk/base/legacy_checks/huawei_wlc_aps.py @@ -46,6 +46,10 @@ class StateTemplate(NamedTuple): def parse_huawei_wlc_aps(string_table): parsed = {} + # Filter Access Point Information from Offline Access Points + down_states = [key for key, value in ap_state_map.items() if value.value == 2] + string_table[0] = [line for line in string_table[0] if line[0] not in down_states] + aps_info1, aps_info2 = string_table # Access-Points @@ -56,10 +60,6 @@ def parse_huawei_wlc_aps(string_table): # aps_info1 aps_info2 # [line] --> [2,4GHZ Info] # --> [5GHz Info] - - # Skip Access Points Reported by the Controller which have no Channel Information - if 2 * idx + 1 >= len(aps_info2): - continue status, mem, cpu, temp, con_users = ap_info1 ap_id, radio_state_2GHz, ch_usage_2GHz, users_online_2GHz = aps_info2[2 * idx]