From af368727e2ad71d4a5128b6787e09cb6a359aa5f Mon Sep 17 00:00:00 2001 From: bugspencor Date: Mon, 4 Dec 2023 13:54:36 +0100 Subject: [PATCH] storcli.py: Skip battery backup unit status if it does not exist Some HPE RAID controllers have an external battery (Energy pack aka HPE Smart Storage Battery) instead of a controller onboard battery backup unit. With our controller (HPE MR416i-a Gen10+) the "BBU Status" field is not present in the storcli output and storcli.py aborts data collection. This commit skips the BBU Status field if it does not exist. Signed-off-by: bugspencor --- storcli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storcli.py b/storcli.py index 073b4a6..c474e9e 100755 --- a/storcli.py +++ b/storcli.py @@ -251,7 +251,7 @@ def handle_sas_controller(response): def handle_megaraid_controller(response): controller_index = response["Basics"]["Controller"] - if response["Status"]["BBU Status"] != "NA": + if "BBU Status" in response["Status"] and response["Status"]["BBU Status"] != "NA": # BBU Status Optimal value is 0 for normal, 8 for charging. metrics["bbu_healthy"].labels(controller_index).set( response["Status"]["BBU Status"] in [0, 8, 4096]