Files
MOTD/30-hdd-temp
2019-08-19 15:22:47 +03:00

24 lines
533 B
Bash
Executable File

#!/bin/bash
sd=(sda sdb sdc sdd sde sdf)
out=""
COLUMNS=3
clear="\e[0m\e[39m"
my_target_temp=45
for i in ${!sd[@]}; do
temp=$(smartctl -a /dev/${sd[$i]} | grep Temperature_Celsius | awk '{print $10}' 2> /dev/null)
color="\e[42m"
if [ "$temp" -ge "${my_target_temp}" ]; then
color="\e[41m"
fi
out+="${sd[$i]} \e[30m $color $temp $clear ,"
c=i+1
if [ $((($i+1) % $COLUMNS)) -eq 0 ]; then
out+="\n"
fi
done
out+="\n"
echo -e "
HDD Temps:"
printf "$out" | column -c $c -ts $',' | sed -e 's/^/ /'