Last active
February 27, 2024 23:20
-
-
Save wkettler/a93644ec101d3b6cfb6c to your computer and use it in GitHub Desktop.
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 | |
# | |
# hddcheck.sh | |
# | |
# Modified version of http://www.cyberciti.biz/files/scripts/monitor-my-hard-disk.sh.txt. | |
# | |
# Generate a warning email based on hard drive temps. | |
# | |
TO=test@test.com | |
HDDS="/dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf /dev/sdg /dev/sdh /dev/sdi" | |
HDT=/usr/sbin/hddtemp | |
LOG=/usr/bin/logger | |
DOWN=/sbin/shutdown | |
MAIL=/usr/bin/mail | |
HOSTNAME=$(hostname) | |
ALERT_LEVEL=50 | |
for disk in $HDDS; do | |
if [[ -b $disk ]]; then | |
HDTEMP=$($HDT $disk | awk '{print $NF}' | awk -F '°' '{print $1}') | |
if [[ $HDTEMP -ge $ALERT_LEVEL ]]; then | |
# MSG="System going down $disk temperature $HDTEMP°C crossed its limit" | |
MSG="$disk temperature $HDTEMP°C crossed its limit" | |
# Log to syslog | |
$LOG "${MSG}" | |
# Send email | |
echo "${MSG}" | ${MAIL} -s "ERROR: $HOSTNAME disk temperature" ${TO} | |
# Shutdown the system | |
# $DOWN -h 0 | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment