summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Gilligan <gilligan@vyatta.com>2010-04-30 17:49:31 -0700
committerBob Gilligan <gilligan@vyatta.com>2010-04-30 17:49:31 -0700
commitf78be567aa747f501ad55f0037ef843801d3dd93 (patch)
tree9b2668b09a727f42bed57c5057b63bfcd779963f
parent72b54ee266b56b918c2c06e680db4e204428e6d5 (diff)
downloadvyatta-op-f78be567aa747f501ad55f0037ef843801d3dd93.tar.gz
vyatta-op-f78be567aa747f501ad55f0037ef843801d3dd93.zip
Add "show system image storage" op mode command.
As the name indicates, it tells you how much disk space each image occupies.
-rw-r--r--Makefile.am1
-rw-r--r--scripts/show-image-storage.pl66
-rw-r--r--templates/show/system/image/storage/node.def3
3 files changed, 70 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 0fda3f8..25e343c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,6 +24,7 @@ bin_SCRIPTS += scripts/vyatta-boot-image.pl
bin_SCRIPTS += scripts/vyatta-sudo
bin_SCRIPTS += scripts/vyatta-show-snmp.pl
bin_SCRIPTS += scripts/rename-image.pl
+bin_SCRIPTS += scripts/show-image-storage.pl
bin_sudo_users_SCRIPTS = scripts/vyatta-identify-interface.pl
bin_sudo_users_SCRIPTS += scripts/vyatta-delete-log-file.sh
diff --git a/scripts/show-image-storage.pl b/scripts/show-image-storage.pl
new file mode 100644
index 0000000..00a5112
--- /dev/null
+++ b/scripts/show-image-storage.pl
@@ -0,0 +1,66 @@
+#!/usr/bin/perl
+
+# **** License ****
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# This code was originally developed by Vyatta, Inc.
+# Portions created by Vyatta are Copyright (C) 2010 Vyatta, Inc.
+# All Rights Reserved.
+#
+# Author: Bob Gilligan
+# Date: April 30, 2010
+# Description: Script to display disk storage used by images
+#
+# **** End License ****
+
+use strict;
+use warnings;
+use Getopt::Long;
+
+
+#
+# Main section
+#
+
+# Figure out where the images live...
+my $imagedir = "/live/image/boot";
+if (! -e $imagedir) {
+ # Must be running on Old non-image system.
+ $imagedir = "/boot";
+ if (! -e $imagedir) {
+ printf("Can't locate system image directory!\n");
+ exit 1;
+ }
+}
+
+my $bootlist=`/opt/vyatta/bin/vyatta-boot-image.pl --list`;
+
+my @bootlist_arr = split(/\n/, $bootlist);
+
+printf("Image name Read-Only Read-Write Total\n");
+printf("------------------------------ ------------ ------------ ------------\n");
+
+foreach my $image (@bootlist_arr) {
+ my $total;
+ my $read_only;
+ my $read_write;
+ my $string;
+ my $garbage;
+
+ if ( -e "$imagedir/$image") {
+ $string = `du -s $imagedir/$image`;
+ ($total, $garbage) = split(' ', $string);
+ $string = `du -s $imagedir/$image/*.squashfs`;
+ ($read_only, $garbage) = split(' ', $string);
+ $read_write = $total - $read_only;
+ printf("%-30s %12d %12d %12d\n", $image, $read_only, $read_write,
+ $total);
+ }
+}
diff --git a/templates/show/system/image/storage/node.def b/templates/show/system/image/storage/node.def
new file mode 100644
index 0000000..0592adc
--- /dev/null
+++ b/templates/show/system/image/storage/node.def
@@ -0,0 +1,3 @@
+help: Show disk space utilization of system images
+
+run: /opt/vyatta/bin/show-image-storage.pl