mirror of
https://github.com/smxi/inxi.git
synced 2024-11-17 00:31:19 +00:00
first attempt to handle irregular temp1/temp2/fan1/fan2 cases
This commit is contained in:
parent
3d188b3814
commit
8729fb72da
137
inxi
137
inxi
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
########################################################################
|
########################################################################
|
||||||
#### Script Name: inxi
|
#### Script Name: inxi
|
||||||
#### version: 1.0.89-b1
|
#### version: 1.0.90-b1
|
||||||
#### Date: 26 July 2009
|
#### Date: 26 July 2009
|
||||||
########################################################################
|
########################################################################
|
||||||
#### SPECIAL THANKS
|
#### SPECIAL THANKS
|
||||||
|
@ -3018,61 +3018,46 @@ get_sensors_data()
|
||||||
BEGIN {
|
BEGIN {
|
||||||
IGNORECASE=1
|
IGNORECASE=1
|
||||||
moboTemp=""
|
moboTemp=""
|
||||||
moboTempLock=""
|
|
||||||
cpuTemp=""
|
cpuTemp=""
|
||||||
cpuTempLock=""
|
moboTempReal=""
|
||||||
|
cpuTempReal=""
|
||||||
|
tempUnit=""
|
||||||
|
temp1=""
|
||||||
|
temp2=""
|
||||||
cpuFan=""
|
cpuFan=""
|
||||||
sysFan1=""
|
sysFan1=""
|
||||||
sysFan2=""
|
sysFan2=""
|
||||||
sysFan3=""
|
sysFan3=""
|
||||||
tempData1=""
|
cpuFanReal=""
|
||||||
tempData2=""
|
tempFanType="" # set to 1 or 2
|
||||||
}
|
}
|
||||||
# dumping the extra + signs, nobody has negative temps
|
# dumping the extra + signs, nobody has negative temps
|
||||||
# also, note gawk treats ° as a space, so we have to get the C/F data
|
# also, note gawk treats ° as a space, so we have to get the C/F data
|
||||||
# explicitly by testing for $3 or $4 ~ /C|F/ then concatenating manually
|
|
||||||
# there are some guesses here, and we will need a lot more data of
|
# 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
|
# 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
|
# is a hack here to handle cases where search term has 1 or 2 words with space
|
||||||
# also, the assumption that temp1 is cpu fan and temp2 is sys temp is not always right.
|
/^(M\/B|MB|SYS) Temp/ {
|
||||||
/^(M\/B|MB|SYS) Temp|^temp2:/ {
|
moboTemp=gensub( /\+(.+)/, "\\1", 1, $3 )
|
||||||
if ( $1 == "temp2:" ) {
|
if ( $4 ~ /C|F/ && tempUnit == "" ){
|
||||||
tempData1=$2
|
tempUnit="°" $4
|
||||||
tempData2=$3
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tempData1=$3
|
|
||||||
tempData2=$4
|
|
||||||
}
|
|
||||||
# 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/ {
|
||||||
|
cpuTemp=gensub( /\+(.+)/, "\\1", 1, $3 )
|
||||||
|
if ( $4 ~ /C|F/ && tempUnit == "" ){
|
||||||
|
tempUnit="°" $4
|
||||||
}
|
}
|
||||||
/^CPU Temp|^temp1:/ {
|
|
||||||
if ( $1 == "temp1:" ) {
|
|
||||||
tempData1=$2
|
|
||||||
tempData2=$3
|
|
||||||
}
|
}
|
||||||
else {
|
/^temp1:/ {
|
||||||
tempData1=$3
|
temp1=gensub( /\+(.+)/, "\\1", 1, $2 )
|
||||||
tempData2=$4
|
if ( $3 ~ /C|F/ && tempUnit == "" ){
|
||||||
|
tempUnit="°" $3
|
||||||
}
|
}
|
||||||
# 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"
|
|
||||||
}
|
}
|
||||||
|
/^temp2:/ {
|
||||||
|
temp2=gensub( /\+(.+)/, "\\1", 1, $2 )
|
||||||
|
if ( $3 ~ /C|F/ && tempUnit == "" ){
|
||||||
|
tempUnit="°" $3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# note: can be cpu fan:, cpu fan speed:, etc
|
# note: can be cpu fan:, cpu fan speed:, etc
|
||||||
|
@ -3095,23 +3080,85 @@ get_sensors_data()
|
||||||
}
|
}
|
||||||
|
|
||||||
END {
|
END {
|
||||||
# rough hack to get rid of bad fan speeds for cases where fan1/2/3 and cpu fan speed are the same:
|
# first we need to handle the case where we have to determine which temp/fan to use for cpu and mobo:
|
||||||
if ( cpuFan == sysFan1 && cpuFan != 0 ) {
|
if ( temp1 != "" && temp2 != "" ){
|
||||||
|
if ( temp1 >= temp2 ){
|
||||||
|
tempFanType=1
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tempFanType=2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# then get the real cpu temp
|
||||||
|
if ( cpuTemp != "" ){
|
||||||
|
cpuTempReal=cpuTemp
|
||||||
|
}
|
||||||
|
else if ( tempFanType != "" ){
|
||||||
|
if ( tempFanType == 1 ){
|
||||||
|
cpuTempReal=temp1
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cpuTempReal=temp2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( temp1 != "" ){
|
||||||
|
cpuTempReal=temp1
|
||||||
|
}
|
||||||
|
# then the real mobo temp
|
||||||
|
if ( moboTemp != "" ){
|
||||||
|
moboTempReal=moboTemp
|
||||||
|
}
|
||||||
|
else if ( tempFanType != "" ){
|
||||||
|
if ( tempFanType == 1 ) {
|
||||||
|
moboTempReal=temp2
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
moboTempReal=temp1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
moboTempReal=temp2
|
||||||
|
}
|
||||||
|
|
||||||
|
# then the cpu fan speed
|
||||||
|
if ( cpuFan != "" ) {
|
||||||
|
cpuFanReal=cpuFan
|
||||||
|
}
|
||||||
|
else if ( tempFanType == 1 && sysFan1 != "" ) {
|
||||||
|
cpuFanReal=sysFan1
|
||||||
|
}
|
||||||
|
else if ( tempFanType == 2 && sysFan2 != "" ) {
|
||||||
|
cpuFanReal=sysFan2
|
||||||
|
}
|
||||||
|
|
||||||
|
# then the mobo fan speed
|
||||||
|
if ( mobFan != "" ) {
|
||||||
|
moboFanReal=moboFan
|
||||||
|
}
|
||||||
|
else if ( tempFanType == 1 && sysFan1 != "" ) {
|
||||||
|
moboFanReal=sysFan2
|
||||||
|
}
|
||||||
|
else if ( tempFanType == 2 && sysFan2 != "" ) {
|
||||||
|
moboFanReal=sysFan1
|
||||||
|
}
|
||||||
|
|
||||||
|
# then double check the sys fans for duplication
|
||||||
|
if ( cpuFanReal == sysFan1 && cpuFanReal != 0 ) {
|
||||||
sysFan1 = ""
|
sysFan1 = ""
|
||||||
}
|
}
|
||||||
if ( cpuFan == sysFan2 && cpuFan != 0 ) {
|
if ( cpuFanReal == sysFan2 && cpuFanReal != 0 ) {
|
||||||
sysFan2 = ""
|
sysFan2 = ""
|
||||||
}
|
}
|
||||||
if ( cpuFan == sysFan3 && cpuFan != 0 ) {
|
if ( cpuFanReal == sysFan3 && cpuFanReal != 0 ) {
|
||||||
sysFan3 = ""
|
sysFan3 = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
# if they are ALL null, print error message
|
# if they are ALL null, print error message
|
||||||
if ( moboTemp == "" && cpuTemp == "" && cpuFan == "" && sysFan1 == "" && sysFan2 == "" && sysFan3 == "" ) {
|
if ( moboTempReal == "" && cpuTempReal == "" && cpuFanReal == "" && sysFan1Real == "" && sysFan2Real == "" && sysFan3Real == "" ) {
|
||||||
print "No active sensors found. Have you configured your sensors yet?"
|
print "No active sensors found. Have you configured your sensors yet?"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print moboTemp "," cpuTemp "," cpuFan "," sysFan1 "," sysFan2 "," sysFan3
|
print moboTempReal tempUnit "," cpuTempReal tempUnit "," cpuFanReal "," sysFan1 "," sysFan2 "," sysFan3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'
|
'
|
||||||
|
|
Loading…
Reference in a new issue