From b1503df5ae0cba7a367b7b521c5deb31eb963574 Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Sun, 25 Jan 2009 03:53:20 +0000 Subject: [PATCH] testing commit, this is mainly just to test the sample data file, and to fix some bugs in the cpu sections --- inxi | 184 ++++++++++++++++++++++++----------------------------------- 1 file changed, 73 insertions(+), 111 deletions(-) diff --git a/inxi b/inxi index 4824db8..e4a7f75 100755 --- a/inxi +++ b/inxi @@ -1,8 +1,8 @@ #!/bin/bash ######################################################################## #### Script Name: inxi -#### version: 0.9.4-b1-t2 -#### Date: January 8, 2009 +#### version: 0.9.6-b1-t1 +#### Date: 23 January 2009 ######################################################################## #### SPECIAL THANKS ######################################################################## @@ -19,7 +19,7 @@ #### Gaim/Pidgin, Weechat, KVIrc and Kopete. #### Original infobash author and copyright holder: #### Copyright (C) 2005-2007 Michiel de Boer a.k.a. locsmif -#### inxi version: Copyright (C) 2008 Scott Rogers & Harald Hope +#### inxi version: Copyright (C) 2008-9 Scott Rogers & Harald Hope #### Further fixes (listed as known): Horst Tritremmel #### #### Current script home page: http://techpatterns.com/forums/about1131.html @@ -180,7 +180,8 @@ B_MODULES_DIR='false' # B_PARTITIONS_DIR='false' # ### Directory's used when present -DIR_CPUINFO='/proc/cpuinfo' +# DIR_CPUINFO='/proc/cpuinfo' +DIR_CPUINFO="$HOME/bin/scripts/inxi/svn/modules/data/xeon_2x_2" DIR_MEMINFO='/proc/meminfo' DIR_ASOUND_DEVICE='/proc/asound/cards' DIR_ASOUND_VERSION='/proc/asound/version' @@ -263,7 +264,7 @@ CN='' ### Distro Data # In cases of derived distros where the version file of the base distro can also be found under /etc, # the derived distro's version file should go first. (Such as with Sabayon / Gentoo) -DISTROS_DERIVED="antix-version kanotix-version knoppix-version mandrake-release sabayon-release sidux-version turbolinux-release zenwalk-version" +DISTROS_DERIVED="antix-version kanotix-version knoppix-version mandrake-release pardus-release sabayon-release sidux-version turbolinux-release zenwalk-version" # debian_version excluded from DISTROS_PRIMARY so Debian can fall through to /etc/issue detection. Same goes for Ubuntu. DISTROS_EXCLUDE_LIST="debian_version ubuntu_version" DISTROS_PRIMARY="gentoo-release redhat-release slackware-version SuSE-release" @@ -1377,6 +1378,7 @@ get_cpu_core_count() # count the number of processors given local cpu_core_count=${A_CPU_TYPE_PCNT_CCNT[2]} local cpu_type='' + echo A_CPU_TYPE_PCNT_CCNT ${A_CPU_TYPE_PCNT_CCNT[2]} 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 @@ -1409,11 +1411,12 @@ get_cpu_data() if [[ $B_CPUINFO == 'true' ]];then IFS=$'\n' - A_CPU_DATA=($(gawk -F': ' ' + A_CPU_DATA=( $( gawk -F': ' ' { IGNORECASE=1 } + # TAKE STRONGER NOTE: \t+ does NOT always work, MUST be [ \t]+ # TAKE NOTE: \t+ will work for $DIR_CPUINFO, but SOME ARBITRARY FILE used for TESTING might contain SPACES! # Therefore PATCH to use [ \t]+ when TESTING! - /^processor\t+:/ { nr = $NF } + /^processor[ \t]+:/ { nr = $NF } /^model name|^cpu\t+:/ { gsub(/'"$BAN_LIST_NORMAL"'/, "", $NF ) @@ -1468,10 +1471,11 @@ get_cpu_data() else { printf("%s %s\n", max, "Mhz") } - }' $DIR_CPUINFO)) + }' $DIR_CPUINFO ) ) fi IFS="$ORIGINAL_IFS" +# echo getMainCpu: ${[@]} } ## this is for counting processors and finding HT types @@ -1484,36 +1488,57 @@ 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 ' - BEGIN { FS=": "; i = 0 } {IGNORECASE = 1} - /^processor/ { num_of_processors = $NF + 1 } # counts logical processors, both HT and physical - /^cpu cores/ { num_of_cores = $NF } # counts physical cores - /^physical/ { physical_id[i] = $NF } # array of physical cpus ids - /^core id/ { core_id[i] = $NF; i++ } # array of core ids - { +# A_CPU_TYPE_PCNT_CCNT=( $( + gawk ' + BEGIN { + FS=": " + IGNORECASE = 1 + i = 0 processors = 1 cores = 1 # single cores are obviously a Uni-processor type = "UP" cpu_temp = 0 core_temp = 0 - + } + # counts logical processors, both HT and physical + /^processor/ { + num_of_processors = $NF + 1 + } + # counts physical cores + /^cpu cores/ { + num_of_cores = $NF + } + # array of physical cpus ids + /^physical/ { + physical_id[i] = $NF + } + # array of core ids + /^core id/ { + core_id[i] = $NF + i++ +# print "i: " i + } + END { # look for the largest id number, and assign it - for ( j = 0; j <= num_of_processors; j++) + for ( j = 0; j < num_of_processors; j++ ) { - if ( physical[j] > cpu_temp ) + if ( physical_id[j] > cpu_temp ) { - cpu_temp = physical[j] + cpu_temp = physical_id[j] +# print "physical_id: " physical_id[j] } if ( core_id[j] > core_temp ) { core_temp = core_id[j] +# print "core_temp: " core_id[j] } } physical_cpu_count = cpu_temp + 1 core_count = core_temp + 1 +# print "physical_cpu_count: " physical_cpu_count + # looking at logical processor counts over 1, which means either HT, SMP or MCP if ( num_of_processors > 1 ) { @@ -1549,11 +1574,12 @@ get_cpu_ht_multicore_smp_data() } } } + print type " " processors " " cores } - END { print type " " processors " " cores } - ' $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 @@ -1861,101 +1887,37 @@ get_hdd_data_basic() { local hdd_used='' -# dfdata="Filesystem 1K-blocks Used Available Use% Mounted on -# /dev/hdc7 5289348 2811800 2208864 57% / -# tmpfs 1037688 0 1037688 0% /lib/init/rw -# udev 10240 116 10124 2% /dev -# tmpfs 1037688 0 1037688 0% /dev/shm -# /dev/hdc8 8420132 4218360 3774044 53% /home -# /dev/hdc5 32981408 20955204 12026204 64% /media/hd2 -# /dev/sdb1 390700768 188926868 201773900 49% /media/Snusmumrikken -# /dev/sda1 732572000 248156936 484415064 34% /media/Mr. Big" -# # hdd_used=$( df | gawk ' - if [[ $B_TESTING_1 == 'true' ]];then - hdd_used=$( df | gawk ' - /^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/ { - # this handles the case where the first item is too long - # and makes df wrap output to next line, so here we advance - # it to the next line for that single case - if ( NF == 1 ) { - getline - } - if ( $4 ~ /.*\%/ ) { - print "b: " $1 " used: " $2 " full: " $1 - used += $2 - full += $1 - } - else if ( $5 ~ /.*\%/ ) { - print "a: " $1 " used: " $3 " full: " $2 - used += $3 - full += $2 - } - else { - next - } + hdd_used=$( df | gawk ' + /^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/ { + # this handles the case where the first item is too long + # and makes df wrap output to next line, so here we advance + # it to the next line for that single case + if ( NF == 1 ) { + getline } - END { - print "Remember, this is only for your mounted stuff in df!!" - used = used*1024/1000**3 - print "used : " used - full = full*1024/1000**3 - print "full : " full - percent = used/full - print "percent : " percent - }' ) - elif [[ $B_TESTING_2 == 'true' ]];then - hdd_used=$( df | gawk ' - p { - if (/^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/) { - if (NF == 1) { - getline - if (NF == 5) { - c += $2 - } - else { - next - } - } - else if (NF == 6) { - c += $3 - } - } + # if the first item caused a wrap, use one less than standard + # testing for the field with % in it, ie: 34%, then go down from there + # this also protects against cases where the mount point has a space in the + # file name, thus breaking going down from $NF directly. + if ( $4 ~ /.*\%/ ) { + used += $2 } - /^Filesystem/ { p++ } - END { - print c - }' ) - else - hdd_used=$( df | gawk ' - /^\/dev\/(mapper\/|[hs]d[a-z][0-9]+)/ { - # this handles the case where the first item is too long - # and makes df wrap output to next line, so here we advance - # it to the next line for that single case - if ( NF == 1 ) { - getline - } - # if the first item caused a wrap, use one less than standard - if ( $4 ~ /.*\%/ ) { - used += $2 - } - # otherwise use standard - else if ( $5 ~ /.*\%/ ) { - used += $3 - } - # and if this is not detected, give up, we need user data to debug - else { - next - } + # otherwise use standard + else if ( $5 ~ /.*\%/ ) { + used += $3 } - END { - print used - }' ) - fi + # and if this is not detected, give up, we need user data to debug + else { + next + } + } + END { + print used + }' ) if [[ -z $hdd_used ]];then hdd_used='na' fi - echo hdd_used "$hdd_used" # create the initial array strings: # disk-dev, capacity, name, usb or not