New version, new tarball, new man. Found a pesky bug with false disk used results.

It turns out I'd neglected to include /dev/disk partitions, oops, in the df data.

Since this is a long time bug, it warrants a new release even though I just did 
2.1.22.
This commit is contained in:
inxi-svn 2014-04-27 22:57:24 +00:00
parent 0232318b18
commit 1f57eae5bb
3 changed files with 33 additions and 7 deletions

16
inxi
View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash
########################################################################
#### Script Name: inxi
#### Version: 2.1.22
#### Version: 2.1.23
#### Date: 2014-04-27
#### Patch Number: 00
########################################################################
@ -5437,14 +5437,18 @@ get_hdd_data_basic()
total=0
}
( $2 == "partition" ) && ( $3 ~ /^[0-9]+$/ ) {
total = total + $3
total += ( 1000 / 1024 ) * $3
}
END {
# result in kB, change to 1024 Byte blocks
total = total * 1000 / 1024
total = sprintf( "%.1f", total )
print total
}' )
fi
# echo ss: $swap_size
hdd_data="$( eval $df_string )"
# eval $df_string | awk 'BEGIN{tot=0} !/total/ {tot+=$4} END{print tot}'
log_function_data 'raw' "hdd_data:\n$hdd_data"
hdd_used=$( echo "$hdd_data" | gawk -v bsdType=$BSD_TYPE -v bTotal=$b_total -v swapSize=$swap_size '
BEGIN {
@ -5456,6 +5460,7 @@ get_hdd_data_basic()
devSet=""
devWorking=""
mountWorking=""
used=0
}
# do this first to skip the other tests, if we have the totals, we do not need to calculate them
# note there is a risk to this because if a new fs to exclude is present but not excluded
@ -5476,7 +5481,8 @@ get_hdd_data_basic()
# also handles odd dm-1 type, from lvm, and mdraid, and some other bsd partition syntax
# note that linux 3.2.45-grsec-9th types kernels have this type of partition name: /dev/xvdc (no number, letter)
# note: btrfs does not seem to use partition integers, just the primary /dev/sdx identifier
( bTotal == "false" ) && /^\/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])[[:space:]]/ {
# df can also show /dev/disk/(by-label|by-uuid etc)
( bTotal == "false" ) && /^\/dev\/(disk\/|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
@ -5519,6 +5525,7 @@ get_hdd_data_basic()
}
END {
used=used + swapSize
used = sprintf( "%.1f", used )
print used
}' )
# echo hdu:$hdd_used
@ -5533,7 +5540,7 @@ get_hdd_data_basic()
if [[ $B_PARTITIONS_FILE == 'true' ]];then
A_HDD_DATA=( $(
gawk -v hddUsed="$hdd_used" '
gawk -v hddUsed=$hdd_used '
/[hsv]d[a-z]$/ {
driveSize = $(NF - 1)*1024/1000**3
gsub(/,/, " ", driveSize)
@ -5571,6 +5578,7 @@ get_hdd_data_basic()
fi
IFS="$ORIGINAL_IFS"
a_temp=${A_HDD_DATA[@]}
# echo ${a_temp[@]}
log_function_data "A_HDD_DATA: $a_temp"
eval $LOGFE
}

7
inxi.1
View file

@ -80,11 +80,12 @@ Shows optical drive data. Same as \fB\-Dd\fR. With \fB\-x\fR, adds features line
\fB\-xx\fR adds a few more features.
.TP
.B \-D
Show full hard Disk info, not only model, ie: \fB/dev/sda ST380817AS 80.0GB. Shows disk space
Show full hard Disk info, not only model, ie: \fB/dev/sda ST380817AS 80.0GB\fR. Shows disk space
total + used percentage. The disk used percentage includes space used by swap partition(s), since
those are not usable for data storage. Note that with RAID disks, the percentage will be wrong
since the total is computed from the disk sizes, but the used is computed from partition used
percentages. This small defect may get corrected in the future.
since the total is computed from the disk sizes, but the used is computed from mounted partition used
percentages. This small defect may get corrected in the future. Also, unmounted partitions are not
counted in disk use percentages since inxi has no access to that data.
.TP
.B \-f
Show all cpu flags used, not just the short list. Not shown with \fB\-F\fR to avoid

View file

@ -1,3 +1,20 @@
=====================================================================================
Version: 2.1.23
Patch Version: 00
Script Date: 2014-04-27
-----------------------------------
Changes:
-----------------------------------
New version, new tarball, new man. Found a pesky bug with false disk used results.
It turns out I'd neglected to include /dev/disk partitions, oops, in the df data.
Since this is a long time bug, it warrants a new release even though I just did
2.1.22.
-----------------------------------
-- Harald Hope - Sun, 27 Apr 2014 15:55:20 -0700
=====================================================================================
Version: 2.1.22
Patch Version: 00