status-rpi.sh

#!/bin/bash
maxtemp="65"   #Temperatur    
minhdd="2"     #GigaByte
minram="150"   #Freier Ram/Speicher
 
# Pause zwischen den Abfragen
pause="sleep 120"
 
# Webhook1 = IT-Administation: RaspPI-Monitoring 
webhock="https://outlook.office.com/webhook/9d898bd9-0ebf-47be-8843-748a2483efcc@4ac474f8-95e2-4d4c-b4df-fa0ad20dbb69/IncomingWebhook/3ccf373c7ef84ebab704ee7975c6a8d9/133502b3-a348-4f68-ac3d-0786b656681e"
 
# TeamViewer ID
tvinfo=$(teamviewer info | grep 'TeamViewer ID:' | cut -d" " -f27)
 
# Nachrichten Inhalt
info=""$HOSTNAME" | Teamviewer ID: "$tvinfo" | " 
 
###
# Curl zu Teams
sendteams ()
{
curl -H "Content-Type: application/json" -d "{\"text\": \"$send\"}" $webhock2
}
 
temperatur () 
{
temp=$(vcgencmd measure_temp | cut -d"=" -f2 | cut -d"." -f1)
if [ "$temp" -gt "$maxtemp" ]
    then
    send="WARNUNG: $info >> Temperatur ist mit $temp"°" zu hoch!"
    sendteams
    sleep 2
fi
}
 
festplatte ()
{
hdd=$(df -h | grep /dev/root | awk '{print $4}' | cut -c1,2)
if [ "$hdd" -lt "$minhdd" ]
    then
    send="WARNUNG: $info >> Festplatte: Es stehen nur noch $hdd"GB" zur Verfügung!"
    sendteams
    sleep 2
fi
}
 
arbeitsspeicher ()
{
ram=$(free -mh | awk 'NR==2{print $7}' | cut -c1,2,3)
if [ "$ram" -lt "$minram" ]
    then
    send="WARNUNG: $info >> Arbeitsspeicher: Es stehen nur noch $ram"MB" zur Verfügung!"
    sendteams
    sleep 2
fi
}
 
while true; do
temperatur
festplatte
arbeitsspeicher
$pause
done

Last updated