How to monitor system (CPU, HDD, mobo, GPU) temperatures on FreeNAS 8?

Joined
Nov 3, 2012
Messages
3
do you mean the "Drive Activity Status",
if yes, sorry to shatter your dreams but there is a second ada filter xD
Code:
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


Ok srly, this will call the "adastat" function which will call "camcontrol" for each found disk, you may want to check the output of this tool against you drives on the LSI

Yes, I had caught that and modified accordingly, but the result of the adastat function call to the LSI card ports is:

"camcontrol: error sending command"

Seems that camcontrol command being sent here doesn't apply to the LSI ports the same as it does with onboard ports...

If someone knows the correct command sequence, great, but really it's not as useful to me as the temps anyway.

Thanks, Karl
 

Yell

Explorer
Joined
Oct 24, 2012
Messages
74
well then to remove you errors readd that /ada/ for the adastat function call.
Does LSI supply FreeBSD binary's ? Maybe the even ship a little control center to monitor the attached drives?
 

bogenfisch

Cadet
Joined
Feb 22, 2013
Messages
1
Love the script - as I have little to no knowledge of scripting. Unfortunately it only gives a static view of the temperture at that instance

In the Freenas feature request there is a open request for HDD temps in the reporting tab, which is quite old. It would be nice to be able to look at how the temperatures vary over time. Especially for private people who can't afford airconditioned server rooms at home

If the output could be a file with the format

Timestamp; CPU1; CPU2; ...; CPUn; HHD SN1; HDD SN2; ...; HDD SNn
28.02.2013 15:00:00; TEMP string ....
28.02.2013 15:15:00; TEMP string ....
etc

then this could be imported into a spreadsheet, and a diagram over time generated.

Volunteers?
 

virus

Cadet
Joined
Mar 13, 2013
Messages
1
Your right. It works now both in 8.2 and 8.3.1. Thanks!


I used the esmart script and put this script together to send myself email of this information
Code:
#! /usr/local/bin/sh

(
echo "To: your email address "
echo "Subject: System Temperatures INFO"
echo " "
) > /var/cover


adastat () { echo -n `camcontrol cmd $1 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r - | awk '{print $10 " " ; }'` " " ; } >> /var/cover
echo
echo System Temperatures - `date` >> /var/cover
cat /etc/version >> /var/cover
uptime | awk '{ print "\nSystem Load:",$8,$9,$10,"\n" }' >> /var/cover
echo "CPU Temperature:" >> /var/cover
sysctl -a | egrep -E "cpu\.[0-9]+\.temp" >> /var/cover
echo
echo "Drive Activity Status" >> /var/cover
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 >> /var/cover
echo "HDD Temperature:" >> /var/cover
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 /dev/$i | awk '/Temperature_Celsius/{DevTemp=$10;} /Serial Number:/{DevSerNum=$3}; /Device Model:/{DevName=$3} END { print DevTemp,DevSerNum,DevName }'` >> /var/cover
done
echo

sendmail -t < /var/cover
exit 0


when I do run it though i get an echo of the hard letters. Not sure which echo is the cause of it and if I can turn if off from outputting. Otherwise the email is looks good.

Hi there,
this scrip i received all time error somethig like waiting for } ...
i inpire my self and made this:
Code:
#!/bin/sh
(
echo "To: ***x@***.com"
echo "Subject: System Temperatures INFO"
echo " "
) > /var/cover
echo Pc temp `sysctl -n hw.acpi.thermal.tz0.temperature` >> /var/cover
echo CPU1   `sysctl -n dev.cpu.0.temperature` >> /var/cover
echo CPU2   `sysctl -n dev.cpu.1.temperature` >> /var/cover
echo "Hdd" >> /var/cover
echo   DevTemp1=`smartctl -a /dev/ada0 | awk '/Temperature_Celsius/{print $0}' | awk '{print $10 "C"}'` \   DevSerNum1=`smartctl -a /dev/ada0 | awk '/Serial Number:/{print $0}' | awk '{print $3}'` \   DevName1=`smartctl -a /dev/ada0 | awk '/Device Model:/{print $0}' | awk '{print $3}'`\   DevTemp2=`smartctl -a /dev/ada1 | awk '/Temperature_Celsius/{print $0}' | awk '{print $10 "C"}'` \   DevSerNum2=`smartctl -a /dev/ada1 | awk '/Serial Number:/{print $0}' | awk '{print $3}'` \   DevName2=`smartctl -a /dev/ada1 | awk '/Device Model:/{print $0}' | awk '{print $3}'` >> /var/cover
sendmail -t < /var/cover
exit 0

for:
Code:
System Information
Hostname 	freenas.local
Build 	FreeNAS-8.3.0-RELEASE-p1-x64 (r12825)
Platform 	Dual Core AMD Opteron(tm) Processor 170
Memory 	1519MB
System Time 	Wed Mar 13 21:05:19 CET 2013
Uptime 	9:05PM up 4 days, 20:47, 0 users
Load Average 	0.07, 0.08, 0.08
Connected through 	192.168.10.180
 

firest0rm

Cadet
Joined
Aug 1, 2013
Messages
5
can some one tell me how to install this?
i am a total noob when it comes to linux + freenas

also is there any better plugin out there that can show this in a spread sheet and log down the tempratures some how?
 

gpsguy

Active Member
Joined
Jan 22, 2012
Messages
4,472
You don't need to "install it" - just run it. Here's a recent forum message, explaining how: Running scripts

If you want to automate it, read up on cron.

btw, FreeNAS isn't a Linux distro. It's a descendant of Unix.
 

firest0rm

Cadet
Joined
Aug 1, 2013
Messages
5
just shows the lack of knowledge lol

can u explain more about this cron thing?
 

gpsguy

Active Member
Joined
Jan 22, 2012
Messages
4,472
Learn about cron.

The FreeNAS manual has a section on how to create cron jobs.
 

Z300M

Guru
Joined
Sep 9, 2011
Messages
882
FreeNAS CPU / Hard Drive Temperature Script

Nice Job djoole ... thanks for the inspiration.... I cleaned up the awk script in the for loop a bit so that it is only necessary to call smartctl once for each disk drive to save the unnecessary overhead.

Code:
#! /bin/bash
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.freenas
uptime | awk '{ print "\nSystem Load:",$8,$9,$10,"\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
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 /dev/$i | awk '/Temperature_Celsius/{DevTemp=$10;} /Serial Number:/{DevSerNum=$3}; /Device Model:/{DevName=$3} END { print DevTemp,DevSerNum,DevName }'`
done
echo


I also included/changed the following:
  • a few cosmetic labels
  • included system load to correlate with the CPU termperature
  • list the system disks in ascending order (ada0-adaX)
  • omitted any disks other than adaX since they didn't apply on my system ( da0 = boot flash drive - no temp sensor).
  • +++show drive status (00=stopped, FF=spinning) prior to temperature reading to determine if disk was active (smartctl causes disk to start spinning)
+++ Credit for the drive spin down status belongs to the authors of this thread
http://forums.freenas.org/showthread.php?2068-How-to-find-out-if-a-drive-is-spinning-down-properly&highlight=camcontrol cmd -a

Hope someone finds this useful and can improve it some more.
Sorry, but I am a real n00b when it comes to working with shell scripts. How could I modify it to have the Temperature, Serial Number and Name separated by Tabs?
 

tmacka88

Patron
Joined
Jul 5, 2011
Messages
268
FreeNAS CPU / Hard Drive Temperature Script

Nice Job djoole ... thanks for the inspiration.... I cleaned up the awk script in the for loop a bit so that it is only necessary to call smartctl once for each disk drive to save the unnecessary overhead.

Code:
#! /bin/bash
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.freenas
uptime | awk '{ print "\nSystem Load:",$8,$9,$10,"\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
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 /dev/$i | awk '/Temperature_Celsius/{DevTemp=$10;} /Serial Number:/{DevSerNum=$3}; /Device Model:/{DevName=$3} END { print DevTemp,DevSerNum,DevName }'`
done
echo


I also included/changed the following:
  • list the system disks in ascending order (ada0-adaX)
.


How do I modify this to show all HDD's not just ada. I have others such as da, but want this script above to show all hdd's.

Thanks
 

tmacka88

Patron
Joined
Jul 5, 2011
Messages
268
FreeNAS CPU / Hard Drive Temperature Script

Nice Job djoole ... thanks for the inspiration.... I cleaned up the awk script in the for loop a bit so that it is only necessary to call smartctl once for each disk drive to save the unnecessary overhead.

Code:
#! /bin/bash
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.freenas
uptime | awk '{ print "\nSystem Load:",$8,$9,$10,"\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
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 /dev/$i | awk '/Temperature_Celsius/{DevTemp=$10;} /Serial Number:/{DevSerNum=$3}; /Device Model:/{DevName=$3} END { print DevTemp,DevSerNum,DevName }'`
done
echo


I also included/changed the following:
  • list the system disks in ascending order (ada0-adaX)
.


How do I modify this to show all HDD's not just ada. I have others such as da, but want this script above to show all hdd's.

Thanks
 

tmacka88

Patron
Joined
Jul 5, 2011
Messages
268
FreeNAS CPU / Hard Drive Temperature Script

Nice Job djoole ... thanks for the inspiration.... I cleaned up the awk script in the for loop a bit so that it is only necessary to call smartctl once for each disk drive to save the unnecessary overhead.

Code:
#! /bin/bash
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.freenas
uptime | awk '{ print "\nSystem Load:",$8,$9,$10,"\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
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 /dev/$i | awk '/Temperature_Celsius/{DevTemp=$10;} /Serial Number:/{DevSerNum=$3}; /Device Model:/{DevName=$3} END { print DevTemp,DevSerNum,DevName }'`
done
echo


I also included/changed the following:
  • list the system disks in ascending order (ada0-adaX)
.


How do I modify this to show all HDD's not just ada. I have others such as da, but want this script above to show all hdd's.


Thanks
 

tmacka88

Patron
Joined
Jul 5, 2011
Messages
268
Sorry for the posts duplicating not sure what happened...

Also when I run NASbox's script:
Code:
  1. #! /bin/bash
  2. adastat () { echo -n `camcontrol cmd $1 -a "E5 00 00 00 00 00 00 00 00 00 00 00" -r - | awk '{print $10 " " ; }'` " " ; }
  3. echo
  4. echo System Temperatures - `date`
  5. cat /etc/version.freenas
  6. uptime | awk '{ print "\nSystem Load:",$8,$9,$10,"\n" }'
  7. echo "CPU Temperature:"
  8. sysctl -a | egrep -E "cpu\.[0-9]+\.temp"
  9. echo
  10. echo "Drive Activity Status"
  11. 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
  12. echo "HDD Temperature:"
  13. for i in $(sysctl -n kern.disks | awk '{for (i=NF; i!=0 ; i--) if (match($i, '/ada/')) print $i }')
  14. do
  15. echo $i `smartctl -a /dev/$i | awk '/Temperature_Celsius/{DevTemp=$10;} /Serial Number:/{DevSerNum=$3}; /Device Model:/{DevName=$3} END { print DevTemp,DevSerNum,DevName }'`
  16. done
  17. echo


It doesnt return the HDD temps.

Code:
System Temperatures - Sun Nov 17 15:48:49 EST 2013
cat: /etc/version.freenas: No such file or directory
 
System Load: 0.16, 0.08, 0.08 
 
CPU Temperature:
dev.cpu.0.temperature: 28.0C
dev.cpu.1.temperature: 28.0C
 
Drive Activity Status
ada0:camcontrol: cam_lookup_pass: couldn't open /dev/xpt0
cam_lookup_pass: Permission denied
 ada1:camcontrol: cam_lookup_pass: couldn't open /dev/xpt0
cam_lookup_pass: Permission denied
 
 
HDD Temperature:
ada0
ada1


Any ideas? Do they have an internal temp sensor or do you add them?? Not sure if I am missing something
 

warri

Guru
Joined
Jun 6, 2011
Messages
1,193
Try executing the script as root.
 

tmacka88

Patron
Joined
Jul 5, 2011
Messages
268
Try executing the script as root.

Hi,

Ok, so running as root worked. I had to change SSH setting in Services to "Login with root password".

However, I don't wish to have this setting activate for security. How can I give my user root privileges without changing my group. Can I change my users "Shell" to something other than CSH?

Is it possible to set alerts with this data? e.g. if hdd temp is above 40 deg C to email me???

Also how do I modify this to show all HDD's not just ada. I have others such as da, but want this script above to show all hdd's.

Code:
 
#! /bin/bash
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.freenas
uptime | awk '{ print "\nSystem Load:",$8,$9,$10,"\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
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 /dev/$i | awk '/Temperature_Celsius/{DevTemp=$10;} /Serial Number:/{DevSerNum=$3}; /Device Model:/{DevName=$3} END { print DevTemp,DevSerNum,DevName }'`
done
echo
 

warri

Guru
Joined
Jun 6, 2011
Messages
1,193
You can just change to the root user with su in the shell - no need to allow root login directly.

If you want alerts, you need to extend the script and run it as regular cronjob. Then check for temperature threshold and send an email if necessary. A while ago I actually added email reports to the script: https://gist.github.com/fkleon/6147471 (should still work in 9.1.1 - you can use it as a base for extension if you wanted to)
To include all of your hard drives, either hard code the actual names or parse the output of camcontrol devlist.

If you have SMART alerts set up, they will also notify you if the temperatures get to high. You can even set an arbitrary temperature threshold. Using this is probably the better solution, since it's built into FreeNAS. And you get critical SMART reports for free as well.
 

tmacka88

Patron
Joined
Jul 5, 2011
Messages
268
ok cool Ill take a look thanks.

I still doesnt allow me to run it:
Code:
user@FreeNAS:~ % su /mnt/Volume4/bin/hdd-temp.sh
su: Sorry
user@FreeNAS:~ % sudo /mnt/Volume4/bin/hdd-temp.sh
Password:
Sorry, user user is not allowed to execute '/mnt/Volume4/bin/hdd-temp.sh' as root on FreeNAS.local.
 

warri

Guru
Joined
Jun 6, 2011
Messages
1,193
Just type su without anything else. You will be prompted to enter the root password. After that you're in a root shell. But yeah, use the built-in SMART if possible. ;)
 

tmacka88

Patron
Joined
Jul 5, 2011
Messages
268
Yeh I will set that up.

Now just curious to get this working though.

Still no luck.

Code:
user@FreeNAS:~ % su
su: Sorry


not sure whats going on...
 
Top