From 56cbd3ac1b84ec35d1777ed9def7cdce500163fc Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sat, 18 Sep 2004 18:02:54 +0000 Subject: [PATCH] format sizes --- bindings/perl/examples/df.pl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bindings/perl/examples/df.pl b/bindings/perl/examples/df.pl index 17b35417..5e870a05 100755 --- a/bindings/perl/examples/df.pl +++ b/bindings/perl/examples/df.pl @@ -7,7 +7,7 @@ my $sigar = new Sigar; my $fslist = $sigar->file_system_list; -print "Filesytem\tSize\tUsed\tAvail\tUse%\tMounted on\tType\n"; +print "Filesystem\tSize\tUsed\tAvail\tUse%\tMounted on\tType\n"; for my $fs (@$fslist) { my $dirname = $fs->dir_name; @@ -34,11 +34,16 @@ for my $fs (@$fslist) { print $fs->dev_name . "\t" . - $total . "\t" . - $used . "\t" . - $avail . "\t" . + format_size($total) . "\t" . + format_size($used) . "\t" . + format_size($avail) . "\t" . $usePct . "\t" . $dirname . "\t" . $fs->sys_type_name . "/" . $fs->type_name . "\n"; } + +sub format_size { + my($size) = @_; + return Sigar::format_size($size * 1024); +}