|
@@ -0,0 +1,43 @@
|
|
1
|
+#!/bin/python3
|
|
2
|
+#
|
|
3
|
+import argparse
|
|
4
|
+import nagios
|
|
5
|
+import subprocess
|
|
6
|
+
|
|
7
|
+GPU_ERROR = 80
|
|
8
|
+GPU_WARNING = 75
|
|
9
|
+#
|
|
10
|
+CPU_ERROR = 80
|
|
11
|
+CPU_WARNING = 75
|
|
12
|
+#
|
|
13
|
+
|
|
14
|
+if __name__ == "__main__":
|
|
15
|
+ cpu_temp = subprocess.check_output(['cat', '/sys/class/thermal/thermal_zone0/temp']).decode('utf-8')
|
|
16
|
+ try:
|
|
17
|
+ cpu_temp = int(cpu_temp) / 1000
|
|
18
|
+ except ValueError:
|
|
19
|
+ cpu_temp = None
|
|
20
|
+
|
|
21
|
+ gpu_temp = subprocess.check_output(['vcgencmd', 'measure_temp']).decode('utf-8')
|
|
22
|
+ gpu_temp = gpu_temp[gpu_temp.find('=')+1:gpu_temp.find("'")]
|
|
23
|
+ try:
|
|
24
|
+ gpu_temp = float(gpu_temp)
|
|
25
|
+ except ValueError:
|
|
26
|
+ gpu_temp = None
|
|
27
|
+ #
|
|
28
|
+ n = nagios.Nagios()
|
|
29
|
+ #
|
|
30
|
+ if (gpu_temp or 0) > GPU_ERROR:
|
|
31
|
+ status = n.ERROR
|
|
32
|
+ elif (cpu_temp or 0) > CPU_ERROR:
|
|
33
|
+ status = n.ERROR
|
|
34
|
+ elif (gpu_temp or 0) > GPU_WARNING:
|
|
35
|
+ status = n.WARNING
|
|
36
|
+ elif (cpu_temp or 0) > CPU_WARNING:
|
|
37
|
+ status = n.WARNING
|
|
38
|
+ elif gpu_temp is None or cpu_temp is None:
|
|
39
|
+ status = n.UNKNOWN
|
|
40
|
+ else:
|
|
41
|
+ status = n.OK
|
|
42
|
+ #
|
|
43
|
+ n.exit(status, f"cpu-temperature={cpu_temp}°C - gpu-temperature: {gpu_temp}°C")
|