mirror of
https://github.com/smxi/inxi.git
synced 2024-11-16 16:21:39 +00:00
(Change version)
This fixes the multiple physical cpu missing data. I had to simplify the ht/smp part to make it work, also, from what I can tell, we only really need the terms: UP SMP HT SMP-HT which cover all possible scenarios from what I can tell http://en.wikipedia.org/wiki/Symmetric_multiprocessing says that it's all basically smp, single cpu, dual core, or multi cpu, single or multi core.
This commit is contained in:
parent
5a35c5fb12
commit
460f028877
138
inxi
138
inxi
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
########################################################################
|
||||
#### Script Name: inxi
|
||||
#### version: 0.9.7
|
||||
#### Date: 26 January 2009
|
||||
#### version: 0.9.8
|
||||
#### Date: 3 February 2009
|
||||
########################################################################
|
||||
#### SPECIAL THANKS
|
||||
########################################################################
|
||||
|
@ -91,6 +91,9 @@
|
|||
#### ln -s <path to inxi> /usr/share/apps/konversation/scripts/inxi
|
||||
#### DCOP doesn't like \n, so avoid using it for most output unless required, as in error messages.
|
||||
########################################################################
|
||||
#### Valuable Resources
|
||||
#### awk arrays: http://www.math.utah.edu/docs/info/gawk_12.html
|
||||
########################################################################
|
||||
#### TESTING FLAGS
|
||||
#### inxi supports advanced testing triggers to do various things, using -! <arg>
|
||||
#### -! 1 - triggers default B_TESTING_1='true' to trigger some test or other
|
||||
|
@ -1392,13 +1395,9 @@ get_cpu_core_count()
|
|||
get_cpu_ht_multicore_smp_data
|
||||
## Because of the upcoming release of cpus with core counts over 6, a count of cores is given after Deca (10)
|
||||
# count the number of processors given
|
||||
local cpu_physical_count=${A_CPU_TYPE_PCNT_CCNT[1]}
|
||||
local cpu_core_count=${A_CPU_TYPE_PCNT_CCNT[2]}
|
||||
local cpu_type=''
|
||||
|
||||
if [[ ${A_CPU_TYPE_PCNT_CCNT[0]} == "HT" || ${A_CPU_TYPE_PCNT_CCNT[0]} == "SMP" ]]; then
|
||||
# note the use of the space, this avoids a double space if this is null in the output
|
||||
cpu_type=" ${A_CPU_TYPE_PCNT_CCNT[0]}"
|
||||
fi
|
||||
local cpu_type=${A_CPU_TYPE_PCNT_CCNT[0]}
|
||||
|
||||
# match the numberic value to an alpha value
|
||||
case $cpu_core_count in
|
||||
|
@ -1415,7 +1414,8 @@ get_cpu_core_count()
|
|||
*) cpu_alpha_count='Multi';;
|
||||
esac
|
||||
# create array, core count integer; core count string
|
||||
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" )
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -1513,16 +1513,18 @@ get_cpu_ht_multicore_smp_data()
|
|||
# if = 1 processor then single core/processor Uni-Processor (UP)
|
||||
|
||||
if [[ $B_CPUINFO == 'true' ]]; then
|
||||
A_CPU_TYPE_PCNT_CCNT=( $( gawk '
|
||||
A_CPU_TYPE_PCNT_CCNT=( $(
|
||||
gawk '
|
||||
BEGIN {
|
||||
FS=": "
|
||||
IGNORECASE = 1
|
||||
i = 0
|
||||
processors = 1
|
||||
core_count = 0
|
||||
cores = 1 # single cores are obviously a Uni-processor
|
||||
i = 0
|
||||
index_temp = ""
|
||||
physical_cpu_count = 0
|
||||
processors = 1
|
||||
type = "UP"
|
||||
cpu_temp = 0
|
||||
core_temp = 0
|
||||
}
|
||||
# counts logical processors, both HT and physical
|
||||
/^processor/ {
|
||||
|
@ -1534,59 +1536,55 @@ get_cpu_ht_multicore_smp_data()
|
|||
}
|
||||
# array of physical cpus ids
|
||||
/^physical/ {
|
||||
physical_id[i] = $NF
|
||||
a_physical_id[i] = $NF
|
||||
}
|
||||
# array of core ids
|
||||
/^core id/ {
|
||||
core_id[i] = $NF
|
||||
a_core_id[i] = $NF
|
||||
i++
|
||||
}
|
||||
END {
|
||||
# look for the largest id number, and assign it
|
||||
for ( j = 0; j < num_of_processors; j++ ) {
|
||||
if ( physical_id[j] > cpu_temp ) {
|
||||
cpu_temp = physical_id[j]
|
||||
}
|
||||
if ( core_id[j] > core_temp ) {
|
||||
core_temp = core_id[j]
|
||||
if ( a_core_id[j] > core_count ) {
|
||||
core_count = a_core_id[j]
|
||||
}
|
||||
}
|
||||
|
||||
physical_cpu_count = cpu_temp + 1
|
||||
core_count = core_temp + 1
|
||||
|
||||
# trick, set the index equal to value, if the same, it will overwrite
|
||||
# this lets us create the actual array of true cpu physical ids
|
||||
for ( j in a_physical_id ) {
|
||||
index_temp = a_physical_id[j]
|
||||
a_cpu_physical_working[index_temp] = a_physical_id[j]
|
||||
}
|
||||
# note that length() is a gawk >= 3.1.5 only method, better to do it manually
|
||||
for ( j in a_cpu_physical_working ) {
|
||||
++physical_cpu_count
|
||||
}
|
||||
core_count = core_count + 1
|
||||
# looking at logical processor counts over 1, which means either HT, SMP or MCP
|
||||
# http://en.wikipedia.org/wiki/Symmetric_multiprocessing
|
||||
if ( num_of_processors > 1 ) {
|
||||
if ( physical_cpu_count == 1 ) {
|
||||
if ( physical_cpu_count == core_count ) {
|
||||
type = "HT" # this is more than likely a P4 w/HT or an Atom 270
|
||||
}
|
||||
else {
|
||||
if ( core_count == num_of_cores && core_count == num_of_processors) {
|
||||
type = "MCP"
|
||||
cores = core_count
|
||||
}
|
||||
else {
|
||||
type = "HT" # this is i7 or Atom 330
|
||||
cores = core_count
|
||||
}
|
||||
}
|
||||
per_cpu_core_count = num_of_processors / physical_cpu_count
|
||||
if ( physical_cpu_count == per_cpu_core_count && physical_cpu_count > 1 ) {
|
||||
type = "SMP-HT"
|
||||
}
|
||||
else if ( physical_cpu_count == per_cpu_core_count ) {
|
||||
type = "HT" # this is more than likely a P4 w/HT or an Atom 270
|
||||
}
|
||||
else {
|
||||
type = "SMP"
|
||||
processors = physical_cpu_count
|
||||
|
||||
if ( num_of_cores > 1 ) {
|
||||
type = "SMPMC" # processors could be both MCP and SMP
|
||||
cores = core_count
|
||||
}
|
||||
}
|
||||
}
|
||||
print type " " processors " " cores
|
||||
# make sure to handle up cpus too
|
||||
else {
|
||||
core_count = 1
|
||||
physical_cpu_count = 1
|
||||
}
|
||||
print type " " physical_cpu_count " " core_count
|
||||
}
|
||||
' $DIR_CPUINFO ) )
|
||||
' $DIR_CPUINFO
|
||||
) )
|
||||
fi
|
||||
# echo A_CPU_TYPE_PCNT_CCNT:1 ${A_CPU_TYPE_PCNT_CCNT[@]}
|
||||
}
|
||||
|
||||
# for more on distro id, please reference this python thread: http://bugs.python.org/issue1322
|
||||
|
@ -2478,8 +2476,20 @@ print_short_data()
|
|||
|
||||
# set A_CPU_CORE_DATA
|
||||
get_cpu_core_count
|
||||
local cpu_core_count_string="${A_CPU_CORE_DATA[1]}"
|
||||
local cpu_core_count=${A_CPU_CORE_DATA[0]}
|
||||
local cpc_plural='' cpu_count_print='' model_plural=''
|
||||
local cpu_physical_count=${A_CPU_CORE_DATA[0]}
|
||||
local cpu_core_count=${A_CPU_CORE_DATA[3]}
|
||||
local cpu_core_alpha=${A_CPU_CORE_DATA[1]}
|
||||
local cpu_type=${A_CPU_CORE_DATA[2]}
|
||||
local cores_per_cpu=$(( $cpu_core_count / $cpu_physical_count ))
|
||||
if [[ "$cpu_physical_count" -gt 1 ]];then
|
||||
cpc_plural='(s)'
|
||||
model_plural='s'
|
||||
cpu_count_print="$cpu_physical_count "
|
||||
fi
|
||||
|
||||
local cpu_data_string="${cpu_count_print}${cpu_core_alpha} core ${cpu_type}"
|
||||
# local cpu_core_count=${A_CPU_CORE_DATA[0]}
|
||||
|
||||
# load A_HDD_DATA
|
||||
get_hdd_data_basic
|
||||
|
@ -2528,7 +2538,7 @@ print_short_data()
|
|||
#C1="${C1},1"; C2="${C2},1"; CN="${CN},1"
|
||||
fi
|
||||
fi
|
||||
short_data="${C1}CPU${CN}[${C2}${cpu_core_count_string} ${cpu_model} ${C1}clocked at${C2} ${min_max_clock}${CN}] ${C1}Kernel${CN}[${C2} ${current_kernel}${CN}] ${C1}Up${CN}[${C2}${FL2}${FL1}${up_time}${FL1}${CN}] ${C1}Mem${CN}[${C2}${FL2}${FL1}${memory}${FL1}${CN}] ${C1}HDD${CN}[${C2}${FL2}${FL1}${hdd_capacity}($hdd_used)${FL1}${CN}] ${C1}Procs${CN}[${C2}${FL2}${FL1}${processes}${FL1}${CN}]"
|
||||
short_data="${C1}CPU$cpc_plural${CN}[${C2} ${cpu_data_string} ${cpu_model}$model_plural ${C1}clocked at${C2} ${min_max_clock}${CN}] ${C1}Kernel${CN}[${C2} ${current_kernel}${CN}] ${C1}Up${CN}[${C2}${FL2}${FL1}${up_time}${FL1}${CN}] ${C1}Mem${CN}[${C2}${FL2}${FL1}${memory}${FL1}${CN}] ${C1}HDD${CN}[${C2}${FL2}${FL1}${hdd_capacity}($hdd_used)${FL1}${CN}] ${C1}Procs${CN}[${C2}${FL2}${FL1}${processes}${FL1}${CN}]"
|
||||
|
||||
if [[ $SHOW_IRC -gt 0 ]];then
|
||||
short_data="${short_data} ${C1}Client${CN}[${C2}${IRC_CLIENT}${IRC_CLIENT_VERSION}${CN}]"
|
||||
|
@ -2641,8 +2651,19 @@ print_cpu_data()
|
|||
|
||||
# set A_CPU_CORE_DATA
|
||||
get_cpu_core_count
|
||||
local cpu_core_count_string="${A_CPU_CORE_DATA[1]}"
|
||||
local cpu_core_count=${A_CPU_CORE_DATA[0]}
|
||||
local cpc_plural='' cpu_count_print='' model_plural=''
|
||||
local cpu_physical_count=${A_CPU_CORE_DATA[0]}
|
||||
local cpu_core_count=${A_CPU_CORE_DATA[3]}
|
||||
local cpu_core_alpha=${A_CPU_CORE_DATA[1]}
|
||||
local cpu_type=${A_CPU_CORE_DATA[2]}
|
||||
|
||||
if [[ "$cpu_physical_count" -gt 1 ]];then
|
||||
cpc_plural='(s)'
|
||||
cpu_count_print="$cpu_physical_count "
|
||||
model_plural='s'
|
||||
fi
|
||||
|
||||
local cpu_data_string="${cpu_count_print}${cpu_core_alpha} core ${cpu_type}"
|
||||
# Strange (and also some expected) behavior encountered. If print_screen_output() uses $1
|
||||
# as the parameter to output to the screen, then passing "<text1> ${ARR[@]} <text2>"
|
||||
# will output only <text1> and first element of ARR. That "@" splits in elements and "*" _doesn't_,
|
||||
|
@ -2655,22 +2676,23 @@ print_cpu_data()
|
|||
a_cpu_working[2]="unknown"
|
||||
fi
|
||||
|
||||
cpu_data=$( create_print_line "CPU:" "${C1}${cpu_core_count_string}${C2} ${a_cpu_working[0]}" )
|
||||
cpu_data=$( create_print_line "CPU$cpc_plural:" "${C1}${cpu_data_string}${C2} ${a_cpu_working[0]}$model_plural" )
|
||||
if [[ $VERBOSITY_LEVEL -ge 3 || $B_SHOW_CPU == 'true' ]];then
|
||||
# update for multicore, bogomips x core count.
|
||||
if [[ $B_EXTRA_DATA == 'true' ]];then
|
||||
# if [[ $cpu_vendor != 'intel' ]];then
|
||||
bmip_data=$( calculate_multicore_data "${a_cpu_working[4]}" "$cpu_core_count" )
|
||||
bmip_data=$( calculate_multicore_data "${a_cpu_working[4]}" "$(( $cpu_core_count * $cpu_physical_count ))" )
|
||||
# else
|
||||
# bmip_data="${a_cpu_working[4]}"
|
||||
# fi
|
||||
bmip_data=" ${C1}bmips${C2} $bmip_data"
|
||||
fi
|
||||
## note: this handles how intel reports L2, total instead of per core like AMD does
|
||||
# note that we need to multiply by number of actual cpus here to get true cache size
|
||||
if [[ $cpu_vendor != 'intel' ]];then
|
||||
cpu_cache=$( calculate_multicore_data "${a_cpu_working[2]}" "$cpu_core_count" )
|
||||
cpu_cache=$( calculate_multicore_data "${a_cpu_working[2]}" "$(( $cpu_core_count * $cpu_physical_count ))" )
|
||||
else
|
||||
cpu_cache="${a_cpu_working[2]}"
|
||||
cpu_cache=$( calculate_multicore_data "${a_cpu_working[2]}" "$cpu_physical_count" )
|
||||
fi
|
||||
# only print shortened list
|
||||
if [[ $B_CPU_FLAGS_FULL != 'true' ]];then
|
||||
|
@ -3065,7 +3087,7 @@ print_system_data()
|
|||
local current_kernel=$( uname -rm ) # | gawk '{print $1,$3,$(NF-1)}' )
|
||||
local distro="$( get_distro_data )"
|
||||
# check for 64 bit first
|
||||
if [ -n "$( uname -m | grep -o 'x86_64' )" ];then
|
||||
if [[ -n "$( uname -m | grep -o 'x86_64' )" ]];then
|
||||
bits="(64 bit)"
|
||||
else
|
||||
bits="(32 bit)"
|
||||
|
|
Loading…
Reference in a new issue