diff options
Diffstat (limited to 'swift/cli/recon.py')
-rwxr-xr-x | swift/cli/recon.py | 26 |
1 files changed, 23 insertions, 3 deletions
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) |