View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 4 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Tue Jan 03, 2006 4:38 am 
Offline
Joined: Wed Aug 24, 2005 3:44 am
Posts: 210
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 03, 2006 6:43 am 
Offline
Joined: Sun Jun 12, 2005 2:39 pm
Posts: 464
Location: UK
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!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 03, 2006 7:14 am 
Offline
Joined: Wed Aug 24, 2005 3:44 am
Posts: 210
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 03, 2006 7:42 am 
Offline
Joined: Sun Jun 12, 2005 2:39 pm
Posts: 464
Location: UK
ahhh I couldnt work out what all the extra stuff was! (perl newbie!)


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu