Browse Source

shelly: temperature check added

master
Dirk Alders 1 year ago
parent
commit
94546c8f80
1 changed files with 15 additions and 1 deletions
  1. 15
    1
      check_shelly

+ 15
- 1
check_shelly View File

6
 import os
6
 import os
7
 import urllib.request
7
 import urllib.request
8
 
8
 
9
-CHECKS = ['wifi', 'mqtt', 'memory', 'filesystem']
9
+CHECKS = ['wifi', 'mqtt', 'memory', 'filesystem', 'temperature']
10
 #
10
 #
11
 WIFI_QUALITY_ERROR = -30
11
 WIFI_QUALITY_ERROR = -30
12
 WIFI_QUALITY_WARNING = -50
12
 WIFI_QUALITY_WARNING = -50
16
 #
16
 #
17
 FS_ERROR = .15
17
 FS_ERROR = .15
18
 FS_WARNING = .30
18
 FS_WARNING = .30
19
+#
20
+TMP_WARNING = 50
21
+TMP_ERROR = 57
19
 
22
 
20
 if __name__ == "__main__":
23
 if __name__ == "__main__":
21
     parser = argparse.ArgumentParser(
24
     parser = argparse.ArgumentParser(
73
         else:
76
         else:
74
             status = n.OK
77
             status = n.OK
75
         n.exit(status, f"fs_left: {fs_left} ({fs_size}) > {FS_WARNING} > {FS_ERROR}")
78
         n.exit(status, f"fs_left: {fs_left} ({fs_size}) > {FS_WARNING} > {FS_ERROR}")
79
+    elif args.check == 'temperature':
80
+        temperature = data.get('tmp', {}).get('tC')
81
+        if temperature is None:
82
+            status = n.UNKNOWN
83
+        elif temperature >= TMP_ERROR:
84
+            status = n.ERROR
85
+        elif temperature >= TMP_WARNING:
86
+            status = n.WARNING
87
+        else:
88
+            status = n.OK
89
+        n.exit(status, f"temperature: {temperature}°C")

Loading…
Cancel
Save