From 12f9e57ea7b9ea75bb87ed764638c35340af4915 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Sun, 7 Jan 2024 12:49:49 +0100 Subject: [PATCH] voltage monitoring added for raspi --- check_raspi_voltage | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 check_raspi_voltage diff --git a/check_raspi_voltage b/check_raspi_voltage new file mode 100755 index 0000000..ccc5f23 --- /dev/null +++ b/check_raspi_voltage @@ -0,0 +1,27 @@ +#!/bin/python3 +# +import argparse +import nagios +import subprocess + + +if __name__ == "__main__": + throttled = subprocess.check_output(['vcgencmd', 'get_throttled']).decode('utf-8') + try: + tval = throttled[throttled.index('=')+1:] + tval = int(tval, 16) + except ValueError: + tval = None + # + n = nagios.Nagios() + # + if tval is None: + status = n.UNKNOWN + elif tval & 0x4000 != 0: + status = n.ERROR + elif tval != 0: + status = n.WARNING + else: + status = n.OK + # + n.exit(status, f"Overtemperature state ({throttled})")