[pve-devel] [PATCH container] fix #5414: use proper percentages in `pct df`

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Apr 25 09:40:13 CEST 2024


while some people write percentages as 0.XX , putting a % next to that is just
confusing. also, combined with the format modifier this would be rather lossy,
and also not match regular `df` output..

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 src/PVE/CLI/pct.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/CLI/pct.pm b/src/PVE/CLI/pct.pm
index c48321d..4504b54 100755
--- a/src/PVE/CLI/pct.pm
+++ b/src/PVE/CLI/pct.pm
@@ -433,7 +433,7 @@ __PACKAGE__->register_method({
 		    my $used = $format->($df->{used});
 		    my $avail = $format->($df->{avail});
 
-		    my $pc = sprintf('%.1f', $df->{used}/$df->{total});
+		    my $pc = sprintf('%.1f', 100 * $df->{used} / $df->{total});
 
 		    my $entry = [ $name, $mp->{volume}, $total, $used, $avail, $pc, $path ];
 		    push @list, $entry;
-- 
2.39.2





More information about the pve-devel mailing list