trying to tighten the fan output to avoid errors and also added sys fan 1-3 handling.

This commit is contained in:
inxi-svn 2009-07-27 18:22:41 +00:00
parent 33332b4d5e
commit 43862494d7

43
inxi
View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### version: 1.0.87-b1 #### version: 1.0.88-b1
#### Date: 26 July 2009 #### Date: 26 July 2009
######################################################################## ########################################################################
#### SPECIAL THANKS #### SPECIAL THANKS
@ -3013,12 +3013,16 @@ get_sensors_data()
IFS="," IFS=","
if [[ $B_SENSORS == 'true' ]];then if [[ $B_SENSORS == 'true' ]];then
# note: non-configured sensors gives error message, which we need to redirect to stdout
A_SENSORS_DATA=( $( sensors | gawk ' A_SENSORS_DATA=( $( sensors | gawk '
BEGIN { BEGIN {
IGNORECASE=1 IGNORECASE=1
moboTemp="" moboTemp=""
cpuTemp="" cpuTemp=""
cpuFan="" cpuFan=""
sysFan1=""
sysFan2=""
sysFan3=""
tempData1="" tempData1=""
tempData2="" tempData2=""
} }
@ -3056,23 +3060,26 @@ get_sensors_data()
cpuTemp=cpuTemp "°" tempData2 cpuTemp=cpuTemp "°" tempData2
} }
} }
/CPU Fan|fan1:/ { /CPU Fan:/ {
if ( $1 == "fan1:" ) { cpuFan=$3
tempData1=$2
} }
else { /fan1:/ {
tempData1=$3 sysFan1=$2
} }
cpuFan=tempData1 /fan2:/ {
sysFan2=$2
}
/fan3:/ {
sysFan3=$2
} }
END { END {
# if they are ALL null, print error message # if they are ALL null, print error message
if ( moboTemp == "" && cpuTemp == "" && cpuFan == "" ) { if ( moboTemp == "" && cpuTemp == "" && cpuFan == "" && sysFan1 == "" && sysFan2 == "" && sysFan3 == "" ) {
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 print moboTemp "," cpuTemp "," cpuFan "," sysFan1 "," sysFan2 "," sysFan3
} }
} }
' '
@ -3942,7 +3949,7 @@ print_partition_data()
print_sensors_data() print_sensors_data()
{ {
eval $LOGFS eval $LOGFS
local mobo_temp='' cpu_temp='' cpu_fan='' sensors_data='' local mobo_temp='' cpu_temp='' cpu_fan='' sys_fan1='' sys_fan2='' sys_fan3='' sensors_data=''
get_sensors_data get_sensors_data
# initial error cases, for missing app or unconfigured sensors # initial error cases, for missing app or unconfigured sensors
@ -3963,14 +3970,28 @@ print_sensors_data()
fi fi
cpu_temp="${C1}Cpu Temp:${C2} $cpu_temp " cpu_temp="${C1}Cpu Temp:${C2} $cpu_temp "
# we need to make sure it's either cpu fan OR cpu fan and sys fan 1
if [[ -n ${A_SENSORS_DATA[2]} ]];then if [[ -n ${A_SENSORS_DATA[2]} ]];then
cpu_fan="${A_SENSORS_DATA[2]}rpm" cpu_fan="${A_SENSORS_DATA[2]}rpm"
elif [[ -z ${A_SENSORS_DATA[2]} && -n ${A_SENSORS_DATA[3]} ]];then
cpu_fan="${A_SENSORS_DATA[3]}rpm"
else else
cpu_fan='N/A' cpu_fan='N/A'
fi fi
cpu_fan="${C1}Cpu Fan:${C2} $cpu_fan " cpu_fan="${C1}Cpu Fan:${C2} $cpu_fan "
# then set the sys fans, if present or 0. sys fan 1 only if cpu fan is present,
# otherwise fan1: is cpu fan
if [[ -n ${A_SENSORS_DATA[2]} && -n ${A_SENSORS_DATA[3]} ]];then
sys_fan1="${C1}Sys Fan1:${C2} ${A_SENSORS_DATA[3]}rpm "
fi fi
sensors_data="$mobo_temp$cpu_temp$cpu_fan" if [[ -n ${A_SENSORS_DATA[4]} ]];then
sys_fan2="${C1}Sys Fan2:${C2} ${A_SENSORS_DATA[4]}rpm "
fi
if [[ -n ${A_SENSORS_DATA[5]} ]];then
sys_fan3="${C1}Sys Fan3:${C2} ${A_SENSORS_DATA[5]}rpm "
fi
fi
sensors_data="$mobo_temp$cpu_temp$cpu_fan$sys_fan1$sys_fan2$sys_fan3"
sensors_data=$( create_print_line "Sensors:" "$sensors_data" ) sensors_data=$( create_print_line "Sensors:" "$sensors_data" )
print_screen_output "$sensors_data" print_screen_output "$sensors_data"
eval $LOGFE eval $LOGFE