From a1822fd07f78a9f93068798d0cbe4f3b3ae40704 Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Sun, 16 Jun 2013 20:59:53 +0000 Subject: [PATCH] new version, new tarball. Added support for openSUSE repo syntax/location, as long as it's zypp or yum it will work. If it's both then it will show only one I believe, if that's a possible scenario, no idea. Added one more fix for those pesky intel vm cpu core errors, now if /proc/cpuinfo shows no siblings at all, and no core_id, but does have physical id, it will use the count for physical id as a default for core count. Not perfect, but better than calling a dual core cpu a single core. There's still a lot of mysteries with vm versions of kvm cpus, for example, if you see a dual core xeon, is that actually one core with ht, or two cores? There is no way to find that information out that I can see that is reliable. --- inxi | 169 +++++++++++++++++++++++++++---------------------- inxi.changelog | 21 ++++++ 2 files changed, 116 insertions(+), 74 deletions(-) diff --git a/inxi b/inxi index 6152302..ada423c 100755 --- a/inxi +++ b/inxi @@ -1,8 +1,8 @@ #!/usr/bin/env bash ######################################################################## #### Script Name: inxi -#### Version: 1.9.8 -#### Date: June 14 2013 +#### Version: 1.9.9 +#### Date: June 16 2013 #### Patch Number: 00 ######################################################################## #### SPECIAL THANKS @@ -3603,6 +3603,7 @@ get_cpu_ht_multicore_smp_data() num_of_processors = 0 num_of_cpus = 0 cpu_core_count = 0 + siblings = 0 core_id[0] processor_id[0] cpu_id[0] @@ -3613,14 +3614,13 @@ get_cpu_ht_multicore_smp_data() nr = 0 bArm = "false" bXeon = "false" - siblings = "" } # hack to handle xeons which can have buggy /proc/cpuinfo files /^model name/ && ( $0 ~ /Xeon/ ) { bXeon = "true" } # only do this once since sibling count does not change - /^siblings/ && ( bXeon == "true" ) && ( siblings == "" ) { + /^siblings/ && ( bXeon == "true" ) && ( siblings == 0 ) { gsub(/[^0-9]/,"",$NF) if ( $NF != "" ) { siblings = $NF @@ -3693,7 +3693,7 @@ get_cpu_ht_multicore_smp_data() num_of_cores++ } # xeon may show wrong core / physical id count, if it does, fix it - if ( num_of_cores == 1 && bXeon == "true" && siblings != "" && siblings > 1 ) { + if ( num_of_cores == 1 && bXeon == "true" && siblings > 1 ) { num_of_cores = siblings/2 } # final check, override the num of cores value if it clearly is wrong @@ -3701,6 +3701,11 @@ get_cpu_ht_multicore_smp_data() if ( ( num_of_cores == 1 ) && ( cpu_core_count * num_of_cpus > 1 ) ) { num_of_cores = cpu_core_count * num_of_cpus } + # last check, seeing some intel cpus and vms with intel cpus that do not show any + # core id data at all, or siblings. + if ( num_of_cores == 0 && num_of_processors > 0 ) { + num_of_cores = num_of_processors + } #################################################################### # algorithm @@ -3708,12 +3713,12 @@ get_cpu_ht_multicore_smp_data() # if > 1 processor && processor id (physical id) != core id then Multi-Core Processors (MCP) # if > 1 processor && processor ids (physical id) > 1 then Multiple Processors (SMP) # if = 1 processor then single core/processor Uni-Processor (UP) - if ( num_of_processors > 1 || ( bXeon == "true" && siblings != "" ) ) { + if ( num_of_processors > 1 || ( bXeon == "true" && siblings > 0 ) ) { # non-multicore HT if ( num_of_processors == (num_of_cores * 2) ) { type = type "HT-" } - else if ( bXeon == "true" && siblings != "" && siblings > 1 ) { + else if ( bXeon == "true" && siblings > 1 ) { type = type "HT-" # num_of_processors num_of_cores num_of_cpus } # non-HT multi-core or HT multi-core @@ -7274,10 +7279,11 @@ get_raid_component_data_bsd() get_repo_data() { eval $LOGFS - local repo_file='' repo_data_working='' repo_data_working2='' repo_line='' + local repo_file='' repo_data_working='' repo_data_working2='' repo_line='' repo_files='' + local repo_name='' local apt_file='/etc/apt/sources.list' yum_repo_dir='/etc/yum.repos.d/' yum_conf='/etc/yum.conf' local pacman_conf='/etc/pacman.conf' pacman_repo_dir='/etc/pacman.d/' pisi_dir='/etc/pisi/' - local freebsd_conf='/etc/portsnap.conf' + local zypp_repo_dir='/etc/zypp/repos.d/' freebsd_conf='/etc/portsnap.conf' # apt - debian, buntus, also sometimes some yum/rpm repos may create apt repos here as well if [[ -f $apt_file || -d $apt_file.d ]];then @@ -7288,76 +7294,85 @@ get_repo_data() # actually running, inxi will merely note the existence of each repo type for apt/yum. # Also, in rpm, you can install apt-rpm for the apt-get command, so it's not good to check for # only the commands in terms of selecting which repos to show. - if [[ -d $yum_repo_dir || -f $yum_conf ]];then - # older redhats put their yum data in /etc/yum.conf - for repo_file in $( ls $yum_repo_dir*.repo $yum_conf 2>/dev/null ) - do - repo_data_working="$( gawk -v repoFile=$repo_file ' - # construct the string for the print function to work with, file name: data - function print_line( fileName, repoId, repoUrl ){ - print "yum repos:" fileName ":" repoId repoUrl - } - BEGIN { - FS="\n" - IGNORECASE=1 - enabledStatus="" - repoTitle="" - urlData="" - } - # this is a hack, assuming that each item has these fields listed, we collect the 3 - # items one by one, then when the url/enabled fields are set, we print it out and - # reset the data. Not elegant but it works. Note that if enabled was not present - # we assume it is enabled then, and print the line, reset the variables. This will - # miss the last item, so it is printed if found in END - /^\[.+\]/ { - if ( urlData != "" && repoTitle != "" ){ - print_line( repoFile, repoTitle, urlData ) - enabledStatus="" - urlData="" - repoTitle="" + if [[ -d $yum_repo_dir || -f $yum_conf || -d $zypp_repo_dir ]];then + if [[ -d $yum_repo_dir || -f $yum_conf ]];then + # older redhats put their yum data in /etc/yum.conf + repo_files=$( ls $yum_repo_dir*.repo $yum_conf 2>/dev/null ) + repo_name='yum' + elif [[ -d $zypp_repo_dir ]];then + repo_files=$( ls $zypp_repo_dir*.repo 2>/dev/null ) + repo_name='zypp' + fi + if [[ -n $repo_files ]];then + for repo_file in $repo_files + do + repo_data_working="$( gawk -v repoFile=$repo_file ' + # construct the string for the print function to work with, file name: data + function print_line( fileName, repoId, repoUrl ){ + print "'$repo_name' sources:" fileName ":" repoId repoUrl } - gsub( /\[|\]/, "", $1 ) # strip out the brackets - repoTitle = $1 " ~ " - } - /^(mirrorlist|baseurl)/ { - sub( /(mirrorlist|baseurl)[[:space:]]*=[[:space:]]*/, "", $1 ) # strip out the field starter - urlData = $1 - } - # note: enabled = 1. enabled = 0 means disabled - /^enabled[[:space:]]*=/ { - enabledStatus = $1 - } - # print out the line if all 3 values are found, otherwise if a new - # repoTitle is hit above, it will print out the line there instead - { - if ( urlData != "" && enabledStatus != "" && repoTitle != "" ){ - if ( enabledStatus !~ /enabled[[:space:]]*=[[:space:]]*0/ ){ + BEGIN { + FS="\n" + IGNORECASE=1 + enabledStatus="" + repoTitle="" + urlData="" + } + # this is a hack, assuming that each item has these fields listed, we collect the 3 + # items one by one, then when the url/enabled fields are set, we print it out and + # reset the data. Not elegant but it works. Note that if enabled was not present + # we assume it is enabled then, and print the line, reset the variables. This will + # miss the last item, so it is printed if found in END + /^\[.+\]/ { + if ( urlData != "" && repoTitle != "" ){ + print_line( repoFile, repoTitle, urlData ) + enabledStatus="" + urlData="" + repoTitle="" + } + gsub( /\[|\]/, "", $1 ) # strip out the brackets + repoTitle = $1 " ~ " + } + /^(mirrorlist|baseurl)/ { + sub( /(mirrorlist|baseurl)[[:space:]]*=[[:space:]]*/, "", $1 ) # strip out the field starter + urlData = $1 + } + # note: enabled = 1. enabled = 0 means disabled + /^enabled[[:space:]]*=/ { + enabledStatus = $1 + } + # print out the line if all 3 values are found, otherwise if a new + # repoTitle is hit above, it will print out the line there instead + { + if ( urlData != "" && enabledStatus != "" && repoTitle != "" ){ + if ( enabledStatus !~ /enabled[[:space:]]*=[[:space:]]*0/ ){ + print_line( repoFile, repoTitle, urlData ) + } + enabledStatus="" + urlData="" + repoTitle="" + } + } + END { + # print the last one if there is data for it + if ( urlData != "" && repoTitle != "" ){ print_line( repoFile, repoTitle, urlData ) } - enabledStatus="" - urlData="" - repoTitle="" } - } - END { - # print the last one if there is data for it - if ( urlData != "" && repoTitle != "" ){ - print_line( repoFile, repoTitle, urlData ) - } - } - ' $repo_file )" - - # then load the global for each file as it gets filled - if [[ -n $repo_data_working ]];then - if [[ -z $REPO_DATA ]];then - REPO_DATA="$repo_data_working" - else - REPO_DATA="$REPO_DATA + ' $repo_file )" + + # then load the global for each file as it gets filled + if [[ -n $repo_data_working ]];then + if [[ -z $REPO_DATA ]];then + REPO_DATA="$repo_data_working" + else + REPO_DATA="$REPO_DATA $repo_data_working" + fi + repo_data_working='' fi - repo_data_working='' - fi - done + done + fi # pacman - archlinux, going to assume that pisi and arch/pacman don't have the above issue with apt/yum # pisi - pardus elif [[ -d $pisi_dir && -n $( type -p pisi ) ]];then @@ -9112,6 +9127,7 @@ print_hard_disk_data() local hdd_capacity="${a_hdd_basic_working[0]}" local hdd_used=${a_hdd_basic_working[1]} local bsd_unsupported='Hard drive data not yet supported for BSD systems.' + local hdd_name_temp='' if [[ $B_SHOW_BASIC_DISK == 'true' || $B_SHOW_DISK == 'true' ]];then ## note: the output part of this should be in the print hdd data function, not here @@ -9151,7 +9167,12 @@ print_hard_disk_data() fi dev_data="${C1}id$SEP3${C2} /dev/${a_hdd_working[0]} " fi - hdd_name="${C1}model$SEP3${C2} ${a_hdd_working[2]}" + if [[ -n ${a_hdd_working[2]} ]];then + hdd_name_temp=${a_hdd_working[2]} + else + hdd_name_temp='N/A' + fi + hdd_name="${C1}model$SEP3${C2} $hdd_name_temp" hdd_string="$usb_data$dev_data$hdd_name$size_data$hdd_serial$hdd_temp_data" hdd_model="${hdd_model}${C1}$(($i+1)):${C2} $hdd_string " # printing line one, then new lines according to $divisor setting, and after, if leftovers, print that line. diff --git a/inxi.changelog b/inxi.changelog index 941fded..c2bfd08 100755 --- a/inxi.changelog +++ b/inxi.changelog @@ -1,3 +1,24 @@ +===================================================================================== +Version: 1.9.9 +Patch Version: 00 +Script Date: June 16 2013 +----------------------------------- +Changes: +----------------------------------- +new version, new tarball. Added support for openSUSE repo syntax/location, as long as it's +zypp or yum it will work. If it's both then it will show only one I believe, if that's a possible scenario, no idea. + +Added one more fix for those pesky intel vm cpu core errors, now if /proc/cpuinfo shows no siblings at all, +and no core_id, but does have physical id, it will use the count for physical id as a default for core count. + +Not perfect, but better than calling a dual core cpu a single core. + +There's still a lot of mysteries with vm versions of kvm cpus, for example, if you see a dual core xeon, is +that actually one core with ht, or two cores? There is no way to find that information out that I can see that is +reliable. +----------------------------------- +-- Harald Hope - Sun, 16 Jun 2013 13:56:28 -0700 + ===================================================================================== Version: 1.9.8 Patch Version: 00