Last active
August 29, 2015 14:01
-
-
Save lidio601/10f88f91e940fcf13b82 to your computer and use it in GitHub Desktop.
Linux thermal monitor & emergercy shutdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# http://www.raspberrypi.org/forums/viewtopic.php?t=30670 | |
#temp=`cat /proc/acpi/thermal_zone/THRM/temperature | cut -c26-27` | |
temp="`cat /sys/class/thermal/thermal_zone0/temp`" | |
let tempint=$temp/1000 | |
tempfloat="`bc -l <<< \"scale=2; $temp/1000\"`" | |
debug="$1" | |
if [ ! -z "$debug" ]; then | |
echo "debug: temperature=$tempfloat degree" | |
#exit 1 | |
fi | |
dat=`date` | |
mail="`which mail`" | |
notifyuser="root" | |
alarm_temperature="64" | |
switchdown_temperature="70" | |
if [ "$tempint" -gt "$alarm_temperature" ]; then | |
if [ "$tempint" -gt "$switchdown_temperature" ]; then | |
echo "<$dat> $tempfloat degree: temperature too high! Shutting down..." | $mail -s "Emergency shutdown" "$notifyuser" | |
if [ ! -z "$debug" ]; then | |
echo "<$dat> $tempfloat degree: temperature too high! Shutting down..." | |
else | |
shutdown -h now | |
fi | |
else | |
echo "$dat at $tempfloat degree" | $mail -s "thermal alert: $tempfloat degree" "$notifyuser" | |
if [ ! -z "$debug" ]; then | |
echo "$dat at $tempfloat degree" | |
fi | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment