Browse Source

voltage monitoring added for raspi

master
Dirk Alders 11 months ago
parent
commit
12f9e57ea7
1 changed files with 27 additions and 0 deletions
  1. 27
    0
      check_raspi_voltage

+ 27
- 0
check_raspi_voltage View File

@@ -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…
Cancel
Save