Hi...
I made a script to alert high temperatures of the HDDs based on S.M.A.R.T.... The goal of my script is to be more hardware independent as possible...
But unfortunately I didn't tested it with SAS disks
Code:
#!/bin/bash
### Define parametros de alerta ###
temp_max=35 # Temperatura em graus celcius
email="seu_endereco_de_email" # E-mail do destinatario do alerta
assunto="FreeNAS: Alerta de temperatura HDD" # Assunto do email
# Define variavel de graus celcius
CEL=$'\xe2\x84\x83'
# Monta array de discos do sistema
arrdiscs=($(camcontrol devlist | awk '{print substr($NF, 8, length($NF)-8)}'))
# Cria array para alerta de temperatura
alertdiscs=()
# Recupera a temperatura dos discos com base no arrdiscs
for i in "${arrdiscs[@]}"
do
temp=("$(smartctl -A "/dev/$i" | egrep ^194 | awk '{print $10}')")
if [ -n "$temp" ] && [ $temp -gt $temp_max ]; then
alertdiscs+=("[$i]: $temp$CEL")
fi
done
# Compara os valores de temperatura com a variavel temp_max e gera alerta
if [ ${#alertdiscs[@]} -gt 0 ]; then
# Envia email de alerta
printf "%b\n" "Discos com temperatura acima do limite ($temp_max$CEL):\n${alertdiscs[@]}" | /usr/bin/mail -s "$assunto" "$email"
fi
So... No need to define the name of the HDD devices... :)
With this script an email will be send ONLY if the temperature of one or more HDDs is higher than that specified in the max_temp variable. In the message body will be listed only the hard drives with high temperatures.
Hope it help someone... ;)