Features:
1) Display current temperature in MMonit (checked at each cycle defined in Monit).
2) Alert if set CPU temperature threshold is exceeded.
Requires: apt-get install bc
/etc/monit/customscripts/picputemp.sh
Code: Select all
#!/bin/bash
# Configuration
templimit="80" # CPU temperature must be less than this value
# Get output
output=$(vcgencmd measure_temp | egrep -o '[0-9]*\.[0-9]*')
# If CPU Temperature is below templimit
if (( $(echo "$output < $templimit" |bc) -l )); then
echo "CPU Temperature: $output°C"
exit 0
fi
# If CPU temperature is at or above temp limit
if (( $(echo "$output >= $templimit" |bc) -l )); then
echo "CPU temperature is above limit threshold of $templimit°C, current temp is: $output°C" >&2
exit 1
fi
Code: Select all
# Check Raspberry Pi CPU Temperature
check program cpu_temperature with path "/etc/monit/customscripts/picputemp.sh"
with timeout 5 seconds
if status != 0 then alert
I had to temporarily set the threshold to 20 degrees to trigger the alert (so I could show how the MMonit log looks when its triggered):