Created
May 2, 2018 07:52
-
-
Save discarn8/cdb8735fb97f7a075dd7a10165a7faa4 to your computer and use it in GitHub Desktop.
hdd_temp_shutdown_with_log.sh
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 | |
HDDS="/dev/sda /dev/sdb /dev/sdc" | |
HDT=/usr/sbin/hddtemp | |
LOG=/usr/bin/logger | |
DOWN=/sbin/shutdown | |
ALERT_LEVEL=55 | |
for disk in $HDDS | |
do | |
if [ -b $disk ]; then | |
HDTEMP=$($HDT $disk | awk '{ print $4}' | awk -F '°' '{ print $1}') | |
if [ $HDTEMP -ge $ALERT_LEVEL ]; then | |
$LOG "System going down as hard disk : $disk temperature $HDTEMP°C crossed its limit" | |
sync;sync | |
$DOWN -h 0 | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment