瀏覽代碼

voltage monitoring added for raspi

master
Dirk Alders 11 月之前
父節點
當前提交
12f9e57ea7
共有 1 個文件被更改,包括 27 次插入0 次删除
  1. 27
    0
      check_raspi_voltage

+ 27
- 0
check_raspi_voltage 查看文件

@@ -0,0 +1,27 @@
1
+#!/bin/python3
2
+#
3
+import argparse
4
+import nagios
5
+import subprocess
6
+
7
+
8
+if __name__ == "__main__":
9
+    throttled = subprocess.check_output(['vcgencmd', 'get_throttled']).decode('utf-8')
10
+    try:
11
+        tval = throttled[throttled.index('=')+1:]
12
+        tval = int(tval, 16)
13
+    except ValueError:
14
+        tval = None
15
+    #
16
+    n = nagios.Nagios()
17
+    #
18
+    if tval is None:
19
+        status = n.UNKNOWN
20
+    elif tval & 0x4000 != 0:
21
+        status = n.ERROR
22
+    elif tval != 0:
23
+        status = n.WARNING
24
+    else:
25
+        status = n.OK
26
+    #
27
+    n.exit(status, f"Overtemperature state ({throttled})")

Loading…
取消
儲存