So apparently sometimes doing ‘stupid things(tm)’ can overheat your disks, and your box… So you should always keep an eye on the temperature.
So for my benefit more so in the future, and maybe others, here is a quick script to check the temperature of the processors, disk, and any changes in /var/log/messages to see what is going on. Â I guess I should make it more modular, and not hardcode stuff, but here we are.
#!/bin/bash
#
#
# Read the disk temperature
disk="smartctl -d ata -A /dev/sda | grep Temperature_Celsius | awk '{print \$10}'"
diskt=$(eval $disk)
if [ "$diskt" -gt 40 ];
then
error=$"Disk temperature is hotter than 40c it's now $diskt\n"
else
# error=$"Disk temperature is fine, it's $diskt\n"
:
fi
sensors| grep Core|awk '{print $3}'>/tmp/dat.txt
j=0
while read line
do
number="echo $line |sed 's/\.#!/bin/bash
#
#
# Read the disk temperature
disk="smartctl -d ata -A /dev/sda | grep Temperature_Celsius | awk '{print \$10}'"
diskt=$(eval $disk)
if [ "$diskt" -gt 40 ];
then
error=$"Disk temperature is hotter than 40c it's now $diskt\n"
else
# error=$"Disk temperature is fine, it's $diskt\n"
:
fi
sensors| grep Core|awk '{print $3}'>/tmp/dat.txt
j=0
while read line
do
number="echo $line |sed 's/\.\0\°C//g'|sed 's/\+//g'"
cpu=$(eval $number)
if [ "$cpu" -gt 82 ];
then
error=$"$error\nCPU core $j temperature is $cpu"
else
#error=$"$error\nCPU core $j temperature is $cpu"
:
fi
j=$(($j+1))
done < /tmp/dat.txt rm -f /tmp/dat.txt if [[ -f /tmp/messages.1 ]]; then tail /var/log/messages > /tmp/messages.2
dstring="diff /tmp/messages.1 /tmp/messages.2"
logadd=$(eval $dstring)
if [ ! -z "$logadd" ];
then
error=$"$error\n\n$logadd"
else
:
fi
mv /tmp/messages.2 /tmp/messages.1
else
tail /var/log/messages > /tmp/messages.1
fi
if [ ! -z "$error" ];
then
echo "there are issues.."
echo -e $error > /tmp/message.tmp
mail your_name@your_domain.com -s "errors on machine_name"
\°C//g'|sed 's/\+//g'"
cpu=$(eval $number)
if [ "$cpu" -gt 82 ];
then
error=$"$error\nCPU core $j temperature is $cpu"
else
#error=$"$error\nCPU core $j temperature is $cpu"
:
fi
j=$(($j+1))
done < /tmp/dat.txt rm -f /tmp/dat.txt if [[ -f /tmp/messages.1 ]]; then tail /var/log/messages > /tmp/messages.2
dstring="diff /tmp/messages.1 /tmp/messages.2"
logadd=$(eval $dstring)
if [ ! -z "$logadd" ];
then
error=$"$error\n\n$logadd"
else
:
fi
mv /tmp/messages.2 /tmp/messages.1
else
tail /var/log/messages > /tmp/messages.1
fi
if [ ! -z "$error" ];
then
echo "there are issues.."
echo -e $error > /tmp/message.tmp
mail your_name@your_domain.com -s "errors on machine_name"
Of course, it can and should be expanded to check up on things like SMART disk errors, and other things going on. Â And of course in the crontab, something like:
*/5 * * * * /root/report.sh
To run it every five minutes. Â As always it’s lacking comments, full pathing to executables, and much of anything to keep it safe. Â I’m sure if I was smart I could read more from pipes and variables, but I’m old so I read from files. Â If you were looking for the bash shell script expert, it’s not me. lol