nagios-plugins/check_raspi_voltage

28 lines
594 B
Plaintext
Raw Normal View History

2024-01-07 12:49:49 +01:00
#!/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})")