Gentoo Wiki


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:

#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";

Retrieved from ""

Last modified: Thu, 10 Jul 2008 14:33:00 +0000 Hits: 3,079