[Voyage-linux] checktemp script

jher (spam-protected)
Sat May 31 03:38:54 HKT 2008


    Hi folks,

I've rewritten the checktemp.sh script in perl and expanded it to detect 
temperatures on all three types of ALIX boards.  I personally only own 
model 1 and model 3 boards so if someone would mind testing it on a 
model 2 board, I'd be much obliged.

Free to distribute

----CUT----

#!/usr/bin/perl
#jher at fnord.org 2008
#Temperatures are in Celsius

system ("modprobe lm77");
system ("modprobe lm90");

#ALIX.1#
$A1_TEMP1="/sys/bus/i2c/drivers/w83627hf/9191-0290/temp1_input";
$A1_TEMP2="/sys/bus/i2c/drivers/w83627hf/9191-0290/temp2_input";
$A1_TEMP3="/sys/bus/i2c/drivers/w83627hf/9191-0290/temp3_input";

#ALIX.2#
$A2_temp1="/sys/bus/i2c/devices/0-0048/temp1_input";

#ALIX.3#
$A3_TEMP1="/sys/bus/i2c/devices/0-004c/temp1_input";
$A3_TEMP2="/sys/bus/i2c/devices/0-004c/temp2_input";

if ((-e $A1_TEMP1) && (-e $A1_TEMP2) && (-e $A1_TEMP3)) {
        open (TP1, $A1_TEMP1);
        $A1_1 = <TP1>;
        close TP1;
        open (TP2, $A1_TEMP2);
        $A1_2 = <TP2>;
        close TP2;
        open (TP3, $A1_TEMP3);
        $A1_3 = <TP3>;
        close TP3;
        $MB_TYPE=1;
}

if (-e $A2_TEMP1) {
        open (TP1, $A2_TEMP1);
        $A2_1 = <TP1>;
        close TP1;
        $MB_TYPE=2;
} else {
        system ("rmmod lm77");
}


if ((-e $A3_TEMP1) && (-e $A3_TEMP2)) {
        open (TP1, $A3_TEMP1);
        $A3_1 = <TP1>;
        close TP1;
        open (TP2, $A3_TEMP2);
        $A3_2 = <TP2>;
        close TP2;
        $MB_TYPE=3;
} else {
        system ("rmmod lm90");
        print "No temp sensors found. Exiting...\n";
        exit;
}


if ($MB_TYPE==1) {
        print "Detected ALIX.1# MB\n";
        $ALL_TEMP=(($A1_1+$A1_2+$A1_3) / 3000);
        $TEMP1 = ($A1_1 /1000);
        $TEMP2 = ($A1_2 /1000);
        $TEMP3 = ($A1_3 /1000);
} elsif ($MB_TYPE==2) {
        print "Detected ALIX.2# MB\n";
        $ALL_TEMP=$A2_1;
        $TEMP1 = ($A2_1 /1000);
        $TEMP2 = "";
        $TEMP3 = "";
} elsif ($MB_TYPE==3) {
        print "Detected ALIX.3# MB\n";
        $ALL_TEMP=(($A3_1 + $A3_2) / 2000);
        $TEMP1 = ($A3_1 /1000);
        $TEMP2 = ($A3_2 /1000);
        $TEMP3 = "";
}

chomp $TEMP1;
chomp $TEMP2;
chomp $TEMP3;

print "Current average board temp is $ALL_TEMP C\n";
print "Temp1 = $TEMP1 C\n";
if ($TEMP2 != "") {
        print "Temp2 = $TEMP2 C\n";
}
if ($TEMP3 != "") {
        print "Temp3 = $TEMP3 C\n";
}





More information about the Voyage-linux mailing list