{"id":1460,"date":"2011-08-21T22:04:59","date_gmt":"2011-08-21T21:04:59","guid":{"rendered":"http:\/\/www.haydnwilliams.com\/blog\/?p=1460"},"modified":"2022-04-11T21:34:00","modified_gmt":"2022-04-11T20:34:00","slug":"uhs-3-hardware-monitoring","status":"publish","type":"post","link":"https:\/\/www.haydnwilliams.com\/blog\/uhs-3-hardware-monitoring\/","title":{"rendered":"UHS3 &#8211; Hardware Monitoring"},"content":{"rendered":"<p>Having built and configured your nice new machine, you may want to keep an eye on temperatures and fan speeds. The main package used to do this is <strong>lm-sensors<\/strong>, which can be installed using <strong>apt-get<\/strong>.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo apt-get install lm-sensors<\/pre>\n<p>Although there is <a title=\"Ubuntu Community Documentation - Sensor Install How To\" href=\"https:\/\/help.ubuntu.com\/community\/SensorInstallHowto\" target=\"_blank\" rel=\"noopener\">basic info<\/a> for older versions of Ubuntu in the <a title=\"Ubuntu Community Documentation\" href=\"https:\/\/help.ubuntu.com\/community\" target=\"_blank\" rel=\"noopener\">Community Documentation<\/a>, there are very good instructions on <a title=\"compdigitec.com\" href=\"http:\/\/www.compdigitec.com\/labs\/2008\/07\/18\/measure-cpu-temp-in-ubuntu\/\" target=\"_blank\" rel=\"noopener\">this page <\/a>on compdigitec.com. Once you&#8217;ve installed <strong>lm-sensors<\/strong>, you can view data at any point by running the command <strong>sensors<\/strong> in a terminal window. The compdigitec article was published in 2008 and so still mentions a &#8216;panel&#8217; as used to be found in GNOME 2. These are defunct in Unity, which comes as the default on Ubuntu 11.04, so if you want a GUI representation of your temperature and\/or fan data then <em>Psensor<\/em> is probably the way to go. You&#8217;ll need to add a new software repository as it isn&#8217;t included in the standard ones; ubuntuguide.net has a good walkthrough <a title=\"ubuntuguide.net\" href=\"http:\/\/ubuntuguide.net\/monitor-cpunvdia-gpushard-disk-temperature-in-ubuntu-using-psensor\" target=\"_blank\" rel=\"noopener\">here<\/a>. Unfortunately all the motherboard \/ chipset temperatures and fans are just labelled temp1, temp2 and temp3, so although you know which are your CPU temps you might not be able to identify the others.<\/p>\n<div id=\"attachment_1506\" style=\"width: 510px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1506\" class=\"size-full wp-image-1506\" title=\"Psensor window showing CPU and general temperatures.\" src=\"http:\/\/www.haydnwilliams.com\/blog\/wp-content\/uploads\/2011\/06\/20110619d.jpg\" alt=\"Psensor window showing CPU and general temperatures.\" width=\"500\" height=\"177\" srcset=\"https:\/\/www.haydnwilliams.com\/blog\/wp-content\/uploads\/2011\/06\/20110619d.jpg 500w, https:\/\/www.haydnwilliams.com\/blog\/wp-content\/uploads\/2011\/06\/20110619d-300x106.jpg 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><p id=\"caption-attachment-1506\" class=\"wp-caption-text\">Psensor window showing CPU and general temperatures.<\/p><\/div>\n<p><strong>sensors<\/strong> didn&#8217;t pick up hard drive temperatures for me, but you can get those by running:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo hddtemp \/dev\/sda<\/pre>\n<p>This assumes you have a SATA drive; for older devices, use <strong>\/dev\/hda\/<\/strong> in place of <strong>\/dev\/sda<\/strong>. For more generic information about your hard drive, you can run the similar <strong>hddparm<\/strong>, <em>i.e.<\/em>:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo hddparm \/dev\/sda<\/pre>\n<p>Both were installed on my system by default, but can be obtained using <strong>apt-get<\/strong> if required. Thanks to embraceubuntu.com for <a title=\"embraceubuntu.com\" href=\"http:\/\/embraceubuntu.com\/2005\/09\/18\/find-the-temperature-of-your-hard-drive\/\" target=\"_blank\" rel=\"noopener\">pointing these out.<\/a> Finally, I&#8217;ve put together a little script to pull the main information from my system into an easy-to-read few lines. Feel free to use and modify for your system as required:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">#!\/bin\/bash\r\n\r\n# Get output of sensors\r\n`sensors &amp;gt; ~\/sensors.out`\r\n\r\n# I&#039;m sure there&#039;s a way to do this using arrays and loops instead of repeating code\r\n# I just haven&#039;t found it yet\r\n\r\n# Parse output to get core temperatures\r\nCORE0=`grep &#039;^Core 0&#039; ~\/sensors.out | awk &#039;{print $3}&#039;`\r\nCORE0=${CORE0#*+}\r\nCORE0=&quot;${CORE0%.*}\u00b0C&quot;\r\nCORE1=`grep &#039;^Core 1&#039; ~\/sensors.out | awk &#039;{print $3}&#039;`\r\nCORE1=${CORE1#*+}\r\nCORE1=&quot;${CORE1%.*}\u00b0C&quot;\r\n\r\n# Parse output to get other temperatures\r\nTEMP1=`grep &#039;^temp1&#039; ~\/sensors.out | awk &#039;{print $2}&#039;`\r\nTEMP1=${TEMP1#*+}\r\nTEMP1=&quot;${TEMP1%.*}\u00b0C&quot;\r\nTEMP2=`grep &#039;^temp2&#039; ~\/sensors.out | awk &#039;{print $2}&#039;`\r\nTEMP2=${TEMP2#*+}\r\nTEMP2=&quot;${TEMP2%.*}\u00b0C&quot;\r\nTEMP3=`grep &#039;^temp3&#039; ~\/sensors.out | awk &#039;{print $2}&#039;`\r\nTEMP3=${TEMP3#*+}\r\nTEMP3=&quot;${TEMP3%.*}\u00b0C&quot;\r\n\r\n#Display core temperatures\r\necho &quot;Core 0:\u00a0\u00a0 $CORE0&quot;\r\necho &quot;Core 1:\u00a0\u00a0 $CORE1&quot;\r\n\r\n# Display other temperatures\r\necho &quot;Temp 1:\u00a0\u00a0 $TEMP1&quot;\r\necho &quot;Temp 2:\u00a0\u00a0 $TEMP2&quot;\r\necho &quot;Temp 3:\u00a0\u00a0 $TEMP3&quot;\r\n\r\n# Check hddtemp, if using sudo\r\nif &#x5B; &quot;$(id -un)&quot; = &quot;root&quot; ]; then\r\nsudo hddtemp \/dev\/sda | awk &#039;{print &quot;HDD:\u00a0\u00a0\u00a0\u00a0 &quot;,$4}&#039;\r\nfi\r\n\r\n# Display fan speed\r\nFANSPEED=`grep &#039;fan1&#039; ~\/sensors.out | awk &#039;{print $2}&#039;`\r\necho &quot;Fan:\u00a0\u00a0\u00a0\u00a0\u00a0 $FANSPEED RPM&quot;\r\n\r\n# Clean up\r\nrm ~\/sensors.out<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Having built and configured your nice new machine, you may&#46;&#46;&#46;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[658,659,660],"class_list":["post-1460","post","type-post","status-publish","format-standard","hentry","category-it","tag-cpu-temperature","tag-hard-drive-temperature","tag-hardware-monitoring"],"_links":{"self":[{"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/posts\/1460","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/comments?post=1460"}],"version-history":[{"count":0,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/posts\/1460\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/media?parent=1460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/categories?post=1460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.haydnwilliams.com\/blog\/wp-json\/wp\/v2\/tags?post=1460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}