282
308
print "[%s] - No hosts returned valid data." % k
284
310
print "[%s] - No hosts returned valid data." % k
311
if least_recent_url is not None:
312
host = urlparse(url).netloc
313
if not least_recent_time:
314
print 'Oldest completion was NEVER by %s.' % host
316
elapsed = time.time() - least_recent_time
317
elapsed, elapsed_unit = seconds2timeunit(elapsed)
318
print 'Oldest completion was %s (%d %s ago) by %s.' % (
319
time.strftime('%Y-%m-%d %H:%M:%S',
320
time.gmtime(least_recent_time)),
321
elapsed, elapsed_unit, host)
322
if most_recent_url is not None:
323
host = urlparse(url).netloc
324
elapsed = time.time() - most_recent_time
325
elapsed, elapsed_unit = seconds2timeunit(elapsed)
326
print 'Most recent completion was %s (%d %s ago) by %s.' % (
327
time.strftime('%Y-%m-%d %H:%M:%S',
328
time.gmtime(most_recent_time)),
329
elapsed, elapsed_unit, host)
287
332
def object_replication_check(self, hosts):
295
340
recon = Scout("replication", self.verbose, self.suppress_errors,
297
342
print "[%s] Checking on replication" % self._ptime()
343
least_recent_time = 9999999999
344
least_recent_url = None
346
most_recent_url = None
298
347
for url, response, status in self.pool.imap(recon.scout, hosts):
299
348
if status == 200:
300
349
stats[url] = response['object_replication_time']
350
last = response.get('object_replication_last', 0)
351
if last < least_recent_time:
352
least_recent_time = last
353
least_recent_url = url
354
if last > most_recent_time:
355
most_recent_time = last
356
most_recent_url = url
301
357
times = [x for x in stats.values() if x is not None]
302
358
if len(stats) > 0 and len(times) > 0:
303
359
computed = self._gen_stats(times, 'replication_time')
307
363
print "[replication_time] - No hosts returned valid data."
309
365
print "[replication_time] - No hosts returned valid data."
366
if least_recent_url is not None:
367
host = urlparse(url).netloc
368
if not least_recent_time:
369
print 'Oldest completion was NEVER by %s.' % host
371
elapsed = time.time() - least_recent_time
372
elapsed, elapsed_unit = seconds2timeunit(elapsed)
373
print 'Oldest completion was %s (%d %s ago) by %s.' % (
374
time.strftime('%Y-%m-%d %H:%M:%S',
375
time.gmtime(least_recent_time)),
376
elapsed, elapsed_unit, host)
377
if most_recent_url is not None:
378
host = urlparse(url).netloc
379
elapsed = time.time() - most_recent_time
380
elapsed, elapsed_unit = seconds2timeunit(elapsed)
381
print 'Most recent completion was %s (%d %s ago) by %s.' % (
382
time.strftime('%Y-%m-%d %H:%M:%S',
383
time.gmtime(most_recent_time)),
384
elapsed, elapsed_unit, host)
312
387
def updater_check(self, hosts):
615
705
args = optparse.OptionParser(usage)
616
706
args.add_option('--verbose', '-v', action="store_true",
617
help="Print verbose info")
707
help="Print verbose info")
618
708
args.add_option('--suppress', action="store_true",
619
help="Suppress most connection related errors")
709
help="Suppress most connection related errors")
620
710
args.add_option('--async', '-a', action="store_true",
621
help="Get async stats")
711
help="Get async stats")
622
712
args.add_option('--replication', '-r', action="store_true",
623
help="Get replication stats")
713
help="Get replication stats")
624
714
args.add_option('--auditor', action="store_true",
625
help="Get auditor stats")
715
help="Get auditor stats")
626
716
args.add_option('--updater', action="store_true",
627
help="Get updater stats")
717
help="Get updater stats")
628
718
args.add_option('--expirer', action="store_true",
629
help="Get expirer stats")
719
help="Get expirer stats")
630
720
args.add_option('--unmounted', '-u', action="store_true",
631
help="Check cluster for unmounted devices")
721
help="Check cluster for unmounted devices")
632
722
args.add_option('--diskusage', '-d', action="store_true",
633
help="Get disk usage stats")
723
help="Get disk usage stats")
634
724
args.add_option('--loadstats', '-l', action="store_true",
635
help="Get cluster load average stats")
725
help="Get cluster load average stats")
636
726
args.add_option('--quarantined', '-q', action="store_true",
637
help="Get cluster quarantine stats")
727
help="Get cluster quarantine stats")
638
728
args.add_option('--md5', action="store_true",
639
help="Get md5sum of servers ring and compare to local copy")
729
help="Get md5sum of servers ring and compare to "
640
731
args.add_option('--sockstat', action="store_true",
641
help="Get cluster socket usage stats")
732
help="Get cluster socket usage stats")
733
args.add_option('--top', type='int', metavar='COUNT', default=0,
734
help='Also show the top COUNT entries in rank order.')
642
735
args.add_option('--all', action="store_true",
643
help="Perform all checks. Equal to -arudlq --md5 --sockstat")
736
help="Perform all checks. Equal to -arudlq --md5 "
644
738
args.add_option('--zone', '-z', type="int",
645
help="Only query servers in specified zone")
739
help="Only query servers in specified zone")
646
740
args.add_option('--timeout', '-t', type="int", metavar="SECONDS",
647
help="Time to wait for a response from a server", default=5)
741
help="Time to wait for a response from a server",
648
743
args.add_option('--swiftdir', default="/etc/swift",
649
help="Default = /etc/swift")
744
help="Default = /etc/swift")
650
745
options, arguments = args.parse_args()
652
747
if len(sys.argv) <= 1 or len(arguments) > 1: