From 41087ac9a37d0071fc54a17de861274bb0cd90e8 Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Sun, 27 Apr 2014 23:51:26 +0000 Subject: [PATCH] added swpctl -l for bsd in -D, though -D doesn't work yet for bsds, but might as well. --- inxi | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/inxi b/inxi index f0697d2..257a32b 100755 --- a/inxi +++ b/inxi @@ -5424,6 +5424,22 @@ get_hdd_data_basic() df_string="df -P -T --exclude-type=aufs --exclude-type=devfs --exclude-type=devtmpfs --exclude-type=fdescfs --exclude-type=iso9660 --exclude-type=linprocfs --exclude-type=procfs --exclude-type=squashfs --exclude-type=sysfs --exclude-type=tmpfs --exclude-type=unionfs $df_total" + 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 += ( 1000 / 1024 ) * $3 + } + END { + # result in kB, change to 1024 Byte blocks + total = total * 1000 / 1024 + total = sprintf( "%.1f", total ) + print total + }' ) + fi else # default size is 512, , so use -k for 1024 -H only for size in human readable format # older bsds don't support -T, pain, so we'll use partial output there @@ -5432,23 +5448,22 @@ get_hdd_data_basic() else df_string='df -k' fi + if swapctl -l &>/dev/null;then + swap_size=$( swapctl -l 2>/dev/null | gawk ' + BEGIN { + swapSize=0 + total=0 + } + ( $1 ~ /^\/dev/ ) && ( $2 ~ /^[0-9]+$/ ) { + total += $2 + } + END { + # result in blocks already + print total + }' ) + 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 += ( 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}'