Nagios Plugins
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

check_raspi_voltage 594B

123456789101112131415161718192021222324252627
  1. #!/bin/python3
  2. #
  3. import argparse
  4. import nagios
  5. import subprocess
  6. if __name__ == "__main__":
  7. throttled = subprocess.check_output(['vcgencmd', 'get_throttled']).decode('utf-8')
  8. try:
  9. tval = throttled[throttled.index('=')+1:]
  10. tval = int(tval, 16)
  11. except ValueError:
  12. tval = None
  13. #
  14. n = nagios.Nagios()
  15. #
  16. if tval is None:
  17. status = n.UNKNOWN
  18. elif tval & 0x4000 != 0:
  19. status = n.ERROR
  20. elif tval != 0:
  21. status = n.WARNING
  22. else:
  23. status = n.OK
  24. #
  25. n.exit(status, f"Overtemperature state ({throttled})")