mirror of
https://github.com/jiangcuo/pve-storage.git
synced 2025-08-28 10:47:48 +00:00
pvesm status: improve output and its format
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). Show N/A if storage is disabled. Use $res->{total} instead of calculating a sum of used and available. Remove wrong rounding - if we want to display 2 digits from the fractional part we would need to add 0.005 not 0.5, this made the result quite wrong depending on the storage size. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
44ae567c38
commit
d40e27deb2
@ -135,15 +135,25 @@ my $print_status = sub {
|
||||
}
|
||||
$maxlen+=1;
|
||||
|
||||
printf "%-${maxlen}s %10s %10s %15s %15s %15s %8s\n", 'Name', 'Type',
|
||||
'Status', 'Total', 'Used', 'Available', '%';
|
||||
|
||||
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';
|
||||
my ($per, $per_fmt) = (0, '% 7.2f%%');
|
||||
$per = ($res->{used}*100)/$res->{total} if $res->{total} > 0;
|
||||
|
||||
printf "%-${maxlen}s %5s %1d %15d %15d %15d %.2f%%\n", $storeid,
|
||||
$res->{type}, $res->{active},
|
||||
$res->{total}/1024, $res->{used}/1024, $res->{avail}/1024, $per;
|
||||
if (!$res->{enabled}) {
|
||||
$per = 'N/A ';
|
||||
$per_fmt = '% 8s';
|
||||
$active = 'disabled';
|
||||
}
|
||||
|
||||
printf "%-${maxlen}s %10s %10s %15d %15d %15d $per_fmt\n", $storeid,
|
||||
$res->{type}, $active, $res->{total}/1024, $res->{used}/1024,
|
||||
$res->{avail}/1024, $per;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user