<div class="bbWrapper"><blockquote data-attributes="" data-quote="Yell" data-source="post: 41878"
class="bbCodeBlock bbCodeBlock--expandable bbCodeBlock--quote js-expandWatch">
<div class="bbCodeBlock-title">
<a href="/community/goto/post?id=41878"
class="bbCodeBlock-sourceJump"
rel="nofollow"
data-xf-click="attribution"
data-content-selector="#post-41878">Yell said:</a>
</div>
<div class="bbCodeBlock-content">
<div class="bbCodeBlock-expandContent js-expandContent ">
do you mean the "Drive Activity Status",<br />
if yes, sorry to shatter your dreams but there is a second ada filter xD<br />
<div class="bbCodeBlock bbCodeCode"><div class="type">Code:</div><pre>for i in $(sysctl -n kern.disks | awk '{for (i=NF; i!=0 ; i--) if(match($i, '/<span style="color: #FF0000">ada</span>/')) print $i }' ); do echo -n $i:; adastat $i; done; echo ; echo</pre></div><br />
<br />
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
</div>
<div class="bbCodeBlock-expandLink js-expandLink"><a role="button" tabindex="0">Click to expand...</a></div>
</div>
</blockquote><br />
Yes, I had caught that and modified accordingly, but the result of the adastat function call to the LSI card ports is:<br />
<br />
"camcontrol: error sending command"<br />
<br />
Seems that camcontrol command being sent here doesn't apply to the LSI ports the same as it does with onboard ports...<br />
<br />
If someone knows the correct command sequence, great, but really it's not as useful to me as the temps anyway.<br />
<br />
Thanks, Karl</div>
<div class="bbWrapper">well then to remove you errors readd that /ada/ for the adastat function call.<br />
Does LSI supply FreeBSD binary's ? Maybe the even ship a little control center to monitor the attached drives?</div>
<div class="bbWrapper"><blockquote data-attributes="" data-quote="Yell" data-source="post: 41901"
class="bbCodeBlock bbCodeBlock--expandable bbCodeBlock--quote js-expandWatch">
<div class="bbCodeBlock-title">
<a href="/community/goto/post?id=41901"
class="bbCodeBlock-sourceJump"
rel="nofollow"
data-xf-click="attribution"
data-content-selector="#post-41901">Yell said:</a>
</div>
<div class="bbCodeBlock-content">
<div class="bbCodeBlock-expandContent js-expandContent ">
well then to remove you errors readd that /ada/ for the adastat function call.<br />
Does LSI supply FreeBSD binary's ? Maybe the even ship a little control center to monitor the attached drives?
</div>
<div class="bbCodeBlock-expandLink js-expandLink"><a role="button" tabindex="0">Click to expand...</a></div>
</div>
</blockquote><br />
Like this: <a href="http://portsmon.freebsd.org/portoverview.py?category=sysutils&portname=megacli" target="_blank" class="link link--external" rel="nofollow ugc noopener">http://portsmon.freebsd.org/portoverview.py?category=sysutils&portname=megacli</a> ?</div>
<div class="bbWrapper">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<br />
<br />
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<br />
<br />
If the output could be a file with the format<br />
<br />
Timestamp; CPU1; CPU2; ...; CPUn; HHD SN1; HDD SN2; ...; HDD SNn<br />
28.02.2013 15:00:00; TEMP string ....<br />
28.02.2013 15:15:00; TEMP string ....<br />
etc<br />
<br />
then this could be imported into a spreadsheet, and a diagram over time generated.<br />
<br />
Volunteers?</div>
<div class="bbWrapper">can some one tell me how to install this?<br />
i am a total noob when it comes to linux + freenas<br />
<br />
also is there any better plugin out there that can show this in a spread sheet and log down the tempratures some how?</div>
<div class="bbWrapper">You don't need to "install it" - just run it. Here's a recent forum message, explaining how: <a href="http://forums.freenas.org/threads/how-to-install-scripts.13758/" target="_blank" class="link link--external" rel="nofollow ugc noopener">Running scripts</a><br />
<br />
If you want to automate it, read up on cron.<br />
<br />
btw, FreeNAS isn't a Linux distro. It's a descendant of Unix.</div>
<div class="bbWrapper">Learn about <a href="http://lmgtfy.com/?q=cron" target="_blank" class="link link--external" rel="nofollow ugc noopener">cron</a>. <br />
<br />
The FreeNAS manual has a section on how to create cron jobs.</div>
<div class="bbWrapper"><blockquote data-attributes="member: 23318" data-quote="NASbox" data-source="post: 27898"
class="bbCodeBlock bbCodeBlock--expandable bbCodeBlock--quote js-expandWatch">
<div class="bbCodeBlock-title">
<a href="/community/goto/post?id=27898"
class="bbCodeBlock-sourceJump"
rel="nofollow"
data-xf-click="attribution"
data-content-selector="#post-27898">NASbox said:</a>
</div>
<div class="bbCodeBlock-content">
<div class="bbCodeBlock-expandContent js-expandContent ">
<b>FreeNAS CPU / Hard Drive Temperature Script</b><br />
<br />
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.<br />
<br />
<div class="bbCodeBlock bbCodeCode"><div class="type">Code:</div><pre>
#! /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
</pre></div><br />
<br />
I also included/changed the following:<br />
<ul>
<li data-xf-list-type="ul">a few cosmetic labels</li>
<li data-xf-list-type="ul">included system load to correlate with the CPU termperature</li>
<li data-xf-list-type="ul">list the system disks in ascending order (ada0-adaX)</li>
<li data-xf-list-type="ul">omitted any disks other than adaX since they didn't apply on my system ( da0 = boot flash drive - no temp sensor).</li>
<li data-xf-list-type="ul">+++show drive status (00=stopped, FF=spinning) prior to temperature reading to determine if disk was active (smartctl causes disk to start spinning)</li>
</ul>+++ Credit for the drive spin down status belongs to the authors of this thread<br />
<a href="http://forums.freenas.org/showthread.php?2068-How-to-find-out-if-a-drive-is-spinning-down-properly&highlight=camcontrol+cmd+-a" target="_blank" class="link link--external" rel="nofollow ugc noopener">http://forums.freenas.org/showthread.php?2068-How-to-find-out-if-a-drive-is-spinning-down-properly&highlight=camcontrol cmd -a</a><br />
<br />
Hope someone finds this useful and can improve it some more.
</div>
<div class="bbCodeBlock-expandLink js-expandLink"><a role="button" tabindex="0">Click to expand...</a></div>
</div>
</blockquote>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?</div>
<div class="bbWrapper"><blockquote data-attributes="member: 23318" data-quote="NASbox" data-source="post: 27898"
class="bbCodeBlock bbCodeBlock--expandable bbCodeBlock--quote js-expandWatch">
<div class="bbCodeBlock-title">
<a href="/community/goto/post?id=27898"
class="bbCodeBlock-sourceJump"
rel="nofollow"
data-xf-click="attribution"
data-content-selector="#post-27898">NASbox said:</a>
</div>
<div class="bbCodeBlock-content">
<div class="bbCodeBlock-expandContent js-expandContent ">
<b>FreeNAS CPU / Hard Drive Temperature Script</b><br />
<br />
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.<br />
<br />
<div class="bbCodeBlock bbCodeCode"><div class="type">Code:</div><pre>
#! /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
</pre></div><br />
<br />
I also included/changed the following:<br />
<ul>
<li data-xf-list-type="ul">list the system disks in ascending order (ada0-adaX)</li>
</ul>.
</div>
<div class="bbCodeBlock-expandLink js-expandLink"><a role="button" tabindex="0">Click to expand...</a></div>
</div>
</blockquote> <br />
<br />
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.<br />
<br />
Thanks</div>
<div class="bbWrapper"><blockquote data-attributes="member: 23318" data-quote="NASbox" data-source="post: 27898"
class="bbCodeBlock bbCodeBlock--expandable bbCodeBlock--quote js-expandWatch">
<div class="bbCodeBlock-title">
<a href="/community/goto/post?id=27898"
class="bbCodeBlock-sourceJump"
rel="nofollow"
data-xf-click="attribution"
data-content-selector="#post-27898">NASbox said:</a>
</div>
<div class="bbCodeBlock-content">
<div class="bbCodeBlock-expandContent js-expandContent ">
<b>FreeNAS CPU / Hard Drive Temperature Script</b><br />
<br />
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.<br />
<br />
<div class="bbCodeBlock bbCodeCode"><div class="type">Code:</div><pre>
#! /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
</pre></div><br />
<br />
I also included/changed the following:<br />
<ul>
<li data-xf-list-type="ul">list the system disks in ascending order (ada0-adaX)</li>
</ul>.
</div>
<div class="bbCodeBlock-expandLink js-expandLink"><a role="button" tabindex="0">Click to expand...</a></div>
</div>
</blockquote> <br />
<br />
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.<br />
<br />
Thanks</div>
<div class="bbWrapper"><blockquote data-attributes="member: 23318" data-quote="NASbox" data-source="post: 27898"
class="bbCodeBlock bbCodeBlock--expandable bbCodeBlock--quote js-expandWatch">
<div class="bbCodeBlock-title">
<a href="/community/goto/post?id=27898"
class="bbCodeBlock-sourceJump"
rel="nofollow"
data-xf-click="attribution"
data-content-selector="#post-27898">NASbox said:</a>
</div>
<div class="bbCodeBlock-content">
<div class="bbCodeBlock-expandContent js-expandContent ">
<b>FreeNAS CPU / Hard Drive Temperature Script</b><br />
<br />
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.<br />
<br />
<div class="bbCodeBlock bbCodeCode"><div class="type">Code:</div><pre>
#! /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
</pre></div><br />
<br />
I also included/changed the following:<br />
<ul>
<li data-xf-list-type="ul">list the system disks in ascending order (ada0-adaX)</li>
</ul>.
</div>
<div class="bbCodeBlock-expandLink js-expandLink"><a role="button" tabindex="0">Click to expand...</a></div>
</div>
</blockquote> <br />
<br />
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.<br />
<br />
<br />
Thanks</div>
<div class="bbWrapper"><blockquote data-attributes="member: 388" data-quote="warri" data-source="post: 83474"
class="bbCodeBlock bbCodeBlock--expandable bbCodeBlock--quote js-expandWatch">
<div class="bbCodeBlock-title">
<a href="/community/goto/post?id=83474"
class="bbCodeBlock-sourceJump"
rel="nofollow"
data-xf-click="attribution"
data-content-selector="#post-83474">warri said:</a>
</div>
<div class="bbCodeBlock-content">
<div class="bbCodeBlock-expandContent js-expandContent ">
Try executing the script as root.
</div>
<div class="bbCodeBlock-expandLink js-expandLink"><a role="button" tabindex="0">Click to expand...</a></div>
</div>
</blockquote> <br />
Hi,<br />
<br />
Ok, so running as root worked. I had to change SSH setting in Services to "Login with root password". <br />
<br />
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?<br />
<br />
Is it possible to set alerts with this data? e.g. if hdd temp is above 40 deg C to email me??? <br />
<br />
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.<br />
<br />
<div class="bbCodeBlock bbCodeCode"><div class="type">Code:</div><pre>
#! /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</pre></div></div>
<div class="bbWrapper">You can just change to the root user with <b>su</b> in the shell - no need to allow root login directly.<br />
<br />
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: <a href="https://gist.github.com/fkleon/6147471" target="_blank" class="link link--external" rel="nofollow ugc noopener">https://gist.github.com/fkleon/6147471</a> (should still work in 9.1.1 - you can use it as a base for extension if you wanted to)<br />
To include all of your hard drives, either hard code the actual names or parse the output of camcontrol devlist.<br />
<br />
If you have SMART alerts set up, they will also notify you if the temperatures get to high. You can even <a href="http://doc.freenas.org/index.php/S.M.A.R.T." target="_blank" class="link link--external" rel="nofollow ugc noopener">set an arbitrary temperature threshold</a>. Using this is probably the better solution, since it's built into FreeNAS. And you get critical SMART reports for free as well.</div>
<div class="bbWrapper">ok cool Ill take a look thanks.<br />
<br />
I still doesnt allow me to run it:<br />
<div class="bbCodeBlock bbCodeCode"><div class="type">Code:</div><pre>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.</pre></div></div>
<div class="bbWrapper">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. ;)</div>
<div class="bbWrapper">Yeh I will set that up.<br />
<br />
Now just curious to get this working though.<br />
<br />
Still no luck.<br />
<br />
<div class="bbCodeBlock bbCodeCode"><div class="type">Code:</div><pre>user@FreeNAS:~ % su
su: Sorry</pre></div><br />
<br />
not sure whats going on...</div>