made temp/fan speed tests more robust, good case from daniel-s-p showed problems

This commit is contained in:
inxi-svn 2009-07-27 19:08:00 +00:00
parent 43862494d7
commit 9218415849

52
inxi
View file

@ -1,7 +1,7 @@
#!/bin/bash
########################################################################
#### Script Name: inxi
#### version: 1.0.88-b1
#### version: 1.0.89-b1
#### Date: 26 July 2009
########################################################################
#### SPECIAL THANKS
@ -3018,7 +3018,9 @@ get_sensors_data()
BEGIN {
IGNORECASE=1
moboTemp=""
moboTempLock=""
cpuTemp=""
cpuTempLock=""
cpuFan=""
sysFan1=""
sysFan2=""
@ -3032,7 +3034,8 @@ get_sensors_data()
# there are some guesses here, and we will need a lot more data of
# different systems before this can be trusted much. Note that there
# is a hack here to handle cases where search term has 1 or 2 words with space
/M\/B Temp|SYS Temp|temp2:/ {
# also, the assumption that temp1 is cpu fan and temp2 is sys temp is not always right.
/M\/B Temp|MB Temp|SYS Temp|temp2:/ {
if ( $1 == "temp2:" ) {
tempData1=$2
tempData2=$3
@ -3041,9 +3044,15 @@ get_sensors_data()
tempData1=$3
tempData2=$4
}
moboTemp=gensub( /\+(.+)/, "\\1", 1, tempData1 )
if ( tempData2 ~ /C|F/ ){
moboTemp=moboTemp "°" tempData2
# this avoids problems if temp1 or temp2 are present also
if ( moboTempLock != "true" ){
moboTemp=gensub( /\+(.+)/, "\\1", 1, tempData1 )
if ( tempData2 ~ /C|F/ ){
moboTemp=moboTemp "°" tempData2
}
if ( $1 == "CPU" ) {
moboTempLock="true"
}
}
}
/CPU Temp|temp1:/ {
@ -3055,13 +3064,25 @@ get_sensors_data()
tempData1=$3
tempData2=$4
}
cpuTemp=gensub( /\+(.+)/, "\\1", 1, tempData1 )
if ( tempData2 ~ /C|F/ ){
cpuTemp=cpuTemp "°" tempData2
# this avoids problems if temp1 or temp2 are present also
if ( cpuTempLock != "true" ){
cpuTemp=gensub( /\+(.+)/, "\\1", 1, tempData1 )
if ( tempData2 ~ /C|F/ ){
cpuTemp=cpuTemp "°" tempData2
}
if ( $1 == "CPU" ) {
cpuTempLock="true"
}
}
}
/CPU Fan:/ {
cpuFan=$3
# note: can be cpu fan:, cpu fan speed:, etc
/CPU Fan(.*):/ {
if ( $3 ~ /(.+):/ ){
cpuFan=$4
}
else {
cpuFan=$3
}
}
/fan1:/ {
sysFan1=$2
@ -3074,6 +3095,17 @@ get_sensors_data()
}
END {
# rough hack to get rid of bad fan speeds for cases where fan1 and cpu fan speeds are the same:
if ( cpuFan == sysFan1 && cpuFan != 0 ) {
sysFan1 = ""
}
if ( cpuFan == sysFan2 && cpuFan != 0 ) {
sysFan2 = ""
}
if ( cpuFan == sysFan3 && cpuFan != 0 ) {
sysFan3 = ""
}
# if they are ALL null, print error message
if ( moboTemp == "" && cpuTemp == "" && cpuFan == "" && sysFan1 == "" && sysFan2 == "" && sysFan3 == "" ) {
print "No active sensors found. Have you configured your sensors yet?"