[pve-devel] [PATCH storage v2] pvesm status: improve output and its format

Thomas Lamprecht t.lamprecht at proxmox.com
Thu May 18 11:56:38 CEST 2017


Add column names at top of output, this allows easier understanding
of what each column means.

Also use a leading zero on percentages < 10% to make format a bit
nicer.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---

changes v1 -> v2:
* use active instead of ready for consistency
* add leading zeros on usage percentage
* improved commit message

 PVE/CLI/pvesm.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/PVE/CLI/pvesm.pm b/PVE/CLI/pvesm.pm
index ba2c91b..b3c9256 100755
--- a/PVE/CLI/pvesm.pm
+++ b/PVE/CLI/pvesm.pm
@@ -134,13 +134,16 @@ my $print_status = sub {
     }
     $maxlen+=1;
 
+    printf "%-${maxlen}s %10s %7s %12s %15s %15s %6s\n", 'name', 'type',
+	'active', 'total', 'available', 'used', '%';
+
     foreach my $res (sort { $a->{storage} cmp $b->{storage} } @$res) {
 	my $storeid = $res->{storage};
 
 	my $sum = $res->{used} + $res->{avail};
 	my $per = $sum ? (0.5 + ($res->{used}*100)/$sum) : 100;
 
-	printf "%-${maxlen}s %5s %1d %15d %15d %15d %.2f%%\n", $storeid,
+	printf "%-${maxlen}s %10s %4d %15d %15d %15d %05.2f%%\n", $storeid,
 	$res->{type}, $res->{active},
 	$res->{total}/1024, $res->{used}/1024, $res->{avail}/1024, $per;
     }
-- 
2.11.0





More information about the pve-devel mailing list