Using Zabbix to monitor RaspberryPi throttling

I needed to monitor the throttle status from a Raspberry Pi. The output of

vcgencmd get_throttled

is a HEX number. This needs converting to binary to then extract which bits have been activated. The following one liner will perform the conversion as a Zabbix Agent key. You’ll need to make sure you have bc installed.

apt install bc
system.run["vcgencmd get_throttled | sed -E 's/(.*=0x)/ibase=16; obase=2; /'|bc"]

This essentially strips the extraneous output, then pipes it to bc and informs bc that the input is base16 (HEX) and the output should be base2 (binary). Always use -E with sed to use extended regex.

You can the create a trigger that find the triggered bits for each condition. For example…

{Template RaspberryPi Sensors:system.run["vcgencmd get_throttled | sed -E 's/(.*=0x)/ibase=16; obase=2; /'|bc"].regexp("(1)(.{1})$")}=1

This regex matches the 2nd bit from the end of the string to 1.

(1)(.{1})$

Just create another triggerand adjust how many characters to check from the end by adjusting the 2nd group.

(.{1})

The bits to check for each trigger can be found here.

Add the zabbix user to video before running the agent. The vcgencmd application requires it to be in that group to run.

usermod -a -G video zabbix