From 94546c8f802f148ba14ff0f086bc5857d2c27f96 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Sun, 24 Dec 2023 08:56:44 +0100 Subject: [PATCH] shelly: temperature check added --- check_shelly | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/check_shelly b/check_shelly index d8fe2dc..c6738c5 100755 --- a/check_shelly +++ b/check_shelly @@ -6,7 +6,7 @@ import nagios import os import urllib.request -CHECKS = ['wifi', 'mqtt', 'memory', 'filesystem'] +CHECKS = ['wifi', 'mqtt', 'memory', 'filesystem', 'temperature'] # WIFI_QUALITY_ERROR = -30 WIFI_QUALITY_WARNING = -50 @@ -16,6 +16,9 @@ RAM_WARNING = .30 # FS_ERROR = .15 FS_WARNING = .30 +# +TMP_WARNING = 50 +TMP_ERROR = 57 if __name__ == "__main__": parser = argparse.ArgumentParser( @@ -73,3 +76,14 @@ if __name__ == "__main__": else: status = n.OK n.exit(status, f"fs_left: {fs_left} ({fs_size}) > {FS_WARNING} > {FS_ERROR}") + elif args.check == 'temperature': + temperature = data.get('tmp', {}).get('tC') + if temperature is None: + status = n.UNKNOWN + elif temperature >= TMP_ERROR: + status = n.ERROR + elif temperature >= TMP_WARNING: + status = n.WARNING + else: + status = n.OK + n.exit(status, f"temperature: {temperature}°C")