shelly: temperature check added

This commit is contained in:
Dirk Alders 2023-12-24 08:56:44 +01:00
parent 73e3168b53
commit 94546c8f80

View File

@ -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")