[pve-devel] [PATCH storage v3 2/2] pvesm status: improve output and its format

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Jun 27 13:42:57 CEST 2017


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

Use leading spaces on the percentage column so that this is lined up.

Switch out the 1/0 from the active column with the actual status
(active, inactive, disabled).

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

changes v2 -> v3:
* capitalize header titles

 PVE/CLI/pvesm.pm | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/PVE/CLI/pvesm.pm b/PVE/CLI/pvesm.pm
index 9adc8ba..5dfbf94 100755
--- a/PVE/CLI/pvesm.pm
+++ b/PVE/CLI/pvesm.pm
@@ -135,14 +135,19 @@ my $print_status = sub {
     }
     $maxlen+=1;
 
+    printf "%-${maxlen}s %10s %10s %15s %15s %15s %8s\n", 'name', 'type',
+	'Status', '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;
+	my $active = $res->{active} ? 'active' : 'inactive';
+	$active = 'disabled' if !$res->{enabled};
 
-	printf "%-${maxlen}s %5s %1d %15d %15d %15d %.2f%%\n", $storeid,
-	$res->{type}, $res->{active},
+	printf "%-${maxlen}s %10s %10s %15d %15d %15d % 7.2f%%\n", $storeid,
+	$res->{type}, $active,
 	$res->{total}/1024, $res->{used}/1024, $res->{avail}/1024, $per;
     }
 };
-- 
2.11.0





More information about the pve-devel mailing list