Here's a script intended for a Raspberry Pi, but I'm pretty sure it's of use to Debian and Ubuntu targets. It's on github: https://github.com/ghoulmann/observium-raspi-monitoring