ein Kollege, der schon wesentlich länger mit Raspberries zu Gange ist, als ich, hat mich darauf hingewiesen, daß es das Wichtigste ist, daß die Dinger unter 50 Grad gehalten werden, da sich sich sonst abdrehen.
Nachdem ich meine NextCloud aufgesetzt hatte und mal fest Daten raufgeladen habe, war es auch mal so weit, daß der Raspberry zeitweise nicht mehr erreichbar war. Zum Glück hat er sich anscheinend dann auch wieder eingeschalten bzw die Dienste wieder aufgenommen. Und in der Tat war zu dem Zeitpunkt die Temperatur knapp unter 50 Grad.
Ich habe mir daraufhin ein Script zur Überwachung der Temperatur geschrieben, das teil ich hier mal mit Euch (und in dem Fall alarmier ich schon bei 40 Grad:
Code: Alles auswählen
#!/bin/bash
if [ "$1" == "debug" ]; then
debug=1
else
debug=0
fi
function getMoreInfo() {
topProcesses=$(ps -eo pcpu,pid,user,args | tail -n +2 | sort -k1 -r -n | head -10)
echo "Top processes:\n${topProcesses}"
}
function sendNotification() {
from="Notifications <myhome@mycastle.org>"
recipient="myhome@mycastle.org"
subject="Alarm: Dein Raspberry wird heiss!"
body="Alarm: Dein Raspberry wird heiss:\n\n$1"
body+="\n\n"
body+="$(getMoreInfo)"
echo -e "To:${recipient}\nSubject:${subject}\n\n${body}\n" | /usr/sbin/sendmail -t -f "${from}"
}
# Get date and time (for logging/reporting purposes)
isoMonth=$(date +"%Y-%m")
nowStamp=$(date +"%Y-%m-%d %H:%M:%S")
# Read CPU temperature
cpuTemp=$(</sys/class/thermal/thermal_zone0/temp)
#cpuTempCelsius=$((cpuTemp/1000))
if [ $debug == 1 ]; then echo "CPU-Temperatur (RAW): $cpuTemp"; fi
cpuTempCelsius=${cpuTemp:0:2}.${cpuTemp:2:5}
if [ $debug == 1 ]; then echo "CPU-Temperatur formattiert: $cpuTempCelsius"; fi
# Read GPU temperature
gpuTemp=$(vcgencmd measure_temp)
if [ $debug == 1 ]; then echo "GPU-Temperatur (RAW): $gpuTemp"; fi
gpuTempCelsius=$(echo "$gpuTemp" | egrep -o '[0-9]*\.[0-9]*')
gpuCheckValue=${gpuTempCelsius:0:2}
if [ $debug == 1 ]; then echo "GPU-Temperatur formattiert: $gpuTempCelsius"; fi
gpuCheckValue=${gpuTempCelsius:0:2}
if [ $debug == 1 ]; then echo "GPU-Check-Wert: $gpuCheckValue"; fi
# =============================================================
# Temperature alert levels
# -------------------------------------------------------------
sendNotification=0
if [ $debug == 1 ]; then
echo "Wertetest CPU $cpuTemp und GPU $gpuCheckValue..."
fi
if [[ "$cpuTemp" > "40000" ]]; then
if [ $debug == 1 ]; then echo "CPU-Temperatur-Niveau erreich!"; fi
sendNotification=1
fi
if [[ $gpuCheckValue -gt 40 ]]; then
if [ $debug == 1 ]; then echo "GPU-Temperatur-Niveau erreich!"; fi
sendNotification=1
fi
# log temperatures
logFile="/var/log/temperature/temperature-${isoMonth}.log"
if [ ! -s "$logFile" ]; then
echo "Date/Time Notify CPU °C GPU °C" >$logFile
fi
echo "$nowStamp $sendNotification $cpuTempCelsius $gpuTempCelsius" >>$logFile
# Sending alert email
if [ $sendNotification == 1 ]; then
if [ $debug == 1 ]; then echo "Sende Benachrichtigung..."; fi
message="CPU-Temperatur: $cpuTempCelsius\n"
message+="GPU-Temperatur: $gpuTempCelsius\n"
sendNotification "${message}"
result=$?
if [ $debug == 1 ]; then
if [ $result == 0 ]; then
echo "Benachrichtigung gesendet."
else
echo "Benachrichtigung fehlgeschlagen mit Fehler-Code $result"
exit $result
fi
fi
else
if [ $debug == 1 ]; then echo "Keine Benachrichtigung verschickt."; fi
fi
Code: Alles auswählen
root=postmaster
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp.world4you.com:587
# Where will the mail seem to come from?
#rewriteDomain=
# The full hostname
hostname=myraspberry.mycastle.org
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES
RewriteDomain=mycastle.org
AuthUser=myhome@mycastle.org
AuthPass=mysuperpassword
UseSTARTTLS=YES