New version, new tarball, new man page. First attempt at adding cpu microarchitecture support.

Will need some updates to bring the family/model ids to fully current, but should show data for most
cpus. Next release will hopefully include latest model/family ids and microarchitecture names.

Note that while /proc/cpuinfo has the family/model id in decimal, the values are actually generally
found as hexadecimal, so inxi translates that interally so we can store the data the way it is presented.

See issue #116 for ongoing additions to this feature.
This commit is contained in:
Harald Hope 2017-07-28 00:18:42 -07:00
parent 6d1dad93ee
commit 1f7b2db8e5
3 changed files with 258 additions and 32 deletions

265
inxi
View file

@ -1,8 +1,8 @@
#!/usr/bin/env bash
########################################################################
#### Script Name: inxi
#### Version: 2.3.25
#### Date: 2017-07-24
#### Version: 2.3.26
#### Date: 2017-07-28
#### Patch Number: 00
########################################################################
#### SPECIAL THANKS
@ -3156,7 +3156,7 @@ show_options()
fi
print_lines_basic "1" "-x" "Adds the following extra data (only works with verbose or line output, not short form):"
print_lines_basic "2" "-B" "Vendor/model, status (if available)"
print_lines_basic "2" "-C" "CPU Flags, Bogomips on Cpu;"
print_lines_basic "2" "-C" "CPU Flags, Bogomips on Cpu;CPU microarchitecture if found, like: (Sandy Bridge)"
print_lines_basic "2" "-d" "Extra optical drive data; adds rev version to optical drive."
print_lines_basic "2" "-D" "Hdd temp with disk data if you have hddtemp installed, if you are root OR if you have added to /etc/sudoers (sudo v. 1.7 or newer) Example:^<username>^ALL^=^NOPASSWD:^/usr/sbin/hddtemp"
print_lines_basic "2" "-G" "Direct rendering status for Graphics (in X)."
@ -4354,6 +4354,166 @@ get_battery_data()
eval $LOGFE
}
## args: $1 type [intel|amd|centaur|arm]; $2 family [hex]; $3 model id [hex]
get_cpu_architecture()
{
eval $LOGFS
local arch=""
case $1 in
amd)
case $2 in
4)
case $3 in
3|7|8|9|A)arch='Am486';;
E|F)arch='Am5x86';;
esac
;;
5)
case $3 in
0|1|2|3)arch='K5';;
6|7)arch='K6';;
8)arch='K6-2';;
9|D)arch='K6-3';;
esac
;;
6)
case $3 in
1|2)arch='K7';;
3|4)arch='K7 Thunderbird';;
6|7|8|A)arch='K7 Palomino+';;
esac
;;
F)
case $3 in
4|5|7|8|B|C|E|F|14|15|17|18|1B|1C|1F)arch='K8';;
21|23|24|25|27|28|2C|2F)arch='K8 rev.E';;
41|43|48|4B|4C|4F|5D|5F|68|6B|6C|6F|7C|7F|C1)arch='K8 rev.F+';;
esac
;;
10)
case $3 in
2|4|5|6|8|9|A)arch='K10';;
esac
;;
11)
case $3 in
3)arch='K8 rev.E+';;
esac
;;
12)
case $3 in
1)arch='K10';;
esac
;;
14)
case $3 in
1|2)arch='Bobcat';;
esac
;;
15)
case $3 in
1)arch='Bulldozer';;
2|10|13)arch='Piledriver';;
30)arch='Steamroller';;
esac
;;
16)
case $3 in
0)arch='Jaguar';;
30)arch='Jaguar Puma';;
esac
;;
17)
case $3 in
*)arch='Zen';;
esac
;;
esac
;;
arm)
if [[ "$2" != '' ]];then
arch="ARMv$2"
else
arch='ARM'
fi
;;
centaur)
case $2 in
5)
case $3 in
4)arch='WinChip C6';;
8)arch='WinChip 2';;
9)arch='WinChip 3';;
esac
;;
6)
case $3 in
6)arch='WinChip-based';;
7|8)arch='C3';;
9)arch='C3-2';;
A|D)arch='C7';;
F)arch='Isaiah';;
esac
;;
esac
;;
intel)
case $2 in
4)
case $3 in
0|1|2|3|4|5|6|7|8|9)arch='486';;
esac
;;
5)
case $3 in
1|2|3|7)arch='P5';;
4|8)arch='P5';; # MMX
9)arch='Quark';;
esac
;;
6)
case $3 in
1)arch='P6 Pro';;
3|5|6)arch='P6 II';;
7|8|A|B)arch='P6 III';;
9|15)arch='Pentium M';;
D)arch='Pentium M';; # Dothan
E)arch='Core Yonah';;
F)arch='Core 2';;
17|1D)arch='Core Penryn';;
1A|1E|2E)arch='Nehalem';;
1C|35|36)arch='Bonnell';;
25|2C|2F)arch='Westmere';;
26|27)arch='Bonnell';;
2A|2D)arch='Sandy Bridge';;
37|4A|4D)arch='Silvermont';;
3A|3E)arch='Ivy Bridge';;
3C|3F|45|46)arch='Haswell';;
3D)arch='Broadwell';;
esac
;;
B)
case $3 in
1)arch='Knights Corner';;
esac
;;
F)
case $3 in
0|1|2)arch='Netburst';;
3|4|6)arch='Nocona Prescott';;
esac
;;
esac
;;
esac
echo $arch
eval $LOGFE
}
## create A_CPU_CORE_DATA, currently with two values: integer core count; core string text
## return value cpu core count string, this helps resolve the multi redundant lines of old style output
get_cpu_core_count()
@ -4491,6 +4651,9 @@ get_cpu_data()
speed = 0
max = 0
min = 0
type=""
family=""
model_nu=""
}
# TAKE STRONGER NOTE: \t+ does NOT always work, MUST be [ \t]+
# TAKE NOTE: \t+ will work for $FILE_CPUINFO, but SOME ARBITRARY FILE used for TESTING might contain SPACES!
@ -4513,6 +4676,9 @@ get_cpu_data()
# but no model name type
if ( $NF ~ "(ARM|AArch)" ) {
bArm = "true"
if ( type=""){
type="arm"
}
}
gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF )
gsub(/'"$BAN_LIST_CPU"'/, "", $NF )
@ -4521,6 +4687,19 @@ get_cpu_data()
cpu[nr, "model"] = $NF
}
}
# arm
/^cpu architecture/ && (family = "") {
gsub(/^ +| +$/, "", $NF)
family=$NF
}
/^cpu family/ && ( family == ""){
gsub(/^ +| +$/, "", $NF)
family=toupper( sprintf("%x", $NF) )
}
/^model[ \t]*:/ && ( model_nu == ""){
gsub(/^ +| +$/, "", $NF)
model_nu=toupper( sprintf("%x", $NF) )
}
/^model name|^cpu\t+:/ {
gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF )
gsub(/'"$BAN_LIST_CPU"'/, "", $NF )
@ -4565,6 +4744,18 @@ get_cpu_data()
/vendor_id/ {
gsub(/genuine|authentic/,"",$NF)
cpu[nr, "vendor"] = tolower( $NF )
if ( type == ""){
if ( $NF ~ /.*intel.*/ ) {
type="intel"
}
else if ($NF ~ /.*amd.*/){
type="amd"
}
# via
else if ($NF ~ /.*centaur.*/){
type="centaur"
}
}
}
END {
#if (!nr) { print ",,,"; exit } # <- should this be necessary or should bash handle that
@ -4593,11 +4784,15 @@ get_cpu_data()
sub(/\.[0-9]+$/,"",max)
sub(/\.[0-9]+$/,"",speed)
sub(/\.[0-9]+$/,"",min)
if ( bArm == "true" ){
type = "arm"
}
if (speed == 0) {
print "N/A," min "," max
print "N/A," min "," max "," type "," family "," model_nu
}
else {
print speed "," min "," max
# print speed "," min "," max "," type "," family "," model_nu > "/dev/tty"
print speed "," min "," max "," type "," family "," model_nu
}
}
' $FILE_CPUINFO ) )
@ -4751,8 +4946,8 @@ get_cpu_data_bsd()
sub(/\.[0-9]+/,"",min)
sub(/\.[0-9]+/,"",max)
print cpuModel "," cpuClock "," cpuCache "," cpuFlags "," cpuBogomips "," cpuVendor
# triggers print case
print cpuClock "," min "," max
# triggers print case, for architecture, check source for syntax
print cpuClock "," min "," max ",,,"
}' <<< "$Sysctl_a_Data" ) )
IFS="$ORIGINAL_IFS"
fi
@ -12148,7 +12343,7 @@ print_short_data()
local a_cpu_working=(${A_CPU_DATA[0]})
# this gets that weird min/max final array item, which almost never contains any data of use
local current_max_clock_nu=$(( ${#A_CPU_DATA[@]} - 1 ))
local a_cpu_speeds=(${A_CPU_DATA[$current_max_clock_nu]})
local a_cpu_info=(${A_CPU_DATA[$current_max_clock_nu]})
IFS="$ORIGINAL_IFS"
local cpu_model="${a_cpu_working[0]}"
## assemble data for output
@ -12164,14 +12359,14 @@ print_short_data()
# model from
# index: 0 speed ; 1 min ; 2 max
# this handles bsd types which always should show N/A unless we get a way to get min / max data
if [[ "${a_cpu_speeds[0]}" == 'N/A' && ${a_cpu_working[1]} != '' ]];then
if [[ "${a_cpu_info[0]}" == 'N/A' && ${a_cpu_working[1]} != '' ]];then
current_max_clock="${a_cpu_working[1]} MHz"
else
if [[ ${a_cpu_speeds[2]} != 0 ]];then
if [[ ${a_cpu_speeds[0]} == ${a_cpu_speeds[2]} ]];then
current_max_clock="${a_cpu_speeds[0]} MHz (max)"
if [[ ${a_cpu_info[2]} != 0 ]];then
if [[ ${a_cpu_info[0]} == ${a_cpu_info[2]} ]];then
current_max_clock="${a_cpu_info[0]} MHz (max)"
else
current_max_clock="${a_cpu_speeds[0]}/${a_cpu_speeds[2]} MHz"
current_max_clock="${a_cpu_info[0]}/${a_cpu_info[2]} MHz"
speed_starter='speed/max'
fi
fi
@ -12552,14 +12747,14 @@ print_battery_data()
print_cpu_data()
{
eval $LOGFS
local cpu_data='' i='' cpu_clock_speed='' cpu_multi_clock_data='' a_cpu_speeds=''
local cpu_data='' i='' cpu_clock_speed='' cpu_multi_clock_data='' a_cpu_info=''
local bmip_data='' cpu_cache='' cpu_vendor='' cpu_flags='' flag_feature='flags'
local a_cpu_working='' cpu_model='' cpu_clock='' cpu_null_error='' max_speed=''
local cpc_plural='' cpu_count_print='' model_plural='' cpu_data_string=''
local cpu_physical_count='' cpu_core_count='' cpu_core_alpha='' cpu_type=''
local cpu_2_data='' working_cpu='' temp1='' per_cpu_cores='' current_max_clock_nu=''
local line_starter="CPU:" multi_cpu_starter="${C1}clock speeds$SEP3${C2} "
local speed_starter='speed'
local speed_starter='speed' arch='' arm=' (ARM)'
##print_screen_output "A_CPU_DATA[0]=\"${A_CPU_DATA[0]}\""
# Array A_CPU_DATA always has one extra element: max clockfreq found.
@ -12570,9 +12765,16 @@ print_cpu_data()
IFS=","
a_cpu_working=(${A_CPU_DATA[0]})
current_max_clock_nu=$(( ${#A_CPU_DATA[@]} - 1 ))
a_cpu_speeds=(${A_CPU_DATA[$current_max_clock_nu]})
a_cpu_info=(${A_CPU_DATA[$current_max_clock_nu]})
IFS="$ORIGINAL_IFS"
if [[ $B_EXTRA_DATA == 'true' && ${a_cpu_info[3]} != '' ]];then
arch=$( get_cpu_architecture "${a_cpu_info[3]}" "${a_cpu_info[4]}" "${a_cpu_info[5]}" )
if [[ "$arch" != '' ]];then
arch=" ($arch)"
arm='' # note: to avoid redundant output, only show this without -x option
fi
fi
# 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_,
@ -12582,7 +12784,7 @@ print_cpu_data()
## print_screen_output "a_cpu_working=\"***${a_cpu_working[@]} $hostName+++++++\"----------"
# unless all these are null, process whatever you have
if [[ -n ${a_cpu_working[0]} || -n ${a_cpu_working[1]} || -n ${a_cpu_working[2]} || -n ${a_cpu_working[3]} ]];then
cpu_model="${a_cpu_working[0]}"
cpu_model="${a_cpu_working[0]}";
## assemble data for output
cpu_clock="${a_cpu_working[1]}"
cpu_vendor=${a_cpu_working[5]}
@ -12601,7 +12803,7 @@ print_cpu_data()
line_starter="CPU$cpc_plural:"
if [[ -z $BSD_TYPE ]];then
cpu_data_string="$cpu_count_print$cpu_core_alpha core"
cpu_data="${C1}$cpu_data_string${C2} ${a_cpu_working[0]}$model_plural ($cpu_type)"
cpu_data="${C1}$cpu_data_string${C2} ${a_cpu_working[0]}$model_plural$arch ($cpu_type)"
else
if [[ $cpu_physical_count -gt 1 ]];then
per_cpu_cores=$(($cpu_core_count/$cpu_physical_count))
@ -12636,6 +12838,7 @@ print_cpu_data()
else
bmip_data="${C1}bmips$SEP3${C2} $bmip_data "
fi
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
@ -12669,7 +12872,7 @@ print_cpu_data()
cpu_data="$cpu_data${C2} ${C1}cache$SEP3${C2} $cpu_cache"
cpu_2_data="$cpu_flags$bmip_data"
else
cpu_data="$cpu_data${C2} (ARM) $bmip_data"
cpu_data="$cpu_data${C2}$arm $bmip_data"
fi
fi
# we don't this printing out extra line unless > 1 cpu core
@ -12678,23 +12881,23 @@ print_cpu_data()
else
if [[ -z ${a_cpu_working[1]} ]];then
if [[ -z ${cpu_data/*ARM*/} ]];then
temp1=' (ARM)'
temp1=$arm
fi
a_cpu_working[1]="N/A$temp1"
else
a_cpu_working[1]="${a_cpu_working[1]%.*} MHz"
fi
# this handles bsd case unless we get a way to get max/min cpu speeds
if [[ ${a_cpu_speeds[0]} != 'N/A' && ${a_cpu_speeds[2]} != 0 ]];then
if [[ ${a_cpu_info[0]} != 'N/A' && ${a_cpu_info[2]} != 0 ]];then
if [[ $B_EXTRA_EXTRA_DATA == 'true' && ${#A_CPU_DATA[@]} -eq 2 &&
$B_SHOW_CPU == 'true' && ${a_cpu_speeds[1]} != 0 ]];then
a_cpu_working[1]="${a_cpu_speeds[0]}/${a_cpu_speeds[1]}/${a_cpu_speeds[2]} MHz"
$B_SHOW_CPU == 'true' && ${a_cpu_info[1]} != 0 ]];then
a_cpu_working[1]="${a_cpu_info[0]}/${a_cpu_info[1]}/${a_cpu_info[2]} MHz"
speed_starter='speed/min/max'
else
if [[ ${a_cpu_speeds[0]} == ${a_cpu_speeds[2]} ]];then
a_cpu_working[1]="${a_cpu_speeds[0]} MHz (max)"
if [[ ${a_cpu_info[0]} == ${a_cpu_info[2]} ]];then
a_cpu_working[1]="${a_cpu_info[0]} MHz (max)"
else
a_cpu_working[1]="${a_cpu_speeds[0]}/${a_cpu_speeds[2]} MHz"
a_cpu_working[1]="${a_cpu_info[0]}/${a_cpu_info[2]} MHz"
speed_starter='speed/max'
fi
fi
@ -12727,11 +12930,11 @@ print_cpu_data()
# we don't do this printing out extra line unless > 1 cpu core
# note the numbering, the last array item is the min/max/not found for cpu speeds
if [[ ${#A_CPU_DATA[@]} -gt 2 && $B_SHOW_CPU == 'true' ]];then
if [[ ${a_cpu_speeds[2]} != 0 ]];then
if [[ $B_EXTRA_EXTRA_DATA == 'true' && ${a_cpu_speeds[1]} != 0 ]];then
max_speed="${C1}min/max$SEP3${C2} ${a_cpu_speeds[1]}/${a_cpu_speeds[2]} MHz "
if [[ ${a_cpu_info[2]} != 0 ]];then
if [[ $B_EXTRA_EXTRA_DATA == 'true' && ${a_cpu_info[1]} != 0 ]];then
max_speed="${C1}min/max$SEP3${C2} ${a_cpu_info[1]}/${a_cpu_info[2]} MHz "
else
max_speed="${C1}max$SEP3${C2} ${a_cpu_speeds[2]} MHz "
max_speed="${C1}max$SEP3${C2} ${a_cpu_info[2]} MHz "
fi
fi
for (( i=0; i < ${#A_CPU_DATA[@]}-1; i++ ))

6
inxi.1
View file

@ -1,4 +1,4 @@
.TH INXI 1 "2017\-06\-29" inxi "inxi manual"
.TH INXI 1 "2017\-07\-27" inxi "inxi manual"
.SH NAME
inxi \- Command line system information script for console and IRC
.SH SYNOPSIS
@ -365,6 +365,10 @@ The following shows which lines / items get extra information with each extra da
.TP
.B \-x \-C
\- bogomips on CPU (if available); CPU Flags (short list).
.TP
.B \-x \-C
\- CPU microarchitecture (like Sandy Bridge, K8, ARMv8, P6, and so on). Only shows if detected. Newer
microarchitectures will have to be added as they appear, and require the CPU family id and model id.
.TP
.B \-x \-d
\- Adds items to features line of optical drive; adds rev version to optical drive.

View file

@ -1,3 +1,22 @@
=====================================================================================
Version: 2.3.26
Patch Version: 00
Script Date: 2017-07-28
-----------------------------------
Changes:
-----------------------------------
New version, new tarball, new man page. First attempt at adding cpu microarchitecture support.
Will need some updates to bring the family/model ids to fully current, but should show data for most
cpus. Next release will hopefully include latest model/family ids and microarchitecture names.
Note that while /proc/cpuinfo has the family/model id in decimal, the values are actually generally
found as hexadecimal, so inxi translates that interally so we can store the data the way it is presented.
See issue #116 for ongoing additions to this feature.
-----------------------------------
-- Harald Hope - Fri, 28 Jul 2017 00:12:56 -0700
=====================================================================================
Version: 2.3.25
Patch Version: 00