From 11b7ae3365040e1aad4c6608f11be0ae875fd7db Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Mon, 28 Apr 2014 20:37:20 +0000 Subject: [PATCH] New version, new tarball. This is an attempt to make -s accurate more of the time, particularly with fringe or broken sensors outputs. See inxi issue 58 for details. http://code.google.com/p/inxi/issues/detail?id=58 Added temp3, and an override to capture cases where temp3 is the actual cpu temp. Added PECI overrides for cases like msi/asus mobos have defective CPUTIN return data. Added core0 overrides as well, for cases where the temp returned is too low. It is absolutely 100% guaranteed that these changes will break some outputs that were working, but it's also certain that I believe that more wrong outputs will be corrected. With sensors, really the only way you can get reliable sensors is to use the lm-sensors config files for your motherboard, then set: CPU: temp and MB: temp explicitly. inxi will always use CPU: or MB: to override anything found. --- inxi | 128 ++++++++++++++++++++++++++++++++++++++----------- inxi.changelog | 28 +++++++++++ 2 files changed, 128 insertions(+), 28 deletions(-) diff --git a/inxi b/inxi index 257a32b..febf4f5 100755 --- a/inxi +++ b/inxi @@ -1,8 +1,8 @@ #!/usr/bin/env bash ######################################################################## #### Script Name: inxi -#### Version: 2.1.23 -#### Date: 2014-04-27 +#### Version: 2.1.24 +#### Date: 2014-04-28 #### Patch Number: 00 ######################################################################## #### SPECIAL THANKS @@ -1775,6 +1775,8 @@ debug_data_collector() df -H &> $debug_data_dir/bsd-df-H-no-excludes.txt df -k -T &> $debug_data_dir/bsd-df-k-T-no-excludes.txt df -k &> $debug_data_dir/bsd-df-k-no-excludes.txt + atacontrol list &> $debug_data_dir/bsd-atacontrol-list.txt + camcontrol devlist &> $debug_data_dir/bsd-camcontrol-devlist.txt # bsd tool mount &> $debug_data_dir/mount.txt btrfs filesystem show &> $debug_data_dir/btrfs-filesystem-show.txt @@ -8192,7 +8194,8 @@ get_sensors_data() gawk -F ':' -v userCpuNo="$SENSORS_CPU_NO" ' BEGIN { IGNORECASE=1 - core0Temp="" # only if all else fails... + core0Temp="" # these only if all else fails... + cpuPeciTemp="" # use if temps are missing or wrong cpuTemp="" cpuTempReal="" fanWorking="" @@ -8207,6 +8210,8 @@ get_sensors_data() sysFanString="" temp1="" temp2="" + temp3="" + tempDiff=20 # for C, handled for F after that is determined tempFanType="" # set to 1 or 2 tempUnit="" tempWorking="" @@ -8235,6 +8240,8 @@ get_sensors_data() tempUnit=tempWorkingUnit } } + # issue 58 msi/asus show wrong for CPUTIN so overwrite it if PECI 0 is present + # http://www.spinics.net/lists/lm-sensors/msg37308.html /^CPU(.*)\+([0-9]+)(.*)[ \t°](C|F)/ && $2 ~ /^[ \t]*\+([0-9]+)/ { cpuTemp=gensub( /[ \t]+\+([0-9\.]+)(.*)/, "\\1", 1, $2 ) tempWorkingUnit=gensub( /[ \t]+\+([0-9\.]+)[ \t°]+([CF])(.*)/, "\\2", 1, $2 ) @@ -8242,6 +8249,13 @@ get_sensors_data() tempUnit=tempWorkingUnit } } + /^PECI[[:space:]]Agent[[:space:]]0(.*)\+([0-9]+)(.*)[ \t°](C|F)/ && $2 ~ /^[ \t]*\+([0-9]+)/ { + cpuPeciTemp=gensub( /[ \t]+\+([0-9\.]+)(.*)/, "\\1", 1, $2 ) + tempWorkingUnit=gensub( /[ \t]+\+([0-9\.]+)[ \t°]+([CF])(.*)/, "\\2", 1, $2 ) + if ( tempWorkingUnit ~ /^C|F$/ && tempUnit == "" ){ + tempUnit=tempWorkingUnit + } + } /^(P\/S|Power)(.*)\+([0-9]+)(.*)[ \t°](C|F)/ && $2 ~ /^[ \t]*\+([0-9]+)/ { psuTemp=gensub( /[ \t]+\+([0-9\.]+)(.*)/, "\\1", 1, $2 ) tempWorkingUnit=gensub( /[ \t]+\+([0-9\.]+)[ \t°]+([CF])(.*)/, "\\2", 1, $2 ) @@ -8249,6 +8263,7 @@ get_sensors_data() tempUnit=tempWorkingUnit } } + # for temp1/2 only use temp1/2 if they are null or greater than the last ones $1 ~ /^temp1$/ && $2 ~ /^[ \t]*\+([0-9]+)/ { tempWorking=gensub( /[ \t]+\+([0-9\.]+)(.*)/, "\\1", 1, $2 ) if ( temp1 == "" || tempWorking > 0 ) { @@ -8269,10 +8284,20 @@ get_sensors_data() tempUnit=tempWorkingUnit } } - + # temp3 is only used as an absolute override for systems with all 3 present + $1 ~ /^temp3$/ && $2 ~ /^[ \t]*\+([0-9]+)/ { + tempWorking=gensub( /[ \t]+\+([0-9\.]+)(.*)/, "\\1", 1, $2 ) + if ( temp3 == "" || tempWorking > 0 ) { + temp3=tempWorking + } + tempWorkingUnit=gensub( /[ \t]+\+([0-9\.]+)[ \t°]+([CF])(.*)/, "\\2", 1, $2 ) + if ( tempWorkingUnit ~ /^C|F$/ && tempUnit == "" ){ + tempUnit=tempWorkingUnit + } + } # final fallback if all else fails, funtoo user showed sensors putting # temp on wrapped second line, not handled - /^(core0|core 0)(.*)\+([0-9]+)(.*)[ \t°](C|F)/ && $2 ~ /^[ \t]*\+([0-9]+)/ { + /^(core0|core 0|Physical id 0)(.*)\+([0-9]+)(.*)[ \t°](C|F)/ && $2 ~ /^[ \t]*\+([0-9]+)/ { tempWorking=gensub( /[ \t]+\+([0-9\.]+)(.*)/, "\\1", 1, $2 ) if ( core0Temp == "" || tempWorking > 0 ) { core0Temp=tempWorking @@ -8282,7 +8307,6 @@ get_sensors_data() tempUnit=tempWorkingUnit } } - # note: can be cpu fan:, cpu fan speed:, etc. Some cases have no space before # $2 starts (like so :1234 RPM), so skip that space test in regex /^CPU(.*)[ \t]*([0-9]+)[ \t]RPM/ { @@ -8340,17 +8364,18 @@ get_sensors_data() } } } - END { # first we need to handle the case where we have to determine which temp/fan to use for cpu and mobo: # note, for rare cases of weird cool cpus, user can override in their prefs and force the assignment + # this is wrong for systems with > 2 tempX readings, but the logic is too complex with 3 variables + # so have to accept that it will be wrong in some cases, particularly for motherboard temp readings. if ( temp1 != "" && temp2 != "" ){ if ( userCpuNo != "" && userCpuNo ~ /(1|2)/ ) { tempFanType=userCpuNo } else { # first some fringe cases with cooler cpu than mobo: assume which is cpu temp based on fan speed - # but only if other fan speed is 0 + # but only if other fan speed is 0. if ( temp1 >= temp2 && 1 in aFanDefault && 2 in aFanDefault && aFanDefault[1] == 0 && aFanDefault[2] > 0 ) { tempFanType=2 } @@ -8378,38 +8403,90 @@ get_sensors_data() tempFanType=1 } } - - # then get the real cpu temp, best guess is hottest is real - if ( cpuTemp != "" ){ - cpuTempReal=cpuTemp + # convert the diff number for F, it needs to be bigger that is + if ( tempUnit == "F" ) { + tempDiff = tempDiff * 1.8 } - else if ( tempFanType != "" ){ - if ( tempFanType == 1 ){ - cpuTempReal=temp1 + if ( cpuTemp != "" ) { + # specific hack to handle broken CPUTIN temps with PECI + if ( cpuPeciTemp != "" && ( cpuTemp - cpuPeciTemp ) > tempDiff ){ + cpuTempReal=cpuPeciTemp } + # then get the real cpu temp, best guess is hottest is real else { - cpuTempReal=temp2 + cpuTempReal=cpuTemp } } else { - cpuTempReal=temp1 + if ( tempFanType != "" ){ + # there are some weird scenarios + if ( tempFanType == 1 ){ + if ( temp1 != "" && temp2 != "" && temp2 > temp1 ) { + cpuTempReal=temp2 + } + else { + cpuTempReal=temp1 + } + } + else { + if ( temp1 != "" && temp2 != "" && temp1 > temp2 ) { + cpuTempReal=temp1 + } + else { + cpuTempReal=temp2 + } + } + } + else { + cpuTempReal=temp1 # can be null, that is ok + } + if ( cpuTempReal != "" ) { + if ( temp3 != "" && temp3 > cpuTempReal ) { + cpuTempReal=temp3 + } + # there are some absurdly wrong temp1: acpitz-virtual-0 temp1: +13.8°C + if ( core0Temp != "" && (core0Temp - cpuTempReal) > tempDiff ) { + cpuTempReal=core0Temp + } + } } - # if all else fails, use core0 temp if it is present and cpu is null - if ( cpuTempReal == "" && core0Temp != "" ) { - cpuTempReal=core0Temp + # if all else fails, use core0/peci temp if present and cpu is null + if ( cpuTempReal == "" ) { + if ( core0Temp != "" ) { + cpuTempReal=core0Temp + } + # note that peci temp is known to be colder than the actual system + # sometimes so it is the last fallback we want to use even though in theory + # it is more accurate, but fact suggests theory wrong. + else if ( cpuPeciTemp != "" ) { + cpuTempReal=cpuPeciTemp + } } - # then the real mobo temp if ( moboTemp != "" ){ moboTempReal=moboTemp } else if ( tempFanType != "" ){ if ( tempFanType == 1 ) { - moboTempReal=temp2 + if ( temp1 != "" && temp2 != "" && temp2 > temp1 ) { + moboTempReal=temp1 + } + else { + moboTempReal=temp2 + } } else { - moboTempReal=temp1 + if ( temp1 != "" && temp2 != "" && temp1 > temp2 ) { + moboTempReal=temp2 + } + else { + moboTempReal=temp1 + } } + ## NOTE: not safe to assume temp3 is the mobo temp, sad to say + #if ( temp1 != "" && temp2 != "" && temp3 != "" && temp3 < moboTempReal ) { + # moboTempReal= temp3 + #} } else { moboTempReal=temp2 @@ -8427,7 +8504,6 @@ get_sensors_data() aFanDefault[2]="" } } - # then we need to get the actual numeric max array count for both fan arrays for (i = 0; i <= 29; i++) { if ( i in aFanMain && i > indexCountaFanMain ) { @@ -8439,7 +8515,6 @@ get_sensors_data() indexCountaFanDefault=i } } - # clear out any duplicates. Primary fan real trumps fan working always if same speed for (i = 1; i <= indexCountaFanMain; i++) { if ( i in aFanMain && aFanMain[i] != "" && aFanMain[i] != 0 ) { @@ -8450,7 +8525,6 @@ get_sensors_data() } } } - # now see if you can find the fast little mobo fan, > 5000 rpm and put it as mobo # note that gawk is returning true for some test cases when aFanDefault[j] < 5000 # which has to be a gawk bug, unless there is something really weird with arrays @@ -8469,7 +8543,6 @@ get_sensors_data() } } } - # then construct the sys_fan string for echo, note that iteration 1 # makes: fanDefaultString separator null, ie, no space or , for (j = 1; j <= indexCountaFanDefault; j++) { @@ -8490,7 +8563,6 @@ get_sensors_data() if ( cpuTempReal != "" ) { cpuTempReal = cpuTempReal tempUnit } - # if they are ALL null, print error message. psFan is not used in output currently if ( cpuTempReal == "" && moboTempReal == "" && aFanMain[1] == "" && aFanMain[2] == "" && aFanMain[3] == "" && fanDefaultString == "" ) { print "No active sensors found. Have you configured your sensors yet?" diff --git a/inxi.changelog b/inxi.changelog index ff81537..f70821d 100755 --- a/inxi.changelog +++ b/inxi.changelog @@ -1,3 +1,31 @@ +===================================================================================== +Version: 2.1.24 +Patch Version: 00 +Script Date: 2014-04-28 +----------------------------------- +Changes: +----------------------------------- +New version, new tarball. This is an attempt to make -s accurate more of the time, +particularly with fringe or broken sensors outputs. See inxi issue 58 for details. +http://code.google.com/p/inxi/issues/detail?id=58 + +Added temp3, and an override to capture cases where temp3 is the actual cpu temp. + +Added PECI overrides for cases like msi/asus mobos have defective CPUTIN return data. + +Added core0 overrides as well, for cases where the temp returned is too low. + +It is absolutely 100% guaranteed that these changes will break some outputs that were +working, but it's also certain that I believe that more wrong outputs will be corrected. + +With sensors, really the only way you can get reliable sensors is to use the lm-sensors +config files for your motherboard, then set: CPU: temp and MB: temp explicitly. + +inxi will always use CPU: or MB: to override anything found. + +----------------------------------- +-- Harald Hope - Mon, 28 Apr 2014 13:17:53 -0700 + ===================================================================================== Version: 2.1.23 Patch Version: 00