[ale] [OT] how do I monitor the "weather" in my computer room

Ron Frazier (ALE) atllinuxenthinfo at techstarship.com
Tue Jun 11 01:49:50 EDT 2013


Hi all,

As promised, here are the final versions of the scripts used to monitor 
the temperatures on my mint machine and provide the data via web page.

The following commands start everything up:

# section to start temperature monitoring scripts

cd ~/temperature-scripts

# commands to start the sensor monitoring script

mate-terminal --geometry=82x5+0450+800 -t "Monitor Temperature Sensors" 
-e "watch -n 15 ./checktemps.sh" &>/dev/null &

# commands to start the mini temperature web server

mate-terminal --geometry=82x5+01800+800 -t "Run Temperature Web Server" 
-e ./startminitempwebserver.sh &>/dev/null &

----------------------

Here is the checktemps.sh which is executed every 15 sec by the watch 
command.  I made some mods to make this a more standard html file.:

#!/bin/bash

# Script to monitor temperatures on the pc and save data to an html file.
# This script can be called repeatedly using the watch command.
# Ron Frazier - 2013-06-07

cd ~/temperature-scripts

{

# read the temperature sensors and create temporary html file

echo '<!DOCTYPE html>'
echo '<html>'

echo '<head>'
echo '<title>Bugs01 Temperatures</title>'
echo '</head>'

echo '<body>'

echo 'Bugs01 Temperatures'
echo '<p>'

date
echo '<p>'

echo 'CPU - '
sensors | grep 'temp1'
echo '<p>'

# used visudo to set hddtemp to not require sudo password

echo 'HDD1 - '
sudo -S hddtemp /dev/sda
echo '<p>'

echo 'HDD2 - '
sudo -S hddtemp /dev/sdb
echo '<p>'

echo 'GPU0 - '
aticonfig --adapter=0 --odgt
echo '<p>'

echo 'GPU1 - '
aticonfig --adapter=1 --odgt
echo '<p>'

echo 'GPU2 - '
aticonfig --adapter=2 --odgt
echo '<p>'

echo '</body>'

echo '</html>'
echo ""

} > ./scratch/scratch-temperature.html

# copy the temporary file to the usable file to prevent partial file 
retrieval

mv ./scratch/scratch-temperature.html ./temperature.html

---------------------

Here is the startminitempwebserver.sh which runs netcat continuously to 
serve up my 1 web page.  You could do many different pages on different 
ports if you wanted.  I was never able to get proper formatting on 
alternate ports by using the content type definitions.  This script 
embeds some headers into the web page before it is served.  This makes 
the browser happy.  Not quite sure what all this does, found it on 
google, but it works.:

#!/bin/bash
cd ~/temperature-scripts

while true; do { echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c 
<./temperature.html)\r\n\r\n"; cat ./temperature.html; } | nc -l 56789; done

---------------------

I had to modify the sudoers file with visudo to allow use of hddtemp 
without a sudo password.:

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        
secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

# line to remove password requirement for hddtemp - may have to be at 
end of file
ron     ALL=(ALL) NOPASSWD: /usr/sbin/hddtemp

---------------

Here is a sample of the html file that gets generated every 15 seconds.  
I can view this from any computer on my network that's attached to the 
same router.  I could also possibly upload it to dropbox every 5 
minutes, but I don't know if they'd like that.

Bugs01 Temperatures

Sun Jun 9 10:19:36 EDT 2013

CPU - temp1: +44.6°C (high = +70.0°C)

HDD1 - /dev/sda: ST9320320AS: 26°C

HDD2 - /dev/sdb: ST95005620AS: 29°C

GPU0 - Adapter 0 - AMD Radeon HD 7800 Series Sensor 0: Temperature - 
81.00 C

GPU1 - Adapter 1 - AMD Radeon HD 6700 Series Sensor 0: Temperature - 
77.00 C

GPU2 - Adapter 2 - AMD Radeon HD 7800 Series Sensor 0: Temperature - 
71.00 C

------------------

Thanks for the help in solving my problem.  Anyone is welcome to use the 
scripts.

Sincerely,

Ron


On 6/7/2013 8:11 PM, Ron Frazier (ALE) wrote:
> Hi all,
>
> Hip Hip Hurray!
>
> I finally got my remote "weather" monitoring system running.  It was 
> NOT easy.  I spent all day (thus far) rewriting and editing scripts 
> and, among other things, troubleshooting problems with commands that 
> require sudo and funky web page formatting from netcat.  Thanks to all 
> for the relevant and specific tips you provided.  I wouldn't have been 
> able to do this without your help in any reasonable about of time.  I 
> can now monitor the temperatures inside my downstairs computer from a 
> web browser on my upstairs computer as long as they're on the same 
> wifi router.  I can even monitor it from my tablet.  Very cool!
>
> I have implemented a number of the tips you all gave me.  Many 
> different script files are involved, which I hope to post before next 
> week, so others can benefit from the information.  I have also been 
> working on other technologies, including running spinrite to test a 
> hard drive in a vm while I'm doing other things with the computer, 
> which was not possible for me before.  I wrote another post about that.
>
> You might find this interesting.
>
> https://dl.dropboxusercontent.com/u/9879631/master-control.png
>
> This is what I call my master control screen on a second monitor.  
> That's where I keep track of a number of things I have going on in the 
> pc.
>
> Here's what each window does numbering from left to right:
>
> Top Row:
>
> window 1: monitors litecoin mining
> window 2: monitors the cpu cores
> window 3: spinrite running in a vm - YEA! (very slowly - BOO!)
>
> Middle Row:
>
> window 4: litecoin wallet
> window 5: monitors local gpu 1 - mainly temperature
> window 6: monitors local gpu 2 - mainly temperature
> window 7: monitors local weather radar - so I can shut down if storms 
> are coming
>
> Bottom Row:
>
> window 8: monitors litecoin pricing
> window 9: monitors temperatures in the basement computer - YEA!
>
> Reestablishing all these things when I reboot is a major pain, so I 
> try not to do so too often.
>
> I'm very pleased with the results today, although I had hoped it would 
> go faster.  All the screens auto update.  For the ones that are 
> browser based, I make extensive use of an auto update plugin for 
> firefox and of the ability to scale the web page in firefox by hitting 
> the ctrl- and ctrl+ keys.  I then size the window to fit the image.
>
> Here's the plugin: http://reloadevery.mozdev.org/
>
> There is one bug in my temperature monitoring system.  On any 
> particular refresh of the web page for the Bugs01 machine, it displays 
> the web page that was active at the time of the previous refresh.  I'm 
> assuming that netcat precaches the file it will be transmitting when 
> it starts and then waits for a request.  I'm not too worried about it 
> since I have the web page refreshing every 1 minute.  On the server 
> side, it generates a new temperature.html every 15 seconds.  So, the 
> data I'm seeing on the screen could be up to 2 minutes out of date 
> depending on the timing of the refresh cycle.  That's ok for my purposes.
>
> A side effect of having this display is that I can tell if the Bugs01 
> clock is wandering.  I haven't set ntp up on that one yet.
>
> Again, thanks for all the help.
>
> Sincerely,
>
> Ron
>
>

-- 

(PS - If you email me and don't get a quick response, you might want to
call on the phone.  I get about 300 emails per day from alternate energy
mailing lists and such.  I don't always see new email messages very quickly.)

Ron Frazier
770-205-9422 (O)   Leave a message.
linuxdude AT techstarship.com
Litecoin: LZzAJu9rZEWzALxDhAHnWLRvybVAVgwTh3
Bitcoin: 15s3aLVsxm8EuQvT8gUDw3RWqvuY9hPGUU

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20130611/c9291879/attachment-0001.html>


More information about the Ale mailing list