From 1598b837f8fcd37b978e91c8cb1ac51b25d43aed Mon Sep 17 00:00:00 2001 From: yoan mueller Date: Fri, 22 Dec 2023 11:53:20 +0100 Subject: [PATCH] Check if temperature is a number Closes https://github.com/prometheus-community/node-exporter-textfile-collector-scripts/issues/197 Signed-off-by: yoan mueller --- storcli.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/storcli.py b/storcli.py index 073b4a6..5b3dbd2 100755 --- a/storcli.py +++ b/storcli.py @@ -384,9 +384,11 @@ def create_metrics_of_physical_drive(physical_drive, detailed_info_array, contro ).set(1) if "Drive Temperature" in state: - metrics["pd_temp"].labels(controller_index, enclosure, slot).set( - state["Drive Temperature"].split("C")[0].strip() - ) + temperature = state["Drive Temperature"].split("C")[0].strip() + if temperature.isnumeric(): + metrics["pd_temp"].labels(controller_index, enclosure, slot).set( + temperature + ) except KeyError: pass