From be100171650ad67fe7066f3d5081f870f4b93c76 Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Sun, 8 Oct 2023 16:15:32 +0200 Subject: [PATCH] v0.10.6 --- setup.cfg | 2 +- src/de/p1st/monitor/loggers/drive.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index c839c9f..a2dfbe0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,7 +3,7 @@ [metadata] name = de.p1st.monitor -version = 0.10.5 +version = 0.10.6 author = Daniel Langbein author_email = daniel@systemli.org description = periodically monitor and warn diff --git a/src/de/p1st/monitor/loggers/drive.py b/src/de/p1st/monitor/loggers/drive.py index 93721c2..32d2da0 100644 --- a/src/de/p1st/monitor/loggers/drive.py +++ b/src/de/p1st/monitor/loggers/drive.py @@ -150,4 +150,10 @@ class DriveLogger(Logger): raise LoggerReadEx(f'smartctl failed with returncode {returncode}\nstdout: {stdout}\nstderr: {stderr}') j = json.loads(stdout) - return j['temperature']['current'] + temp_key = 'temperature' + if temp_key not in j: + raise LoggerReadEx(f'smartctl JSON does not contain key {temp_key}. {device}') + current_key = 'current' + if current_key not in j[temp_key]: + raise LoggerReadEx(f'smartctl JSON does not contain key {temp_key}.{current_key}. {device}') + return j[temp_key][current_key]