Skip to content

Instantly share code, notes, and snippets.

@SirJson
Last active October 17, 2020 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SirJson/510bd8d52533c8221a398def2b146271 to your computer and use it in GitHub Desktop.
Save SirJson/510bd8d52533c8221a398def2b146271 to your computer and use it in GitHub Desktop.
Grabs a bunch of stats from vcgencmd and prints them out

This is just a useful monitoring script for the Raspberry Pi. Especially useful if you are running one in an environment where you are not sure if it will survive ;-)

You can use it just as a one off thing by calling the script or combine it with watch like this:

watch pistats.sh

That way you get automatic updates of the health of your pi to your terminal.

#!/bin/bash
cpu=$(cat /sys/class/thermal/thermal_zone0/temp)
echo "$(date) @ $(hostname)"
printf "\n=== CPU Temperature ===\n"
printf "temp=$((cpu/1000))'C\n"
printf "\n=== GPU Temperature ===\n"
vcgencmd measure_temp
printf "\n=== System memory ===\n"
free -hmt --si
printf "\n=== Disk space ===\n"
df -hHl --type=ext4 --type=vfat --type=f2fs --type=exfat --type=btrfs
printf "\n=== Undervolt event ===\n"
vcgencmd get_throttled
printf "\n=== Current clocks ===\n"
for src in arm core h264 isp v3d uart pwm emmc pixel vec hdmi dpi ; do
printf "$src:\t$(vcgencmd measure_clock $src)\n"
done
printf "\n=== Current voltage ===\n"
for id in core sdram_c sdram_i sdram_p ; do
printf "$id:\t$(vcgencmd measure_volts $id)\n"
done
printf "\n=== Out of memory events ===\n"
vcgencmd mem_oom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment