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})")