LinHES Forums
http://forum.linhes.org/

web based cpu and mobo temp loging script
http://forum.linhes.org/viewtopic.php?f=3&t=7673
Page 1 of 1

Author:  declanh [ Tue Jan 03, 2006 4:38 am ]
Post subject:  web based cpu and mobo temp loging script

im sure there is a more elegant way of doing this ...
but knocked this script together and thought i would share it

Code:
cat mbscr.pl
open (FO,">/var/www/motherboard.htm");
print FO "<html><br>\n";
print FO "<b>Motherboard and CPU temperature readings...</b><br>\n";
close FO;
$m=1;
while ($i++ < ((24*60)/$m) )
{
  open (FP,"/usr/bin/mbmon -c1|");
  while ($rec = <FP>)
   {
    chomp $rec;
    print "Value of \$rec = $rec \n";
    open (FO,">>/var/www/motherboard.htm");
    $now_string = localtime;
    if ($rec =~m/Temp.= (\d+\.\d*), (\d+\.\d*)/i)
     {  print FO  "Mobo = $1 CPU = $2 [$now_string]<br>\n" if ($rec =~m/Temp.= (\d+\.\d*), (\d+\.\d*)/i);
        sleep (60*$m);
        print "Cycle $i \n";
     }
    close FO;
   }
  close FP;
}


i have this in my crontab with an entry thus
Code:
00     08     *     *     *         /usr/bin/perl /usr/declan/mbscr.pl


you can vary the logging frequency (in mins by changing the value of $m)

any you can view it by
http://ip_of_your_machine/motherboard.htm


declan

Author:  mad_paddler [ Tue Jan 03, 2006 6:43 am ]
Post subject: 

This script is a great idea! However this may be a more elegant solution (I'm still a perl newbie...) Rather than writing the results to a file, you could do it as a cgi script and output the results of mbmon directly. Save the code below in /usr/lib/cgi-bin/temp.cgi and chmod 755

Code:
#!/usr/bin/perl
# Simple CPU temp script
#

$output = `/usr/bin/mbmon -c1`;
print "Content-type: text/html\n\n";
print "<html>\n";
print "\n";
print "<head>\n";
print "<title>Simple CPU temp script</title>\n";
print "</head>\n";
print "\n";
print "<body>\n";
print "$output \n";
print "</body>\n";
print "</html\n";


point your browser at http://ip_of_mythtv/cgi-bin/temp.cgi

and you should get the output of mbmon in realtime!

Author:  declanh [ Tue Jan 03, 2006 7:14 am ]
Post subject: 

mad_paddler wrote:
This script is a great idea! However this may be a more elegant solution (I'm still a perl newbie...) Rather than writing the results to a file, you could do it as a cgi script and output the results of mbmon directly. Save the code below in /usr/lib/cgi-bin/temp.cgi and chmod 755

Code:
#!/usr/bin/perl
# Simple CPU temp script
#

$output = `/usr/bin/mbmon -c1`;
print "Content-type: text/html\n\n";
print "<html>\n";
print "\n";
print "<head>\n";
print "<title>Simple CPU temp script</title>\n";
print "</head>\n";
print "\n";
print "<body>\n";
print "$output \n";
print "</body>\n";
print "</html\n";


point your browser at http://ip_of_mythtv/cgi-bin/temp.cgi

and you should get the output of mbmon in realtime!


great idea but not exactly equivalent - my script gives me a history over the whole day - which was what i was trying to check - what the max cpu temp of the day was

Author:  mad_paddler [ Tue Jan 03, 2006 7:42 am ]
Post subject: 

ahhh I couldnt work out what all the extra stuff was! (perl newbie!)

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/