Files
MOTD/30-hdd-temp
Slava e244affe6e added memory info
restyled bars
changed logics in generate docker info
added sorting to services
changed temp scanner (maybe would be optimized)
2024-11-16 00:50:50 +03:00

32 lines
750 B
Bash
Executable File

#!/bin/bash
mapfile -t disks < <( ls /dev/sd[a-z] )
out=""
dim="\e[43m"
label="\e[1;30m"
COLUMNS=3
clear="\e[0m\e[39m"
my_target_temp=45
k=0
for i in ${disks[@]}; do
temp=$(smartctl -a ${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+="$(printf "${dim}${label} %s \e[30m$color %-17s," "$(echo ${i} | sed -e 's/\/dev\///')" "$temp $clear")"
if [ $(($k % $COLUMNS)) -eq 0 ]; then
out+="\n"
fi
fi
done
out+="\n"
printf "\n HDD Temps:\n"
printf "$out" | column -c $k -ts $',' | sed -e 's/^/ /'