28 lines
594 B
Python
Executable File
28 lines
594 B
Python
Executable File
#!/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})")
|