summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Gilligan <gilligan@vyatta.com>2011-08-17 16:18:30 -0700
committerBob Gilligan <gilligan@vyatta.com>2011-08-17 16:18:30 -0700
commitc14272a4429f21dc30a561393d2716dd0b9b5dbc (patch)
treec4b1e4d993ff206f8abc371abcf36403cc31a4af
parenta1573b1751e46c05a3192207f2cfecef1e1c2065 (diff)
downloadvyatta-op-c14272a4429f21dc30a561393d2716dd0b9b5dbc.tar.gz
vyatta-op-c14272a4429f21dc30a561393d2716dd0b9b5dbc.zip
Bugfix 6392: Improve display of numeric values for storage usage.
-rw-r--r--scripts/show-image-storage.pl25
1 files changed, 21 insertions, 4 deletions
diff --git a/scripts/show-image-storage.pl b/scripts/show-image-storage.pl
index 00a5112..80294a5 100644
--- a/scripts/show-image-storage.pl
+++ b/scripts/show-image-storage.pl
@@ -25,6 +25,16 @@ use warnings;
use Getopt::Long;
+sub better_units {
+ my $units = shift;
+
+ $units =~ s/K/ KB/;
+ $units =~ s/M/ MB/;
+ $units =~ s/G/ GB/;
+ $units =~ s/T/ TB/;
+ return $units;
+}
+
#
# Main section
#
@@ -55,12 +65,19 @@ foreach my $image (@bootlist_arr) {
my $garbage;
if ( -e "$imagedir/$image") {
- $string = `du -s $imagedir/$image`;
+ $string = `du -s -h $imagedir/$image`;
($total, $garbage) = split(' ', $string);
- $string = `du -s $imagedir/$image/*.squashfs`;
+ $total = better_units($total);
+
+ $string = `du -s -h $imagedir/$image --exclude live-rw`;
($read_only, $garbage) = split(' ', $string);
- $read_write = $total - $read_only;
- printf("%-30s %12d %12d %12d\n", $image, $read_only, $read_write,
+ $read_only = better_units($read_only);
+
+ $string = `du -s -h $imagedir/$image/live-rw`;
+ ($read_write, $garbage) = split(' ', $string);
+ $read_write = better_units($read_write);
+
+ printf("%-30s %12s %12s %12s\n", $image, $read_only, $read_write,
$total);
}
}