Files
MOTD/30-hdd-temp
Slava 003a32b4a2 Rework for modular system
Autoadd disks to temps (only for sd*, and works on smartmontools)
Some cosmetic changes
2020-01-14 02:18:46 +03:00

31 lines
693 B
Bash
Executable File

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