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

Thomas Lamprecht t.lamprecht at proxmox.com
Wed May 24 12:45: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:
* rename status column to active
* output status (active, inactive, disabled) in status column

 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 8af4e7f..3bc98b4 100755
--- a/PVE/CLI/pvesm.pm
+++ b/PVE/CLI/pvesm.pm
@@ -134,14 +134,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