From 7cc4628ab43c6800f36352a07e659deb57eb8e7a Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Fri, 14 Jun 2013 23:08:38 +0000 Subject: [PATCH] New version, new tarball. Some subtle bug fixes, a kvm virtual machine uses disk id in /proc/partitions of 253, which made the disk totals fail to show up at all. Added that in. Moved sourcing of configuration files to right after initialize_data so that some variables can be forced to different values before the next set of system/app checks. This is to allow specifically turning off, for some headless servers where $DISPLAY is not null due to a bash configuration bug, these: B_SHOW_X_DATA='false' B_RUNNING_IN_X='false' Setting those two to false in inxi.conf will turn off all the X checks etc even if the $DISPLAY is set to non null. Added in support for ksplice kernel version, requires installed uptrack-uname, if that is present and if uptrack-name kernel version is different from uname then it will add (ksplice) to kernel version string, and use ksplice kernel version. Also created a single function get_kernel_version for use by short form/long form inxi output. For intel xeon cpus, trying a work around for a bug in /proc/cpuinfo which fails to show core_id or physical_id for cpus, using siblings / 2 for xeons with no actual core counts. Fixed a bug that made fixes for multimounted partitions fail for disk used. Added in support for also excluding single partitions mounted to different places. --- inxi | 135 +++++++++++++++++++++++++++++++++++-------------- inxi.changelog | 35 +++++++++++++ 2 files changed, 132 insertions(+), 38 deletions(-) diff --git a/inxi b/inxi index a02473f..6b1362a 100755 --- a/inxi +++ b/inxi @@ -1,8 +1,8 @@ #!/usr/bin/env bash ######################################################################## #### Script Name: inxi -#### Version: 1.9.7 -#### Date: May 30 2013 +#### Version: 1.9.8 +#### Date: June 14 2013 #### Patch Number: 00 ######################################################################## #### SPECIAL THANKS @@ -591,6 +591,16 @@ main() # This function just initializes variables initialize_data + + # Source global config overrides, needs to be here because some things + # can be reset that were set in initialize, but check_required_apps needs + if [[ -s /etc/$SCRIPT_NAME.conf ]];then + source /etc/$SCRIPT_NAME.conf + fi + # Source user config variables override /etc/inxi.conf variables + if [[ -s $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf ]];then + source $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf + fi # Check for dependencies BEFORE running ANYTHING else except above functions # Not all distro's have these depends installed by default. Don't want to run @@ -604,14 +614,7 @@ main() SCRIPT_VERSION_NUMBER=$( parse_version_data 'main' ) SCRIPT_PATCH_NUMBER=$( parse_version_data 'patch' ) - ### Source global config overrides - if [[ -s /etc/$SCRIPT_NAME.conf ]];then - source /etc/$SCRIPT_NAME.conf - fi - # Source user config variables override /etc/inxi.conf variables - if [[ -s $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf ]];then - source $HOME/.$SCRIPT_NAME/$SCRIPT_NAME.conf - fi + # previous source location, check for bugs ## this needs to run before the KONVI stuff is set below ## Konversation 1.2 apparently does not like the $PPID test in get_start_client @@ -679,7 +682,7 @@ main() color_scheme=$VIRT_TERM_COLOR_SCHEME fi else - if [[ -n $IRC_X_TERM_COLOR_SCHEME && $B_CONSOLE_IRC == 'true' && -n $DISPLAY ]];then + if [[ -n $IRC_X_TERM_COLOR_SCHEME && $B_CONSOLE_IRC == 'true' && -n $B_RUNNING_IN_X ]];then color_scheme=$IRC_X_TERM_COLOR_SCHEME elif [[ -n $IRC_CONS_COLOR_SCHEME && -z $DISPLAY ]];then color_scheme=$IRC_CONS_COLOR_SCHEME @@ -1625,7 +1628,8 @@ debug_data_collector() ls -l /dev/disk/by-path &> $debug_data_dir/dev-disk-path-data.txt ls -l /dev/mapper &> $debug_data_dir/dev-disk-mapper-data.txt readlink /dev/root &> $debug_data_dir/dev-root.txt - df -h -T -P --exclude-type=aufs --exclude-type=squashfs --exclude-type=unionfs --exclude-type=devtmpfs --exclude-type=tmpfs --exclude-type=iso9660 --exclude-type=devfs --exclude-type=linprocfs --exclude-type=sysfs --exclude-type=fdescfs &> $debug_data_dir/df-h-T-excludes.txt + df -h -T -P --exclude-type=aufs --exclude-type=squashfs --exclude-type=unionfs --exclude-type=devtmpfs --exclude-type=tmpfs --exclude-type=iso9660 --exclude-type=devfs --exclude-type=linprocfs --exclude-type=sysfs --exclude-type=fdescfs &> $debug_data_dir/df-h-T-P-excludes.txt + df -T -P --exclude-type=aufs --exclude-type=squashfs --exclude-type=unionfs --exclude-type=devtmpfs --exclude-type=tmpfs --exclude-type=iso9660 --exclude-type=devfs --exclude-type=linprocfs --exclude-type=sysfs --exclude-type=fdescfs &> $debug_data_dir/df-T-P-excludes.txt df -H -T &> $debug_data_dir/bsd-df-H-T-no-excludes.txt df -H &> $debug_data_dir/bsd-df-H-no-excludes.txt # bsd tool @@ -3587,7 +3591,8 @@ get_cpu_ht_multicore_smp_data() eval $LOGFS # in /proc/cpuinfo local temp_array='' - + + # note: known bug with xeon intel, they show core_id/physical_id as 0 for ht 4 core if [[ $B_CPUINFO_FILE == 'true' ]]; then A_CPU_TYPE_PCNT_CCNT=( $( gawk ' @@ -3607,8 +3612,22 @@ get_cpu_ht_multicore_smp_data() count = 0 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 == "" ) { + gsub(/[^0-9]/,"",$NF) + if ( $NF != "" ) { + siblings = $NF + } } # array of logical processors, both HT and physical + /^processor/ { gsub(/,/, " ", $NF) gsub(/^ +| +$/, "", $NF) @@ -3661,18 +3680,22 @@ get_cpu_ht_multicore_smp_data() for ( i in cpu_id ) { cpuHolder[cpu_id[i]] = 1 } - for ( i in cpuHolder ) { + for ( i in cpuHolder ) { num_of_cpus++ } - i = 0 + i = 0 ## count unique cores ## for ( i in core_id ) { coreHolder[core_id[i]] = 1 } - for ( i in coreHolder ) { + for ( i in coreHolder ) { 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 ) { + num_of_cores = siblings/2 + } # final check, override the num of cores value if it clearly is wrong # and use the raw core count and synthesize the total instead of real count if ( ( num_of_cores == 1 ) && ( cpu_core_count * num_of_cpus > 1 ) ) { @@ -3685,25 +3708,24 @@ 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 ) - { + if ( num_of_processors > 1 || ( bXeon == "true" && siblings != "" ) ) { # non-multicore HT - if ( num_of_processors == (num_of_cores * 2)) - { + if ( num_of_processors == (num_of_cores * 2) ) { type = type "HT-" } + else if ( bXeon == "true" && siblings != "" && siblings > 1 ) { + type = type "HT-" # num_of_processors num_of_cores num_of_cpus + } # non-HT multi-core or HT multi-core - if (( num_of_processors == num_of_cores) || - ( num_of_cpus < num_of_cores)) - { + if (( num_of_processors == num_of_cores) || ( num_of_cpus < num_of_cores)) { type = type "MCP-" } # >1 cpu sockets active - if ( num_of_cpus > 1 ) - { + if ( num_of_cpus > 1 ) { type = type "SMP-" } - } else { + } + else { type = type "UP-" } @@ -4968,43 +4990,59 @@ get_hdd_data_basic() hdd_data="$( eval $df_string )" log_function_data 'raw' "hdd_data:\n$hdd_data" - hdd_used=$( echo "$hdd_data" | gawk -v bsdType=$BSD_TYPE ' + hdd_used=$( echo "$hdd_data" | gawk -v bsdType=$BSD_TYPE ' BEGIN { # this is used for specific cases where bind, or incorrect multiple mounts to same partitions, # is present. The value is searched for an earlier appearance of that partition and if it is # present, the data is not added into the partition used size. partitionsSet="" + # this handles a case where the same dev item is mounted twice to different points + devSet="" + devWorking="" + mountWorking="" } # using $1, not $2, because older bsd df do not have -T, filesystem type - ( bsdType != "" ) && $1 ~ /^(aufs|devfs|devtmpfs|fdescfs|iso9660|linprocfs|procfs|squashfs|sysfs|tmpfs|type|unionfs)$/ { + ( bsdType != "" ) && $1 ~ /^(aufs|devfs|devtmpfs|fdescfs|filesystem|iso9660|linprocfs|procfs|squashfs|sysfs|tmpfs|type|unionfs)$/ { # note use next, not getline or it does not work right next } # also handles odd dm-1 type, from lvm, and mdraid, and some other bsd partition syntax - /^\/dev\/(mapper\/|[hsv]d[a-z][0-9]+|dm[-]?[0-9]+|ada[0-9]+p[0-9]+.*|md[0-9]+|[aw]d[0-9]+s.*)/ { + # note that linux 3.2.45-grsec-9th types kernels have this type of partition name: /dev/xvdc (no number, letter) + /^\/dev\/(mapper\/|[hsv]d[a-z][0-9]+|dm[-]?[0-9]+|ada[0-9]+p[0-9]+.*|md[0-9]+|[aw]d[0-9]+s.*|xvd[a-z])/ { # 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. Using df -P should # make this unneeded but leave it in just in case if ( NF < 6 && $0 !~ /.*%/ ) { + devSet = devSet "~" $1 "~" getline } # 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. + # some bsds will also have only 6 items if ( $5 ~ /.*%/ ) { - if ( partitionsSet !~ /.*~$6~.*/ ) { + devWorking="~" $1 "~" + mountWorking="~" $6 "~" + if ( partitionsSet !~ mountWorking && devSet !~ devWorking ) { used += $3 } - partitionsSet = partitionsSet "~" $6 "~" + partitionsSet = partitionsSet mountWorking + # make sure to only include bsd real lines here, ie, short df output + if ( $1 ~ /^\/dev\// ) { + devSet = devSet devWorking + } } # otherwise use standard else if ( $6 ~ /.*%/ ) { - if ( partitionsSet !~ /.*~$7~.*/ ) { + devWorking="~" $1 "~" + mountWorking="~" $7 "~" + if ( partitionsSet !~ mountWorking && devSet !~ devWorking ) { used += $4 } - partitionsSet = partitionsSet "~" $7 "~" + partitionsSet = partitionsSet mountWorking + devSet = devSet devWorking } # and if this is not detected, give up, we need user data to debug else { @@ -5038,8 +5076,8 @@ get_hdd_data_basic() # size += $3 # } # special case from this data: 8 0 156290904 sda - # note: vm has 252 known starter - $1 ~ /^(3|8|22|33|252)$/ && $NF ~ /[hsv]d[a-z]$/ && ( $2 % 16 == 0 || $2 % 16 == 8 ) { + # note: vm has 252/253 known starter, grsec has 202 + $1 ~ /^(3|8|22|33|202|252|253)$/ && $NF ~ /[hsv]d[a-z]$/ && ( $2 % 16 == 0 || $2 % 16 == 8 ) { size += $3 } @@ -5258,6 +5296,27 @@ get_hdd_temp_data() eval $LOGFE } +get_kernel_version() +{ + eval $LOGFS + + local kernel_version='' ksplice_kernel_version='' + + kernel_version=$( uname -rm ) + + if [[ -n $( type -p uptrack-uname ) && -n $kernel_version ]];then + ksplice_kernel_version=$( uptrack-uname -rm ) + if [[ $kernel_version != $ksplice_kernel_version ]];then + kernel_version="$ksplice_kernel_version (ksplice)" + fi + fi + log_function_data "kernel_version: $kernel_version - ksplice_kernel_version: $ksplice_kernel_version" + + echo $kernel_version + + eval $LOGFE +} + # args: $1 - v/n get_lspci_data() { @@ -6230,7 +6289,7 @@ get_partition_data() } # next set devBase if it didn not get set above here - ( $1 ~ /^\/dev\/|:\/|\/\// ) && ( devBase == "" ) { + ( devBase == "" ) && ( $1 ~ /^\/dev\/|:\/|\/\// ) { devBase=gensub( /^(\/dev\/)(.+)$/, "\\2", 1, $1 ) } # this handles zfs type devices/partitions, which do not start with / but contain / @@ -8445,7 +8504,7 @@ print_it_out() print_short_data() { eval $LOGFS - local current_kernel=$( uname -rm ) # | gawk '{print $1,$3,$(NF-1)}' ) + local current_kernel=$( get_kernel_version ) local processes=$(( $( wc -l <<< "$Ps_aux_Data" ) - 1 )) local short_data='' i='' b_background_black='false' local memory=$( get_memory_data ) @@ -10546,7 +10605,7 @@ print_system_data() local system_data='' bits='' desktop_environment='' dm_data='' de_extra_data='' local host_kernel_string='' de_distro_string='' host_string='' desktop_type='Desktop' local host_name=$HOSTNAME - local current_kernel=$( uname -rm ) # | gawk '{print $1,$3,$(NF-1)}' ) + local current_kernel=$( get_kernel_version ) local distro="$( get_distro_data )" local tty_session='' diff --git a/inxi.changelog b/inxi.changelog index 1a06890..9465010 100755 --- a/inxi.changelog +++ b/inxi.changelog @@ -1,3 +1,38 @@ +===================================================================================== +Version: 1.9.8 +Patch Version: 00 +Script Date: June 14 2013 +----------------------------------- +Changes: +----------------------------------- +New version, new tarball. Some subtle bug fixes, a kvm virtual machine uses disk id in +/proc/partitions of 253, which made the disk totals fail to show up at all. Added that in. + +Moved sourcing of configuration files to right after initialize_data so that some variables +can be forced to different values before the next set of system/app checks. + +This is to allow specifically turning off, for some headless servers where $DISPLAY is not +null due to a bash configuration bug, these: +B_SHOW_X_DATA='false' +B_RUNNING_IN_X='false' + +Setting those two to false in inxi.conf will turn off all the X checks etc even if the $DISPLAY +is set to non null. + +Added in support for ksplice kernel version, requires installed uptrack-uname, if that is +present and if uptrack-name kernel version is different from uname then it will add (ksplice) +to kernel version string, and use ksplice kernel version. Also created a single function +get_kernel_version for use by short form/long form inxi output. + +For intel xeon cpus, trying a work around for a bug in /proc/cpuinfo which fails to show core_id +or physical_id for cpus, using siblings / 2 for xeons with no actual core counts. + +Fixed a bug that made fixes for multimounted partitions fail for disk used. Added in support +for also excluding single partitions mounted to different places. + +----------------------------------- +-- Harald Hope - Fri, 14 Jun 2013 12:36:57 -0700 + ===================================================================================== Version: 1.9.7 Patch Version: 00