Gentoo Wiki ArchivesGentoo Wiki

Lm_sensors/Script

The following script add the cpu temperature and the time in a csv file that can be imported in openoffice calc in order to draw a chart of the temperature
very useful in order to store the temperature and to see them later for example:


#!/usr/bin/perl 
#This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 

while (1) {

$sensors =`sensors | grep temp2:`; 
#debug#print "$sensors\n" ; 

($temp2,$other) = split "     ", $sensors; 
#debug#print "$temp2 \n"; 
#debug#print "$other \n"; 

($temp,$not_interesting) = split "  ", $other; 
#debug#print "temperature=$temp\n"; 

($temperature,$c) = split " ", $temp; 
#debug#print "$temperature \n";

#transform +60 in 60
$temperature =~ s/^\+//;
print "$temperature \n";

#show the time
$time_function = time();
$time_01 = scalar localtime($time_function),"\n";
#debug#print "$time_01 \n";
($week,$month,$day,$time,$year) = split " " ,$time_01; #time format:Fri Aug 11 17:30:16 2006
print "$time \n";


#write to a file
open (FILE,">>results.csv");
print FILE "$time,$temperature \n";
close;

sleep(10);
}
Retrieved from "http://www.gentoo-wiki.info/Lm_sensors/Script"

Last modified: Fri, 11 Jul 2008 00:33:00 +1000 Hits: 4,034

Created by NickStallman.net, Luxury Homes Australia
Real estate agents should list their apartments, townhouses and units in Australia.