Bladeren bron

shelly: temperature check added

master
Dirk Alders 1 jaar geleden
bovenliggende
commit
94546c8f80
1 gewijzigde bestanden met toevoegingen van 15 en 1 verwijderingen
  1. 15
    1
      check_shelly

+ 15
- 1
check_shelly Bestand weergeven

@@ -6,7 +6,7 @@ import nagios
6 6
 import os
7 7
 import urllib.request
8 8
 
9
-CHECKS = ['wifi', 'mqtt', 'memory', 'filesystem']
9
+CHECKS = ['wifi', 'mqtt', 'memory', 'filesystem', 'temperature']
10 10
 #
11 11
 WIFI_QUALITY_ERROR = -30
12 12
 WIFI_QUALITY_WARNING = -50
@@ -16,6 +16,9 @@ RAM_WARNING = .30
16 16
 #
17 17
 FS_ERROR = .15
18 18
 FS_WARNING = .30
19
+#
20
+TMP_WARNING = 50
21
+TMP_ERROR = 57
19 22
 
20 23
 if __name__ == "__main__":
21 24
     parser = argparse.ArgumentParser(
@@ -73,3 +76,14 @@ if __name__ == "__main__":
73 76
         else:
74 77
             status = n.OK
75 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")

Laden…
Annuleren
Opslaan