Last active
October 29, 2018 12:49
-
-
Save TimKraemer/a0e96d57e51a51f88de83b2aeed7da89 to your computer and use it in GitHub Desktop.
script to check temperatures of Ubuntu Server and send an email report if specified temperatures exceeded
This file contains 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 | |
# PURPOSE: Script to check temperatures and report if specified temperatures exceeded | |
# requires lm-sensors | |
LOG_FILE="/var/log/CPUWarning.log" | |
EMAIL_ADDRESS="lockbase@koertner-muth.com" | |
MAX_TEMP=70 | |
warning=false | |
for temp in $(sensors -u | grep "temp[0-9]\_input:" | while read -r line; do echo ${line} | cut -f2 -d ' '; done) | |
do | |
temp=${temp%.*} | |
if [ ${temp} -ge ${MAX_TEMP} ] | |
then | |
warning=true | |
echo 'Die Temperatur vom HAL Server ist zu hoch, bitte die Schranktür öffnen und ggf. die Lüftersteuerung hochregeln' > ${LOG_FILE} | |
echo '============================' >>${LOG_FILE} | |
echo $(date) >>${LOG_FILE} | |
echo '' >>${LOG_FILE} | |
echo "$(sensors)" >>${LOG_FILE} | |
echo '' >>${LOG_FILE} | |
echo '============================' >>${LOG_FILE} | |
fi | |
done | |
if ${warning} | |
then | |
/usr/bin/mail -a "Content-Type: text/plain; charset=UTF-8" -s "[HAL] Der Server wird zu warm!" "$EMAIL_ADDRESS" < ${LOG_FILE} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment