summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorcan <lorcan.browne@hp.com>2015-03-24 13:54:00 +0000
committerJohn Dickinson <me@not.mn>2015-04-14 16:00:37 -0700
commit66fb207fcb288889d73d42960b037e3ef7ef3ce2 (patch)
tree96b832302d46a29d0bf23179d170eaefeb99a55b
parentb76d8c5156c65e3ae6ead5213e40f70d80f7fa9d (diff)
downloadswift-66fb207fcb288889d73d42960b037e3ef7ef3ce2.tar.gz
Add lowest option to swift-recon disk usage output
Currently there is a "--top" option when running swift-recon for disk usage stats. This option lists the x disks with the highest disk usage in descending order. This feature adds a "--lowest" option which does the opposite and lists the y disks with lowest disk usage in ascending order. Have also updated the docs section with --top and --lowest options Change-Id: Ic15d407fe010a31995c2bdd9fb88548a1057f569
-rw-r--r--doc/manpages/swift-recon.14
-rwxr-xr-xswift/cli/recon.py26
2 files changed, 27 insertions, 3 deletions
diff --git a/doc/manpages/swift-recon.1 b/doc/manpages/swift-recon.1
index 4311c99ad..7cafebd43 100644
--- a/doc/manpages/swift-recon.1
+++ b/doc/manpages/swift-recon.1
@@ -62,6 +62,10 @@ Get replication stats
Check cluster for unmounted devices
.IP "\fB-d, --diskusage\fR"
Get disk usage stats
+.IP "\fB--top=COUNT\fR"
+Also show the top COUNT entries in rank order
+.IP "\fB--lowest=COUNT\fR"
+Also show the lowest COUNT entries in rank order
.IP "\fB-l, --loadstats\fR"
Get cluster load average stats
.IP "\fB-q, --quarantined\fR"
diff --git a/swift/cli/recon.py b/swift/cli/recon.py
index b67e2678d..8c2042cb5 100755
--- a/swift/cli/recon.py
+++ b/swift/cli/recon.py
@@ -821,7 +821,7 @@ class SwiftRecon(object):
print("No hosts returned valid data.")
print("=" * 79)
- def disk_usage(self, hosts, top=0, human_readable=False):
+ def disk_usage(self, hosts, top=0, lowest=0, human_readable=False):
"""
Obtain and print disk usage statistics
@@ -835,6 +835,7 @@ class SwiftRecon(object):
raw_total_avail = []
percents = {}
top_percents = [(None, 0)] * top
+ low_percents = [(None, 100)] * lowest
recon = Scout("diskusage", self.verbose, self.suppress_errors,
self.timeout)
print("[%s] Checking disk usage now" % self._ptime())
@@ -858,6 +859,13 @@ class SwiftRecon(object):
top_percents.sort(key=lambda x: -x[1])
top_percents.pop()
break
+ for ident, oused in low_percents:
+ if oused > used:
+ low_percents.append(
+ (url + ' ' + entry['device'], used))
+ low_percents.sort(key=lambda x: x[1])
+ low_percents.pop()
+ break
stats[url] = hostusage
for url in stats:
@@ -903,6 +911,13 @@ class SwiftRecon(object):
url, device = ident.split()
host = urlparse(url).netloc.split(':')[0]
print('%.02f%% %s' % (used, '%-15s %s' % (host, device)))
+ if low_percents:
+ print('LOWEST %s' % lowest)
+ for ident, used in low_percents:
+ if ident:
+ url, device = ident.split()
+ host = urlparse(url).netloc.split(':')[0]
+ print('%.02f%% %s' % (used, '%-15s %s' % (host, device)))
def main(self):
"""
@@ -955,6 +970,9 @@ class SwiftRecon(object):
help="Get drive audit error stats")
args.add_option('--top', type='int', metavar='COUNT', default=0,
help='Also show the top COUNT entries in rank order.')
+ args.add_option('--lowest', type='int', metavar='COUNT', default=0,
+ help='Also show the lowest COUNT entries in rank \
+ order.')
args.add_option('--all', action="store_true",
help="Perform all checks. Equal to \t\t\t-arudlq "
"--md5 --sockstat --auditor --updater --expirer")
@@ -1010,7 +1028,8 @@ class SwiftRecon(object):
self.auditor_check(hosts)
self.umount_check(hosts)
self.load_check(hosts)
- self.disk_usage(hosts, options.top, options.human_readable)
+ self.disk_usage(hosts, options.top, options.lowest,
+ options.human_readable)
self.get_ringmd5(hosts, swift_dir)
self.quarantine_check(hosts)
self.socket_usage(hosts)
@@ -1049,7 +1068,8 @@ class SwiftRecon(object):
if options.loadstats:
self.load_check(hosts)
if options.diskusage:
- self.disk_usage(hosts, options.top, options.human_readable)
+ self.disk_usage(hosts, options.top, options.lowest,
+ options.human_readable)
if options.md5:
self.get_ringmd5(hosts, swift_dir)
self.get_swiftconfmd5(hosts)