Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ### Parameters ###
- cores=4
- logfile="/tmp/cputemp.tmp"
- email="[email protected]"
- subject="FreeNAS Temperatures"
- drives="ada0 ada1 ada2 ada3 ada4"
- ### Set email headers ###
- (
- echo "To: ${email}"
- echo "Subject: ${subject}"
- echo "Content-Type: text/html"
- echo "MIME-Version: 1.0"
- echo -e "\r\n"
- ) > "$logfile"
- ### Set email body ###
- echo "<pre style=\"font-size:14px\">" >> "$logfile"
- ### CPU Summary ###
- (
- echo "### CPU Temp. ###"
- ) >> "$logfile"
- ### CPU ###
- cores=$((cores - 1))
- for core in $(seq 0 $cores)
- do
- {
- temp="$(sysctl -a | grep "cpu.${core}.temp" | cut -c24-25 | tr -d "\n")"
- printf "CPU %s: %s C\n" "$core" "$temp"
- } >> "$logfile"
- done
- ### HDD Summary ###
- (
- echo ""
- echo "### HDD Temp. ###"
- ) >> "$logfile"
- ### Disks ###
- for drive in $drives
- do
- {
- serial="$(smartctl -i /dev/${drive} | grep "Serial Number" | awk '{print $3}')"
- temp="$(smartctl -A /dev/${drive} | grep "Temperature_Celsius" | awk '{print $10}')"
- printf "%s %-15s: %s C\n" "$drive" "$serial" "$temp"
- } >> "$logfile"
- done
- echo "</pre>" >> "$logfile"
- ### Send report ###
- sendmail -t < "$logfile"
- rm "$logfile"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement