New version, tarball. As always with fixes, one thing creates a bug in another. Fixed

linux driver version handling, now only trimming off number from bsd drivers.

Some linux drivers, like tg3 for broadcom ethernet, have numbers ending them. So this is
a bug fix for 1.8.44 release mainly.

Also includes openbsd initial fixes for some issues related to sysctl parsing for cpu and ram.
This commit is contained in:
inxi-svn 2013-03-02 17:54:48 +00:00
parent fd14505984
commit 43a2cbc589
2 changed files with 123 additions and 47 deletions

106
inxi
View file

@ -1,8 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### Version: 1.8.44 #### Version: 1.8.45
#### Date: February 28 2013 #### Date: March 2 2013
#### Patch Number: 00 #### Patch Number: 00
######################################################################## ########################################################################
#### SPECIAL THANKS #### SPECIAL THANKS
@ -94,7 +94,7 @@
#### It appears that freebsd uses gnu grep but openbsd uses bsd grep, however. #### It appears that freebsd uses gnu grep but openbsd uses bsd grep, however.
#### * BSD ps does not support --without-headers option, and also does not support --sort <option> #### * BSD ps does not support --without-headers option, and also does not support --sort <option>
#### Tests show that -m fails to sort memory as expected, but -r does sort cpu percentage. #### Tests show that -m fails to sort memory as expected, but -r does sort cpu percentage.
#### * BSD_TYPE is set with values null, dgbsd (debian gnu/kfreebsd), bsd (all other bsds) #### * BSD_TYPE is set with values null, debian-bsd (debian gnu/kfreebsd), bsd (all other bsds)
#### * Subshell and array closing ) must not be on their own line unless you use an explicit \ #### * Subshell and array closing ) must not be on their own line unless you use an explicit \
#### to indicate that logic continues to next line where closing ) or )) are located. #### to indicate that logic continues to next line where closing ) or )) are located.
######################################################################## ########################################################################
@ -191,6 +191,7 @@
LANG=C LANG=C
### Variable initializations: null values ### Variable initializations: null values
BSD_TYPE='' BSD_TYPE=''
BSD_VERSION=
CMDL_MAX='' CMDL_MAX=''
COLOR_SCHEME='' COLOR_SCHEME=''
# override in user config if desired, seems like less than .3 doesn't work as reliably # override in user config if desired, seems like less than .3 doesn't work as reliably
@ -728,12 +729,13 @@ main()
initialize_data() initialize_data()
{ {
eval $LOGFS eval $LOGFS
BSD_VERSION=$( uname -s 2>/dev/null | tr '[A-Z]' '[a-z]' )
# note: archbsd says they are a freebsd distro, so assuming it's the same as freebsd # note: archbsd says they are a freebsd distro, so assuming it's the same as freebsd
if [[ -n $( grep -i 'bsd' <<< $( uname -s 2>/dev/null ) ) ]];then if [[ -n $( grep 'bsd' <<< "$BSD_VERSION" ) ]];then
# GNU/kfreebsd will by definition have GNU tools like sed/grep # GNU/kfreebsd will by definition have GNU tools like sed/grep
if [[ -n $( grep -i 'kfreebsd' <<< $( uname -s 2>/dev/null ) ) ]];then if [[ -n $( grep 'kfreebsd' <<< "$BSD_VERSION" ) ]];then
BSD_TYPE='dgbsd' # debian gnu bsd BSD_TYPE='debian-bsd' # debian gnu bsd
else else
BSD_TYPE='bsd' # all other bsds BSD_TYPE='bsd' # all other bsds
SED_I="-i ''" SED_I="-i ''"
@ -945,8 +947,8 @@ check_required_apps()
depends="$depends lspci" depends="$depends lspci"
elif [[ $BSD_TYPE == 'bsd' ]];then elif [[ $BSD_TYPE == 'bsd' ]];then
depends="$depends sysctl" depends="$depends sysctl"
# dgbsd has lspci but you must be root to run it # debian-bsd has lspci but you must be root to run it
elif [[ $BSD_TYPE == 'dgbsd' ]];then elif [[ $BSD_TYPE == 'debian-bsd' ]];then
depends="$depends sysctl lspci" depends="$depends sysctl lspci"
fi fi
# no need to add xprop because it will just give N/A if not there, but if we expand use of xprop, # no need to add xprop because it will just give N/A if not there, but if we expand use of xprop,
@ -3286,7 +3288,17 @@ get_cpu_core_count()
# A_CPU_CORE_DATA=( "$cpu_core_count" "$cpu_alpha_count Core$cpu_type" ) # A_CPU_CORE_DATA=( "$cpu_core_count" "$cpu_alpha_count Core$cpu_type" )
A_CPU_CORE_DATA=( "$cpu_physical_count" "$cpu_alpha_count" "$cpu_type" "$cpu_core_count" ) A_CPU_CORE_DATA=( "$cpu_physical_count" "$cpu_alpha_count" "$cpu_type" "$cpu_core_count" )
elif [[ -n $BSD_TYPE ]];then elif [[ -n $BSD_TYPE ]];then
cpu_core_count=$( grep '^hw.ncpu' <<< "$Sysctl_a_Data" | gawk '{print $NF}' ) local gawk_fs=': '
if [[ $BSD_VERSION == 'openbsd' ]];then
gawk_fs='='
fi
cpu_core_count=$( gawk -F "$gawk_fs" '
# note: on openbsd can also be hw.ncpufound so exit after first
/^hw.ncpu/ {
print $NF
exit
}' <<< "$Sysctl_a_Data" )
if [[ -n $( grep -E '^[0-9]+$' <<< "$cpu_core_count" ) ]];then if [[ -n $( grep -E '^[0-9]+$' <<< "$cpu_core_count" ) ]];then
cpu_alpha_count=$( get_cpu_core_count_alpha "$cpu_core_count" ) cpu_alpha_count=$( get_cpu_core_count_alpha "$cpu_core_count" )
if [[ $cpu_core_count -gt 1 ]];then if [[ $cpu_core_count -gt 1 ]];then
@ -3436,12 +3448,33 @@ get_cpu_data()
} }
} }
' $FILE_CPUINFO ) ) ' $FILE_CPUINFO ) )
IFS="$ORIGINAL_IFS"
log_function_data 'cat' "$FILE_CPUINFO" log_function_data 'cat' "$FILE_CPUINFO"
elif [[ -n $BSD_TYPE ]];then elif [[ -n $BSD_TYPE ]];then
bsd_cpu_flags=$( get_cpu_flags_bsd ) get_cpu_data_bsd
fi
temp_array=${A_CPU_DATA[@]}
log_function_data "A_CPU_DATA: $temp_array"
# echo ta: ${temp_array[@]}
eval $LOGFE
# echo getMainCpu: ${[@]}
}
get_cpu_data_bsd()
{
eval $LOGFS
local bsd_cpu_flags=$( get_cpu_flags_bsd )
local gawk_fs=': '
if [[ $BSD_VERSION == 'openbsd' ]];then
gawk_fs='='
fi
IFS=$'\n' IFS=$'\n'
A_CPU_DATA=( $( A_CPU_DATA=( $(
gawk -F': ' -v cpuFlags="$bsd_cpu_flags" ' gawk -F "$gawk_fs" -v cpuFlags="$bsd_cpu_flags" '
BEGIN { BEGIN {
IGNORECASE=1 IGNORECASE=1
cpuModel="" cpuModel=""
@ -3453,26 +3486,28 @@ get_cpu_data()
/^hw.model/ { /^hw.model/ {
gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF ) gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF )
gsub(/'"$BAN_LIST_CPU"'/, "", $NF ) gsub(/'"$BAN_LIST_CPU"'/, "", $NF )
sub(//,"",$NF)
sub(/[a-z]+-core/, "", $NF ) sub(/[a-z]+-core/, "", $NF )
gsub(/^ +| +$/, "", $NF) gsub(/^ +| +$|\"/, "", $NF)
gsub(/ [ \t]+/, " ", $NF) gsub(/ [ \t]+/, " ", $NF)
cpuModel=$NF cpuModel=$NF
if ( cpuClock != "" ) {
exit
} }
/^hw.clock/ { }
/^hw.(clock|cpuspeed)/ {
cpuClock=$NF cpuClock=$NF
if ( cpuModel != "" ) {
exit
}
} }
END { END {
print cpuModel "," cpuClock "," cpuCache "," cpuFlags "," cpuBogomips "," cpuVendor print cpuModel "," cpuClock "," cpuCache "," cpuFlags "," cpuBogomips "," cpuVendor
print "N/A" print "N/A"
}' <<< "$Sysctl_a_Data" ) ) }' <<< "$Sysctl_a_Data" ) )
fi
IFS="$ORIGINAL_IFS" IFS="$ORIGINAL_IFS"
temp_array=${A_CPU_DATA[@]}
log_function_data "A_CPU_DATA: $temp_array"
# echo ta: ${temp_array[@]}
eval $LOGFE eval $LOGFE
# echo getMainCpu: ${[@]}
} }
get_cpu_flags_bsd() get_cpu_flags_bsd()
@ -5392,21 +5427,27 @@ get_memory_data()
}' $FILE_MEMINFO ) }' $FILE_MEMINFO )
log_function_data 'cat' "$FILE_MEMINFO" log_function_data 'cat' "$FILE_MEMINFO"
elif [[ $B_SYSCTL == 'true' && -n $Sysctl_a_Data ]];then elif [[ $B_SYSCTL == 'true' && -n $Sysctl_a_Data ]];then
memory=$( grep -i 'mem' <<< "$Sysctl_a_Data" | gawk ' local gawk_fs=': '
if [[ $BSD_VERSION == 'openbsd' ]];then
gawk_fs='='
fi
memory=$( grep -i 'mem' <<< "$Sysctl_a_Data" | gawk -F "$gawk_fs" '
BEGIN { BEGIN {
realMemory="" realMemory=""
freeMemory="" freeMemory=""
} }
# freebsd seems to use bytes here # freebsd seems to use bytes here
/^hw.physmem:/ { /^hw.physmem/ {
gsub(/^[^0-9]+|[^0-9]+$/,"",$2) gsub(/^[^0-9]+|[^0-9]+$/,"",$2)
realMemory = $2/1024 realMemory = $2/1024
if ( freeMemory != "" ) { if ( freeMemory != "" ) {
exit exit
} }
} }
# But, it uses K here # But, it uses K here. Openbsd does not seem to have this item
/^Free Memory:|^Free Memory Pages:/ { # this can be either: Free Memory OR Free Memory Pages
$1 ~ /^Free Memory/ {
gsub(/[^0-9]/,"",$NF) gsub(/[^0-9]/,"",$NF)
freeMemory = $NF freeMemory = $NF
if ( realMemory != "" ) { if ( realMemory != "" ) {
@ -5414,8 +5455,14 @@ get_memory_data()
} }
} }
END { END {
# hack: temp fix for openbsd: in case no free mem was detected but we have physmem
if ( freeMemory == "" && realMemory != "" ) {
printf("NA/%.1fMB\n", realMemory/1024)
}
else if ( freeMemory != "" && realMemory != "" ) {
used = realMemory - freeMemory used = realMemory - freeMemory
printf("%.1f/%.1fMB\n", used/1024, realMemory/1024) printf("%.1f/%.1fMB\n", used/1024, realMemory/1024)
}
}' ) }' )
fi fi
echo "$memory" echo "$memory"
@ -6133,6 +6180,7 @@ get_partition_data()
( $1 ~ /^\/dev\/|:\/|\/\// ) && ( devBase == "" ) { ( $1 ~ /^\/dev\/|:\/|\/\// ) && ( devBase == "" ) {
devBase=gensub( /^(\/dev\/)(.+)$/, "\\2", 1, $1 ) devBase=gensub( /^(\/dev\/)(.+)$/, "\\2", 1, $1 )
} }
# this handles zfs type devices/partitions, which do not start with / but contain /
( bsdType != "" && devBase == "" && $1 ~ /^[^\/]+\/.+/ ) { ( bsdType != "" && devBase == "" && $1 ~ /^[^\/]+\/.+/ ) {
devBase=gensub( /^([^\/]+\/)([^\/]+)$/, "non-dev-\\1\\2", 1, $1 ) devBase=gensub( /^([^\/]+\/)([^\/]+)$/, "non-dev-\\1\\2", 1, $1 )
} }
@ -8220,7 +8268,12 @@ print_audio_data()
fi fi
# we're testing for the presence of the 2nd array item here, which is the driver name # we're testing for the presence of the 2nd array item here, which is the driver name
if [[ -n ${a_audio_working[1]} ]];then if [[ -n ${a_audio_working[1]} ]];then
driver=$( sed 's/[0-9]*$//' <<< ${a_audio_working[1]} ) # note: linux drivers can have numbers, like tg3
if [[ $BSD_TYPE == 'bsd' ]];then
driver=$( sed 's/[0-9]$//' <<< ${a_audio_working[1]} )
else
driver=${a_audio_working[1]}
fi
audio_driver="${C1}driver$SEP3${C2} ${driver} " audio_driver="${C1}driver$SEP3${C2} ${driver} "
fi fi
if [[ -n ${a_audio_working[2]} && $B_EXTRA_DATA == 'true' ]];then if [[ -n ${a_audio_working[2]} && $B_EXTRA_DATA == 'true' ]];then
@ -9098,7 +9151,12 @@ print_networking_data()
module_version=$( print_module_version "${a_network_working[1]}" ) module_version=$( print_module_version "${a_network_working[1]}" )
fi fi
if [[ -n ${a_network_working[1]} ]];then if [[ -n ${a_network_working[1]} ]];then
# note: linux drivers can have numbers, like tg3
if [[ $BSD_TYPE == 'bsd' ]];then
driver=$( sed 's/[0-9]*$//' <<< ${a_network_working[1]} ) driver=$( sed 's/[0-9]*$//' <<< ${a_network_working[1]} )
else
driver=${a_network_working[1]}
fi
driver_data="${C1}driver$SEP3${C2} ${driver}$module_version " driver_data="${C1}driver$SEP3${C2} ${driver}$module_version "
fi fi
if [[ -n ${a_network_working[2]} && $B_EXTRA_DATA == 'true' ]];then if [[ -n ${a_network_working[2]} && $B_EXTRA_DATA == 'true' ]];then

View file

@ -1,3 +1,21 @@
=====================================================================================
Version: 1.8.45
Patch Version: 00
Script Date: March 2 2013
-----------------------------------
Changes:
-----------------------------------
New version, tarball. As always with fixes, one thing creates a bug in another. Fixed
linux driver version handling, now only trimming off number from bsd drivers.
Some linux drivers, like tg3 for broadcom ethernet, have numbers ending them. So this is
a bug fix for 1.8.44 release mainly.
Also includes openbsd initial fixes for some issues related to sysctl parsing for cpu and ram.
-----------------------------------
-- Harald Hope - Sat, 02 Mar 2013 09:44:17 -0800
===================================================================================== =====================================================================================
Version: 1.8.44 Version: 1.8.44
Patch Version: 00 Patch Version: 00