From 9370d8d186c71b6c302412ca2cf8b17b936d42d9 Mon Sep 17 00:00:00 2001 From: kr0m Date: Sat, 2 Sep 2023 22:11:00 +0200 Subject: [PATCH] Some disks doesnt report device speed correctly, when we assign pd_device_speed metric a string value: Unknown, script execution crashes, in that case assign a 0 speed value. Signed-off-by: kr0m --- storcli.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/storcli.py b/storcli.py index 16a4e98..7a096cc 100755 --- a/storcli.py +++ b/storcli.py @@ -353,9 +353,15 @@ def create_metrics_of_physical_drive(physical_drive, detailed_info_array, contro metrics["pd_link_speed"].labels(controller_index, enclosure, slot).set( attributes["Link Speed"].split(".")[0] ) - metrics["pd_device_speed"].labels(controller_index, enclosure, slot).set( - attributes["Device Speed"].split(".")[0] - ) + # Some disks doesnt report device speed correctly + # when pd_device_speed metric assigns a string value: "Unknown" + # script execution crashes in that case assign a 0 speed value. + if attributes["Device Speed"].split(".")[0] == "Unknown": + metrics["pd_device_speed"].labels(controller_index, enclosure, slot).set('0') + else: + metrics["pd_device_speed"].labels(controller_index, enclosure, slot).set( + attributes["Device Speed"].split(".")[0] + ) metrics["pd_commissioned_spare"].labels(controller_index, enclosure, slot).set( settings["Commissioned Spare"] == "Yes" )