Quick update to -D, now inxi uses the total partition swap space to calculate the

disk used percentage as well. Since swap space is not available as disk space, it 
makes sense to me to count it as used. -P/-p show the percent of swap used as well.
This commit is contained in:
inxi-svn 2014-04-27 21:42:30 +00:00
parent 33636dc58b
commit d1afab4736
3 changed files with 39 additions and 6 deletions

21
inxi
View file

@ -2622,7 +2622,7 @@ show_options()
print_lines_basic "2" "99" "Global - Overrides/removes all settings. Setting specific removes global." print_lines_basic "2" "99" "Global - Overrides/removes all settings. Setting specific removes global."
print_lines_basic "1" "-C" "CPU output, including per CPU clockspeed (if available)." print_lines_basic "1" "-C" "CPU output, including per CPU clockspeed (if available)."
print_lines_basic "1" "-d" "Optical drive data. Same as -Dd. See also -x and -xx." print_lines_basic "1" "-d" "Optical drive data. Same as -Dd. See also -x and -xx."
print_lines_basic "1" "-D" "Full hard Disk info, not only model, ie: /dev/sda ST380817AS 80.0GB. See also -x and -xx." print_lines_basic "1" "-D" "Full hard Disk info, not only model, ie: /dev/sda ST380817AS 80.0GB. See also -x and -xx. Disk total used percentage includes the swap partitions."
print_lines_basic "1" "-f" "All cpu flags, triggers -C. Not shown with -F to avoid spamming. ARM cpus show 'features'." print_lines_basic "1" "-f" "All cpu flags, triggers -C. Not shown with -F to avoid spamming. ARM cpus show 'features'."
print_lines_basic "1" "-F" "Full output for $SCRIPT_NAME. Includes all Upper Case line letters, plus -s and -n. Does not show extra verbose options like -x -d -f -u -l -o -p -t -r" print_lines_basic "1" "-F" "Full output for $SCRIPT_NAME. Includes all Upper Case line letters, plus -s and -n. Does not show extra verbose options like -x -d -f -u -l -o -p -t -r"
print_lines_basic "1" "-G" "Graphic card information (card, display server type/version, resolution, glx renderer, version)." print_lines_basic "1" "-G" "Graphic card information (card, display server type/version, resolution, glx renderer, version)."
@ -5407,7 +5407,7 @@ get_hdd_data_basic()
{ {
eval $LOGFS eval $LOGFS
local hdd_used='' a_temp='' df_string='' df_total='' local hdd_used='' a_temp='' df_string='' df_total=''
local hdd_data='' df_test='' b_total='false' local hdd_data='' df_test='' b_total='false' swap_size=0
if [[ -z $BSD_TYPE ]];then if [[ -z $BSD_TYPE ]];then
## NOTE: older df do not have --total (eg: v: 6.10 2008) ## NOTE: older df do not have --total (eg: v: 6.10 2008)
@ -5430,9 +5430,23 @@ get_hdd_data_basic()
df_string='df -k' df_string='df -k'
fi fi
fi fi
if swapon -s &>/dev/null;then
swap_size=$( swapon -s 2>/dev/null | gawk '
BEGIN {
swapSize=0
total=0
}
( $2 == "partition" ) && ( $3 ~ /^[0-9]+$/ ) {
total = total + $3
}
END {
print total
}' )
fi
# echo ss: $swap_size
hdd_data="$( eval $df_string )" hdd_data="$( eval $df_string )"
log_function_data 'raw' "hdd_data:\n$hdd_data" log_function_data 'raw' "hdd_data:\n$hdd_data"
hdd_used=$( echo "$hdd_data" | gawk -v bsdType=$BSD_TYPE -v bTotal=$b_total ' hdd_used=$( echo "$hdd_data" | gawk -v bsdType=$BSD_TYPE -v bTotal=$b_total -v swapSize=$swap_size '
BEGIN { BEGIN {
# this is used for specific cases where bind, or incorrect multiple mounts to same partitions, # 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 # is present. The value is searched for an earlier appearance of that partition and if it is
@ -5504,6 +5518,7 @@ get_hdd_data_basic()
} }
} }
END { END {
used=used + swapSize
print used print used
}' ) }' )
# echo hdu:$hdd_used # echo hdu:$hdd_used

8
inxi.1
View file

@ -1,4 +1,4 @@
.TH INXI 1 "2014\-04\-14" inxi "inxi manual" .TH INXI 1 "2014\-04\-27" inxi "inxi manual"
.SH NAME .SH NAME
inxi \- Command line system information script for console and IRC inxi \- Command line system information script for console and IRC
.SH SYNOPSIS .SH SYNOPSIS
@ -80,7 +80,11 @@ Shows optical drive data. Same as \fB\-Dd\fR. With \fB\-x\fR, adds features line
\fB\-xx\fR adds a few more features. \fB\-xx\fR adds a few more features.
.TP .TP
.B \-D .B \-D
Show full hard Disk info, not only model, ie: \fB/dev/sda ST380817AS 80.0GB. Show full hard Disk info, not only model, ie: \fB/dev/sda ST380817AS 80.0GB. Shows disk space
total + used percentage. Also, the disk used percentage includes the swap partitions, 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.
.TP .TP
.B \-f .B \-f
Show all cpu flags used, not just the short list. Not shown with \fB\-F\fR to avoid Show all cpu flags used, not just the short list. Not shown with \fB\-F\fR to avoid

View file

@ -1,3 +1,17 @@
=====================================================================================
Version: 2.1.22
Patch Version: 00
Script Date: 2014-04-27
-----------------------------------
Changes:
-----------------------------------
Quick update to -D, now inxi uses the total partition swap space to calculate the
disk used percentage as well. Since swap space is not available as disk space, it
makes sense to me to count it as used. -P/-p show the percent of swap used as well.
-----------------------------------
-- Harald Hope - Sun, 27 Apr 2014 14:41:06 -0700
===================================================================================== =====================================================================================
Version: 2.1.22 Version: 2.1.22
Patch Version: 00 Patch Version: 00