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 1000B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/python3
  2. #
  3. import argparse
  4. import nagios
  5. import subprocess
  6. """
  7. Bit Hex Value Meaning
  8. 0 1 Under-voltage detected
  9. 1 2 ARM frequency has been caped
  10. 2 4 Currently throttled
  11. 3 8 Soft temperature limit is active
  12. 16 1000 Under-voltage has occurred
  13. 17 2000 ARM frequency capping has occurred
  14. 18 4000 Throttling has occurred
  15. 19 8000 Soft temperature limit has occurred
  16. Bit16+ are resetted with a reboot (only)
  17. """
  18. if __name__ == "__main__":
  19. throttled = subprocess.check_output(['vcgencmd', 'get_throttled']).decode('utf-8')
  20. try:
  21. tval = throttled[throttled.index('=')+1:]
  22. tval = int(tval, 16)
  23. except ValueError:
  24. tval = None
  25. else:
  26. tval &= 0x3fff # remove the values which are only resetted with a reboot
  27. #
  28. n = nagios.Nagios()
  29. #
  30. if tval is None:
  31. status = n.UNKNOWN
  32. elif tval & 0x1 != 0:
  33. status = n.ERROR
  34. else:
  35. status = n.OK
  36. #
  37. n.exit(status, f"Undervoltage state ({throttled})")