quick test of branch one inxi, ignore

This commit is contained in:
inxi-svn 2013-01-28 22:34:58 +00:00
parent b057a12938
commit 082151ef84

235
inxi
View file

@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
######################################################################## ########################################################################
#### Script Name: inxi #### Script Name: inxi
#### version: 1.8.26 #### version: 1.8.32
#### Date: December 22 2012 #### Date: January 23 2013
#### Patch Number: 01-b1 #### Patch Number: 01-one
######################################################################## ########################################################################
#### SPECIAL THANKS #### SPECIAL THANKS
######################################################################## ########################################################################
@ -12,21 +12,22 @@
######################################################################## ########################################################################
#### ABOUT INXI #### ABOUT INXI
######################################################################## ########################################################################
#### inxi is a fork of infobash 3.02, the original bash sys info script by locsmif #### inxi is a fork of infobash 3.02, the original bash sys info tool by locsmif
#### As time permits functionality improvements and recoding will occur. #### As time permits functionality improvements and recoding will occur.
#### ####
#### inxi, the universal, portable, system info script for irc. #### inxi, the universal, portable, system information tool for irc.
#### Tested with Irssi, Xchat, Konversation, BitchX, KSirc, ircII, #### Tested with Irssi, Xchat, Konversation, BitchX, KSirc, ircII,
#### Gaim/Pidgin, Weechat, KVIrc and Kopete. #### Gaim/Pidgin, Weechat, KVIrc and Kopete.
#### Original infobash author and copyright holder: #### Original infobash author and copyright holder:
#### Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif #### Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif
#### inxi version: Copyright (C) 2008-12 Scott Rogers & Harald Hope #### inxi version: Copyright (C) 2008-2013 Scott Rogers & Harald Hope
#### Further fixes (listed as known): Horst Tritremmel <hjt at sidux.com> #### Further fixes (listed as known): Horst Tritremmel <hjt at sidux.com>
#### Steven Barrett (aka: damentz) - usb audio patch; swap percent used patch #### Steven Barrett (aka: damentz) - usb audio patch; swap percent used patch
#### Jarett.Stevens - dmidecde -M patch for older systems with the /sys #### Jarett.Stevens - dmidecde -M patch for older systems with the /sys
#### ####
#### Current script home page: http://techpatterns.com/forums/about1131.html #### Current script home page/wiki/svn: http://inxi.googlecode.com
#### Script svn: http://code.google.com/p/inxi #### Script forums: http://techpatterns.com/forums/forum-33.html
#### IRC support: irc.oftc.net channel #smxi
#### ####
#### This program is free software; you can redistribute it and/or modify #### This program is free software; you can redistribute it and/or modify
#### it under the terms of the GNU General Public License as published by #### it under the terms of the GNU General Public License as published by
@ -107,7 +108,7 @@
#### * All variables should clearly explain what they are, except counters like i, j. #### * All variables should clearly explain what they are, except counters like i, j.
#### * Each word of Bash variable must be separated by '_' (underscore) (camel form), like: cpu_data #### * Each word of Bash variable must be separated by '_' (underscore) (camel form), like: cpu_data
#### * Each word of Gawk variable must be like this (first word lower, following start with upper): cpuData #### * Each word of Gawk variable must be like this (first word lower, following start with upper): cpuData
#### * Global variables are 'UPPER CASE', at top of script. #### * Global variables are 'UPPER CASE', at top of this file.
#### ie, SOME_VARIABLE='' #### ie, SOME_VARIABLE=''
#### * Local variables are 'lower case' and declared at the top of the function using local, always. #### * Local variables are 'lower case' and declared at the top of the function using local, always.
#### ie: local some_variable='' #### ie: local some_variable=''
@ -133,7 +134,7 @@
################################################################################### ###################################################################################
#### KDE Konversation information. Moving from dcop(qt3/KDE3) to dbus(qt4/KDE4) #### KDE Konversation information. Moving from dcop(qt3/KDE3) to dbus(qt4/KDE4)
################################################################################### ###################################################################################
#### * dcop and dbus -- these talk back to Konversation from this script #### * dcop and dbus -- these talk back to Konversation from this program
#### * Scripting info -- http://konversation.berlios.de/docs/scripting.html #### * Scripting info -- http://konversation.berlios.de/docs/scripting.html
#### -- http://www.kde.org.uk/apps/konversation/ #### -- http://www.kde.org.uk/apps/konversation/
#### * dbus info -- http://dbus.freedesktop.org/doc/dbus-tutorial.html #### * dbus info -- http://dbus.freedesktop.org/doc/dbus-tutorial.html
@ -145,6 +146,7 @@
#### Because webpages come and go, the above information needs to be moved to inxi's wiki #### Because webpages come and go, the above information needs to be moved to inxi's wiki
######################################################################## ########################################################################
#### Valuable Resources #### Valuable Resources
#### CPU flags: http://unix.stackexchange.com/questions/43539/what-do-the-flags-in-proc-cpuinfo-mean
#### gawk arrays: http://www.math.utah.edu/docs/info/gawk_12.html #### gawk arrays: http://www.math.utah.edu/docs/info/gawk_12.html
#### raid mdstat: http://www-01.ibm.com/support/docview.wss?uid=isg3T1011259 #### raid mdstat: http://www-01.ibm.com/support/docview.wss?uid=isg3T1011259
#### http://www.howtoforge.com/replacing_hard_disks_in_a_raid1_array #### http://www.howtoforge.com/replacing_hard_disks_in_a_raid1_array
@ -1264,6 +1266,11 @@ script_self_updater()
eval $LOGFS eval $LOGFS
local wget_error=0 file_contents='' wget_man_error=0 local wget_error=0 file_contents='' wget_man_error=0
local man_file_path="$MAN_FILE_LOCATION/inxi.1.gz" local man_file_path="$MAN_FILE_LOCATION/inxi.1.gz"
if [[ $B_RUNNING_IN_SHELL != 'true' ]];then
print_screen_output "Sorry, you can't run the $SCRIPT_NAME self updater option (-U) in an IRC client."
exit 1
fi
print_screen_output "Starting $SCRIPT_NAME self updater." print_screen_output "Starting $SCRIPT_NAME self updater."
print_screen_output "Currently running $SCRIPT_NAME version number: $SCRIPT_VERSION_NUMBER" print_screen_output "Currently running $SCRIPT_NAME version number: $SCRIPT_VERSION_NUMBER"
@ -2153,6 +2160,9 @@ get_parameters()
14) 14)
script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_4" 'svn: branch four server' script_self_updater "$SCRIPT_DOWNLOAD_BRANCH_4" 'svn: branch four server'
;; ;;
30)
B_RUNNING_IN_SHELL='true'
;;
ftp*) ftp*)
ALTERNATE_FTP="$OPTARG" ALTERNATE_FTP="$OPTARG"
;; ;;
@ -2349,25 +2359,44 @@ show_options()
## print out version information for -V/--version ## print out version information for -V/--version
print_version_info() print_version_info()
{ {
local last_modified=$( grep -im 1 'date:' $SCRIPT_PATH/$SCRIPT_NAME | gawk '{print $3,$4,$5}' ) # if not in PATH could be either . or directory name, no slash starting
local script_path=$SCRIPT_PATH script_symbolic_start=''
print_screen_output "$SCRIPT_NAME - the universal, portable, system info script for console and irc." if [[ $script_path == '.' ]];then
print_screen_output "Version: $SCRIPT_VERSION_NUMBER-$SCRIPT_PATCH_NUMBER" script_path=$( pwd )
print_screen_output "Script Last Modified: $last_modified" elif [[ -z $( grep '^/' <<< "$script_path" ) ]];then
print_screen_output "Script Location: $SCRIPT_PATH" script_path="$( pwd )/$script_path"
print_screen_output " " fi
print_screen_output "Tested in Irssi, Xchat, Konversation, BitchX, KSirc, ircII," # handle if it's a symbolic link, rare, but can happen with script directories in irc clients
print_screen_output "Gaim/Pidgin, Weechat, KVIrc, Quassel, Kopete, and others." # which would only matter if user starts inxi with -! 30 override in irc client
print_screen_output " " if [[ -L $script_path/$SCRIPT_NAME ]];then
print_screen_output "This script is a fork of Infobash 3.02, which is:" script_symbolic_start=$script_path/$SCRIPT_NAME
print_screen_output "Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif" script_path=$( readlink $script_path/$SCRIPT_NAME )
print_screen_output "Subsequent changes and modifications (after Infobash 3.02) are:" script_path=$( dirname $script_path )
print_screen_output "Copyright (C) 2008-$(date +%y) Scott Rogers, Harald Hope, aka trash80 & h2" fi
print_screen_output " " local last_modified=$( grep -m 1 '^#### Date:' $SCRIPT_PATH/$SCRIPT_NAME | gawk -F ': ' '{print $NF}' )
print_screen_output "This program is free software; you can redistribute it and/or modify" local year_modified=$( gawk '{print $NF}' <<< "$last_modified" )
print_screen_output "it under the terms of the GNU General Public License as published by"
print_screen_output "the Free Software Foundation; either version 3 of the License, or" print_screen_output "$SCRIPT_NAME $SCRIPT_VERSION_NUMBER-$SCRIPT_PATCH_NUMBER ($last_modified)"
print_screen_output "(at your option) any later version." if [[ $B_RUNNING_IN_SHELL == 'true' ]];then
print_screen_output " "
print_screen_output "Program Location: $script_path"
if [[ -n $script_symbolic_start ]];then
print_screen_output "Started via symbolic link: $script_symbolic_start"
fi
print_screen_output "Website: http://inxi.goooglecode.com - IRC: irc.oftc.net channel: #smxi"
print_screen_output "Forums: http://techpatterns.com/forums/forum-33.html"
print_screen_output " "
print_screen_output "$SCRIPT_NAME - the universal, portable, system information tool for console and irc."
print_screen_output "This program is a fork of Infobash 3.02:"
print_screen_output "Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif"
print_screen_output "Subsequent changes and modifications (after Infobash 3.02):"
print_screen_output "Copyright (C) 2008-$year_modified Scott Rogers, Harald Hope, aka trash80 & h2"
print_screen_output " "
print_screen_output "This program is free software; you can redistribute it and/or modify"
print_screen_output "it under the terms of the GNU General Public License as published by"
print_screen_output "the Free Software Foundation; either version 3 of the License, or"
print_screen_output "(at your option) any later version. (http://www.gnu.org/licenses/gpl.html)"
fi
} }
######################################################################## ########################################################################
@ -2384,7 +2413,7 @@ get_start_client()
eval $LOGFS eval $LOGFS
local irc_client_path='' irc_client_path_lower='' non_native_konvi='' i='' local irc_client_path='' irc_client_path_lower='' non_native_konvi='' i=''
local b_non_native_app='false' pppid='' app_working_name='' file_data='' local b_non_native_app='false' pppid='' app_working_name='' file_data=''
local b_qt4_konvi='false' local b_qt4_konvi='false' ps_l=''
if [[ $B_RUNNING_IN_SHELL == 'true' ]];then if [[ $B_RUNNING_IN_SHELL == 'true' ]];then
IRC_CLIENT='Shell' IRC_CLIENT='Shell'
@ -2401,7 +2430,7 @@ get_start_client()
# from inside itself, as a script, the parent is konversation/xchat, not perl/bash etc # from inside itself, as a script, the parent is konversation/xchat, not perl/bash etc
# note: perl can report as: perl5.10.0, so it needs wildcard handling # note: perl can report as: perl5.10.0, so it needs wildcard handling
case $app_working_name in case $app_working_name in
bash|dash|sh|python*|perl*) # We want to know who wrapped it into the shell or perl. bash|dash|sh|zsh|python*|perl*) # We want to know who wrapped it into the shell or perl.
pppid="$( ps -p $PPID -o ppid --no-headers | sed 's/ //g' )" pppid="$( ps -p $PPID -o ppid --no-headers | sed 's/ //g' )"
if [[ -n $pppid && -f /proc/$pppid/exe ]];then if [[ -n $pppid && -f /proc/$pppid/exe ]];then
irc_client_path="$( readlink /proc/$pppid/exe )" irc_client_path="$( readlink /proc/$pppid/exe )"
@ -2416,7 +2445,7 @@ get_start_client()
# as they appear. # as they appear.
case $app_working_name in case $app_working_name in
# check for shell first # check for shell first
bash|dash|sh) bash|dash|sh|zsh)
unset IRC_CLIENT_VERSION unset IRC_CLIENT_VERSION
IRC_CLIENT="Shell wrapper" IRC_CLIENT="Shell wrapper"
;; ;;
@ -2686,7 +2715,14 @@ get_start_client()
exit exit
}' )" }' )"
else else
IRC_CLIENT="PPID=\"$PPID\" - empty?" # this should handle certain cases where it's ssh or some other startup tool
# that falls through all the other tests
ps_l=$(ps -l | gawk '($5 == '$PPID') {print $NF}' )
if [[ -n $ps_l ]];then
IRC_CLIENT=$ps_l
else
IRC_CLIENT="PPID=\"$PPID\" - empty?"
fi
unset IRC_CLIENT_VERSION unset IRC_CLIENT_VERSION
fi fi
fi fi
@ -3076,15 +3112,32 @@ get_cpu_data()
# stop script for a bit to let cpu slow down before parsing cpu /proc file # stop script for a bit to let cpu slow down before parsing cpu /proc file
sleep $CPU_SLEEP sleep $CPU_SLEEP
IFS=$'\n' IFS=$'\n'
A_CPU_DATA=( $( gawk -F': ' ' A_CPU_DATA=( $(
gawk -F': ' '
BEGIN { BEGIN {
IGNORECASE=1 IGNORECASE=1
# need to prime nr for arm cpus, which do not have processor number output in some cases
nr = 0
count = 0
bArm = "false"
} }
# TAKE STRONGER NOTE: \t+ does NOT always work, MUST be [ \t]+ # 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! # TAKE NOTE: \t+ will work for $FILE_CPUINFO, but SOME ARBITRARY FILE used for TESTING might contain SPACES!
# Therefore PATCH to use [ \t]+ when TESTING! # Therefore PATCH to use [ \t]+ when TESTING!
/^processor[ \t]+:/ { /^processor[ \t]+:/ {
nr = $NF gsub(/,/, " ", $NF)
gsub(/^ +| +$/, "", $NF)
if ( $NF ~ "^[0-9]+$" ) {
nr = $NF
}
else {
if ( $NF ~ "^ARM" ) {
bArm = "true"
}
count += 1
nr = count - 1
cpu[nr, "model"] = $NF
}
} }
/^model name|^cpu\t+:/ { /^model name|^cpu\t+:/ {
@ -3118,7 +3171,7 @@ get_cpu_data()
cpu[nr, "cache"] = $NF cpu[nr, "cache"] = $NF
} }
/^flags/ { /^flags|^features/ {
cpu[nr, "flags"] = $NF cpu[nr, "flags"] = $NF
} }
@ -3134,25 +3187,36 @@ get_cpu_data()
END { END {
#if (!nr) { print ",,,"; exit } # <- should this be necessary or should bash handle that #if (!nr) { print ",,,"; exit } # <- should this be necessary or should bash handle that
for ( i = 0; i <= nr; i++ ) { for ( i = 0; i <= nr; i++ ) {
# note: assuming bogomips for arm at 1 x clock
# http://en.wikipedia.org/wiki/BogoMips ARM could change so watch this
# maybe add: && bArm == "true" but I think most of the bogomips roughly equal cpu speed if not amd/intel
if ( cpu[i, "bogomips"] != "" && cpu[i, "speed"] == "" ) {
cpu[i, "speed"] = cpu[i, "bogomips"]
}
print cpu[i, "model"] "," cpu[i, "speed"] "," cpu[i, "cache"] "," cpu[i, "flags"] "," cpu[i, "bogomips"] "," cpu[nr, "vendor"] print cpu[i, "model"] "," cpu[i, "speed"] "," cpu[i, "cache"] "," cpu[i, "flags"] "," cpu[i, "bogomips"] "," cpu[nr, "vendor"]
} }
# this is / was used in inxi short output only, but when it is N/A, need to use the previous array
# value, from above, the actual speed that is, for short output, key 0.
if (!min) { if (!min) {
print "not found" print "N/A"
exit exit
} }
if (min != max) {
printf("Min:%s%s Max:%s%s\n", min, "Mhz", max, "Mhz")
}
else { else {
printf("%s %s\n", max, "Mhz") if (min != max) {
printf("Min:%s%s Max:%s%s\n", min, "Mhz", max, "Mhz")
}
else {
printf("%s %s\n", max, "Mhz")
}
} }
}' $FILE_CPUINFO ) ) }
' $FILE_CPUINFO ) )
log_function_data 'cat' "$FILE_CPUINFO" log_function_data 'cat' "$FILE_CPUINFO"
fi fi
IFS="$ORIGINAL_IFS" IFS="$ORIGINAL_IFS"
temp_array=${A_CPU_DATA[@]} temp_array=${A_CPU_DATA[@]}
log_function_data "A_CPU_DATA: $temp_array" log_function_data "A_CPU_DATA: $temp_array"
# echo ta: ${temp_array[@]}
eval $LOGFE eval $LOGFE
# echo getMainCpu: ${[@]} # echo getMainCpu: ${[@]}
} }
@ -3179,10 +3243,27 @@ get_cpu_ht_multicore_smp_data()
cpu_id[0] cpu_id[0]
type = "-" type = "-"
iter = 0 iter = 0
# needed to handle arm cpu, no processor number cases
count = 0
nr = 0
bArm = "false"
} }
# array of logical processors, both HT and physical # array of logical processors, both HT and physical
/^processor/ { /^processor/ {
processor_id[iter] = $NF gsub(/,/, " ", $NF)
gsub(/^ +| +$/, "", $NF)
if ( $NF ~ "^[0-9]+$" ) {
processor_id[iter] = $NF
}
else {
if ( $NF ~ "^ARM" ) {
bArm = "true"
}
count += 1
nr = count - 1
processor_id[iter] = nr
}
} }
# array of physical cpus ids # array of physical cpus ids
/^physical/ { /^physical/ {
@ -3268,8 +3349,7 @@ get_cpu_ht_multicore_smp_data()
print type " " num_of_cpus " " num_of_cores print type " " num_of_cpus " " num_of_cores
} }
' $FILE_CPUINFO ' $FILE_CPUINFO ) )
) )
fi fi
temp_array=${A_CPU_TYPE_PCNT_CCNT[@]} temp_array=${A_CPU_TYPE_PCNT_CCNT[@]}
log_function_data "A_CPU_TYPE_PCNT_CCNT: $temp_array" log_function_data "A_CPU_TYPE_PCNT_CCNT: $temp_array"
@ -3438,6 +3518,21 @@ get_desktop_environment()
elif [[ -n $( grep -is '^I3_' <<< "$xprop_root" ) ]];then elif [[ -n $( grep -is '^I3_' <<< "$xprop_root" ) ]];then
version=$( get_de_app_version 'i3' '^i3' '3' ) version=$( get_de_app_version 'i3' '^i3' '3' )
desktop_environment='i3' desktop_environment='i3'
elif [[ -n $( grep -is 'WINDOWMAKER' <<< "$xprop_root" ) ]];then
version=$( get_de_app_version 'wmaker' '^Window[[:space:]]*Maker' 'NF' )
if [[ -n $version ]];then
version="$version "
fi
desktop_environment="WindowMaker"
elif [[ -n $( grep -is '^_WM2' <<< "$xprop_root" ) ]];then
# note; there isn't actually a wm2 version available but error handling should cover it and return null
# maybe one day they will add it?
version=$( get_de_app_version 'wm2' '^wm2' 'NF' )
# not certain will always have version, so keep output right if not
if [[ -n $version ]];then
version="$version "
fi
desktop_environment="WM2"
fi fi
fi fi
# a few manual hacks for things that don't id with xprop, these are just good guesses # a few manual hacks for things that don't id with xprop, these are just good guesses
@ -3463,6 +3558,10 @@ get_desktop_environment()
elif [[ -n $( grep -Eis '([[:space:]]|/)dwm' <<< "$ps_aux" | grep -v 'grep' ) ]];then elif [[ -n $( grep -Eis '([[:space:]]|/)dwm' <<< "$ps_aux" | grep -v 'grep' ) ]];then
version=$( get_de_app_version 'dwm' '^dwm' '1' ) version=$( get_de_app_version 'dwm' '^dwm' '1' )
desktop_environment='dwm' desktop_environment='dwm'
elif [[ -n $( grep -is 'wmii2' <<< "$ps_aux" | grep -v 'grep' ) ]];then
version=$( get_de_app_version 'wmii2' '^wmii2' '1' )
desktop_environment='wmii2'
# note: in debian at least, wmii is actuall wmii3
elif [[ -n $( grep -is 'wmii' <<< "$ps_aux" | grep -v 'grep' ) ]];then elif [[ -n $( grep -is 'wmii' <<< "$ps_aux" | grep -v 'grep' ) ]];then
version=$( get_de_app_version 'wmii' '^wmii' '1' ) version=$( get_de_app_version 'wmii' '^wmii' '1' )
desktop_environment='wmii' desktop_environment='wmii'
@ -3487,7 +3586,7 @@ get_de_app_version()
# mate-about -v = MATE Desktop Environment 1.4.0 # mate-about -v = MATE Desktop Environment 1.4.0
case $1 in case $1 in
dwm|jwm|mate-about|wmii) dwm|jwm|mate-about|wmii|wmii2)
get_version='-v' get_version='-v'
;; ;;
esac esac
@ -3516,7 +3615,7 @@ get_de_app_version()
/'$2'/ { /'$2'/ {
# sample: dwm-5.8.2, ©.. etc, why no space? who knows. Also get rid of v in number string # sample: dwm-5.8.2, ©.. etc, why no space? who knows. Also get rid of v in number string
# xfce, and other, output has , in it, so dump all commas # xfce, and other, output has , in it, so dump all commas
gsub(/(,|dwm-|wmii-|v|V)/, "",$'$3') gsub(/(,|dwm-|wmii2-|wmii-|v|V)/, "",$'$3')
print $'$3' print $'$3'
exit # quit after first match prints exit # quit after first match prints
}' <<< "$version_data" ) }' <<< "$version_data" )
@ -4518,13 +4617,13 @@ get_hard_drive_data_advanced()
IFS="$ORIGINAL_IFS" IFS="$ORIGINAL_IFS"
## then we'll loop through that array looking for matches. ## then we'll loop through that array looking for matches.
if [[ -n $( grep -E '[sv]d[a-z]' <<< ${A_HDD_DATA[@]} ) ]];then if [[ -n $( grep -E 'sd[a-z]' <<< ${A_HDD_DATA[@]} ) ]];then
# first pack the main ls variable so we don't have to keep using ls /dev... # first pack the main ls variable so we don't have to keep using ls /dev...
# not all systems have /dev/disk/by-id # not all systems have /dev/disk/by-id
ls_disk_by_id="$( ls -l /dev/disk/by-id 2>/dev/null )" ls_disk_by_id="$( ls -l /dev/disk/by-id 2>/dev/null )"
for (( i=0; i < ${#A_HDD_DATA[@]} - 1; i++ )) for (( i=0; i < ${#A_HDD_DATA[@]} - 1; i++ ))
do do
if [[ -n $( grep -E '^[sv]d[a-z]' <<< ${A_HDD_DATA[$i]} ) ]];then if [[ -n $( grep -E '^sd[a-z]' <<< ${A_HDD_DATA[$i]} ) ]];then
IFS="," IFS=","
a_temp_working=( ${A_HDD_DATA[$i]} ) a_temp_working=( ${A_HDD_DATA[$i]} )
IFS="$ORIGINAL_IFS" IFS="$ORIGINAL_IFS"
@ -6751,7 +6850,7 @@ process_cpu_flags()
i = 1 # start at one because of for increment issue i = 1 # start at one because of for increment issue
flag_string = "" flag_string = ""
} }
/^(lm|nx|pni|svm|vmx|(sss|ss)e([2-9])?([a-z])?(_[0-9])?)$/ { /^(lm|nx|pae|pni|svm|vmx|(sss|ss)e([2-9])?([a-z])?(_[0-9])?)$/ {
if ( $0 == "pni" ){ if ( $0 == "pni" ){
a_flags[i] = "sse3" a_flags[i] = "sse3"
} }
@ -6899,9 +6998,16 @@ print_short_data()
local cpu_model="${a_cpu_working[0]}" local cpu_model="${a_cpu_working[0]}"
## assemble data for output ## assemble data for output
local cpu_clock="${a_cpu_working[1]}" # old CPU3 local cpu_clock="${a_cpu_working[1]}" # old CPU3
# this gets that weird min/max final array item # this gets that weird min/max final array item, which almost never contains any data of use
local min_max_clock_nu=$(( ${#A_CPU_DATA[@]} - 1 )) local min_max_clock_nu=$(( ${#A_CPU_DATA[@]} - 1 ))
local min_max_clock=${A_CPU_DATA[$min_max_clock_nu]} local min_max_clock=${A_CPU_DATA[$min_max_clock_nu]}
# this handles the case of for example ARM cpus, which will not have data for
# min/max, since they don't have speed. Since that sets a flag, not found, just
# look for that and use the speed from the first array array, same where we got
# model from
if [[ "$min_max_clock" == 'N/A' && ${a_cpu_working[1]} != '' ]];then
min_max_clock="${a_cpu_working[1]}"
fi
local script_patch_number=$( get_patch_version_string ) local script_patch_number=$( get_patch_version_string )
#set_color_scheme 12 #set_color_scheme 12
@ -7108,7 +7214,8 @@ print_cpu_data()
# This has been confirmed by #bash on freenode. # This has been confirmed by #bash on freenode.
# The above mentioned only emerges when using the debugging markers below # The above mentioned only emerges when using the debugging markers below
## print_screen_output "a_cpu_working=\"***${a_cpu_working[@]} $hostName+++++++\"----------" ## print_screen_output "a_cpu_working=\"***${a_cpu_working[@]} $hostName+++++++\"----------"
# cpu cache
if [[ -z ${a_cpu_working[2]} ]];then if [[ -z ${a_cpu_working[2]} ]];then
a_cpu_working[2]="unknown" a_cpu_working[2]="unknown"
fi fi
@ -7133,6 +7240,7 @@ print_cpu_data()
fi fi
# only print shortened list # only print shortened list
if [[ $B_CPU_FLAGS_FULL != 'true' ]];then if [[ $B_CPU_FLAGS_FULL != 'true' ]];then
# gawk has already sorted this output
cpu_flags=$( process_cpu_flags "${a_cpu_working[3]}" ) cpu_flags=$( process_cpu_flags "${a_cpu_working[3]}" )
cpu_flags=" ${C1}flags$SEP3${C2} ($cpu_flags)" cpu_flags=" ${C1}flags$SEP3${C2} ($cpu_flags)"
fi fi
@ -7149,6 +7257,7 @@ print_cpu_data()
print_screen_output "$cpu_data" print_screen_output "$cpu_data"
# we don't this printing out extra line unless > 1 cpu core # we don't 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_DATA[@]} -gt 2 && $B_SHOW_CPU == 'true' ]];then
for (( i=0; i < ${#A_CPU_DATA[@]}-1; i++ )) for (( i=0; i < ${#A_CPU_DATA[@]}-1; i++ ))
do do
@ -7179,18 +7288,26 @@ print_cpu_data()
print_cpu_flags_full() print_cpu_flags_full()
{ {
eval $LOGFS eval $LOGFS
local cpu_flags_full="$1" a_cpu_flags='' line_starter='' # note: sort only sorts lines, not words in a string, so convert to lines
local i=0 counter=0 max_length=18 max_length_add=18 flag='' flag_data='' local cpu_flags_full="$( echo $1 | tr " " "\n" | sort )"
local a_cpu_flags='' line_starter=''
local i=0 counter=0 max_length=85 max_length_minus=15 flag='' flag_data=''
local line_length_max=''
# build the flag line array # build the flag line array
for flag in $cpu_flags_full for flag in $cpu_flags_full
do do
a_cpu_flags[$counter]="${a_cpu_flags[$counter]}$flag " a_cpu_flags[$counter]="${a_cpu_flags[$counter]}$flag "
if [[ $i -ge $max_length ]];then if [[ $counter -eq 0 ]];then
(( counter++ )) line_length_max=$(( $max_length - $max_length_minus ))
max_length=$(( $max_length + $max_length_add )) else
line_length_max=$max_length
fi
if [[ $( wc -c <<< ${a_cpu_flags[$counter]} ) -gt $line_length_max ]];then
(( counter++ ))
fi fi
((i++))
done done
# then print it out # then print it out
for (( i=0; i < ${#a_cpu_flags[@]};i++ )) for (( i=0; i < ${#a_cpu_flags[@]};i++ ))