Up 0 Down 0

Monitoring commands

Create new CPU & HDD temperature monitoring script. Replace ZFSVolume and ZFSDataset with the correct names:

vi /mnt/ZFSVolume/ZFSDataset/lstemp

Insert the folowing script with "i":
#! /bin/bash
#
#  Usage: lstemp [ -w or -W]
#  -w / -W: Wake up a sleeping drive to take it's temperature
#
adastat () { echo -n `camcontrol cmd $1 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r - | awk '{print $10 " " ; }'` " " ; }
echo
echo System Temperatures  - `date`
cat /etc/version
uptime | awk '{ print "\nSystem Load:",$(NF-2),$(NF-1),$(NF),"\n" }'
echo "CPU Temperature:"
sysctl -a | egrep -E "cpu\.[0-9]+\.temp"
echo
echo "Drive Activity Status"
for i in $(sysctl -n kern.disks | awk '{for (i=NF; i!=0 ; i--) if (match($i, '/ada/')) print $i }'); do    echo -n $i:; adastat $i; done; echo ; echo
smartopt=`echo $@ | awk '{opt="-n standby"; if(match(tolower($0),'/-w/')) opt=""; print opt; }'`
echo "HDD Temperature:"
for i in $(sysctl -n kern.disks | awk '{for (i=NF; i!=0 ; i--) if (match($i, '/ada/')) print $i }')
do
   echo $i `smartctl -a  $smartopt /dev/$i | awk 'BEGIN { DevName="N/A - Drive in standby mode" } /Temperature_Celsius/{DevTemp=$10;} /Serial Number:/{DevSerNum=$3}; /Device Model:/{DevName=$3} END { print DevTemp,DevSerNum,DevName }'`
done
echo

Safe using ":wq" and make it executable:
chmod 755 /mnt/ZFSVolume/ZFSDataset/lstemp

Run script with the following command:
/mnt/ZFSVolume/ZFSDataset/lstemp