Query only specific zone via swift-recon
Add support to query only specific zones, as well a --all shortcut flag to run all checks. Also skip deleted devices when trying to grab hosts from the ring. Change-Id: I441ec76c90857c2e74262a7a9e2d36de89b28631
This commit is contained in:
parent
296de6ed76
commit
480df2e89e
@ -18,10 +18,12 @@ VERBOSE = False
|
|||||||
SUPPRESS_ERRORS = False
|
SUPPRESS_ERRORS = False
|
||||||
|
|
||||||
|
|
||||||
def getdevices():
|
def get_devices(zone_filter, ring_file):
|
||||||
#todo , fitler by zone[s]
|
|
||||||
ring_file = "/etc/swift/object.ring.gz"
|
|
||||||
ring_data = Ring(ring_file)
|
ring_data = Ring(ring_file)
|
||||||
|
if zone_filter:
|
||||||
|
ips = set((n['ip'], n['port']) for n in ring_data.devs if n \
|
||||||
|
if n['zone'] == zone_filter)
|
||||||
|
else:
|
||||||
ips = set((n['ip'], n['port']) for n in ring_data.devs if n)
|
ips = set((n['ip'], n['port']) for n in ring_data.devs if n)
|
||||||
return ips
|
return ips
|
||||||
|
|
||||||
@ -90,11 +92,10 @@ def scout_quarantine(host):
|
|||||||
return url, content, status
|
return url, content, status
|
||||||
|
|
||||||
|
|
||||||
def get_ringmd5(ringfile):
|
def get_ringmd5(hosts, ringfile):
|
||||||
stats = {}
|
stats = {}
|
||||||
matches = 0
|
matches = 0
|
||||||
errors = 0
|
errors = 0
|
||||||
hosts = getdevices()
|
|
||||||
md5sum = md5()
|
md5sum = md5()
|
||||||
with open(ringfile, 'rb') as f:
|
with open(ringfile, 'rb') as f:
|
||||||
block = f.read(4096)
|
block = f.read(4096)
|
||||||
@ -126,10 +127,8 @@ def get_ringmd5(ringfile):
|
|||||||
print "=" * 79
|
print "=" * 79
|
||||||
|
|
||||||
|
|
||||||
def async_check():
|
def async_check(hosts):
|
||||||
ASYNC_COUNTER = 0
|
|
||||||
stats = {}
|
stats = {}
|
||||||
hosts = getdevices()
|
|
||||||
pool = eventlet.GreenPool(20)
|
pool = eventlet.GreenPool(20)
|
||||||
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
print "[%s] Checking async pendings on %s hosts..." % (now, len(hosts))
|
print "[%s] Checking async pendings on %s hosts..." % (now, len(hosts))
|
||||||
@ -148,9 +147,8 @@ def async_check():
|
|||||||
print "=" * 79
|
print "=" * 79
|
||||||
|
|
||||||
|
|
||||||
def umount_check():
|
def umount_check(hosts):
|
||||||
stats = {}
|
stats = {}
|
||||||
hosts = getdevices()
|
|
||||||
pool = eventlet.GreenPool(20)
|
pool = eventlet.GreenPool(20)
|
||||||
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
print "[%s] Getting unmounted drives from %s hosts..." % (now, len(hosts))
|
print "[%s] Getting unmounted drives from %s hosts..." % (now, len(hosts))
|
||||||
@ -163,9 +161,8 @@ def umount_check():
|
|||||||
print "=" * 79
|
print "=" * 79
|
||||||
|
|
||||||
|
|
||||||
def replication_check():
|
def replication_check(hosts):
|
||||||
stats = {}
|
stats = {}
|
||||||
hosts = getdevices()
|
|
||||||
pool = eventlet.GreenPool(20)
|
pool = eventlet.GreenPool(20)
|
||||||
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
print "[%s] Checking replication times on %s hosts..." % (now, len(hosts))
|
print "[%s] Checking replication times on %s hosts..." % (now, len(hosts))
|
||||||
@ -184,11 +181,10 @@ def replication_check():
|
|||||||
print "=" * 79
|
print "=" * 79
|
||||||
|
|
||||||
|
|
||||||
def load_check():
|
def load_check(hosts):
|
||||||
load1 = {}
|
load1 = {}
|
||||||
load5 = {}
|
load5 = {}
|
||||||
load15 = {}
|
load15 = {}
|
||||||
hosts = getdevices()
|
|
||||||
pool = eventlet.GreenPool(20)
|
pool = eventlet.GreenPool(20)
|
||||||
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
print "[%s] Checking load avg's on %s hosts..." % (now, len(hosts))
|
print "[%s] Checking load avg's on %s hosts..." % (now, len(hosts))
|
||||||
@ -211,11 +207,10 @@ def load_check():
|
|||||||
print "=" * 79
|
print "=" * 79
|
||||||
|
|
||||||
|
|
||||||
def quarantine_check():
|
def quarantine_check(hosts):
|
||||||
objq = {}
|
objq = {}
|
||||||
conq = {}
|
conq = {}
|
||||||
acctq = {}
|
acctq = {}
|
||||||
hosts = getdevices()
|
|
||||||
pool = eventlet.GreenPool(20)
|
pool = eventlet.GreenPool(20)
|
||||||
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
print "[%s] Checking quarantine dirs on %s hosts..." % (now, len(hosts))
|
print "[%s] Checking quarantine dirs on %s hosts..." % (now, len(hosts))
|
||||||
@ -238,8 +233,7 @@ def quarantine_check():
|
|||||||
print "=" * 79
|
print "=" * 79
|
||||||
|
|
||||||
|
|
||||||
def disk_usage():
|
def disk_usage(hosts):
|
||||||
hosts = getdevices()
|
|
||||||
stats = {}
|
stats = {}
|
||||||
highs = []
|
highs = []
|
||||||
lows = []
|
lows = []
|
||||||
@ -315,6 +309,10 @@ def main():
|
|||||||
help="Get cluster quarantine stats")
|
help="Get cluster quarantine stats")
|
||||||
args.add_option('--objmd5', action="store_true",
|
args.add_option('--objmd5', action="store_true",
|
||||||
help="Get md5sums of object.ring.gz and compare to local copy")
|
help="Get md5sums of object.ring.gz and compare to local copy")
|
||||||
|
args.add_option('--all', action="store_true",
|
||||||
|
help="Perform all checks. Equivelent to -arudlq --objmd5")
|
||||||
|
args.add_option('--zone', '-z', type="int",
|
||||||
|
help="Only query servers in specified zone")
|
||||||
args.add_option('--swiftdir', default="/etc/swift",
|
args.add_option('--swiftdir', default="/etc/swift",
|
||||||
help="Default = /etc/swift")
|
help="Default = /etc/swift")
|
||||||
options, arguments = args.parse_args()
|
options, arguments = args.parse_args()
|
||||||
@ -323,24 +321,41 @@ def main():
|
|||||||
args.print_help()
|
args.print_help()
|
||||||
|
|
||||||
swift_dir = options.swiftdir
|
swift_dir = options.swiftdir
|
||||||
|
obj_ring = os.path.join(swift_dir, 'object.ring.gz')
|
||||||
|
con_ring = os.path.join(swift_dir, 'container.ring.gz')
|
||||||
|
acct_ring = os.path.join(swift_dir, 'account.ring.gz')
|
||||||
|
|
||||||
VERBOSE = options.verbose
|
VERBOSE = options.verbose
|
||||||
SUPPRESS_ERRORS = options.suppress
|
SUPPRESS_ERRORS = options.suppress
|
||||||
|
|
||||||
|
if options.zone:
|
||||||
|
hosts = get_devices(options.zone, obj_ring)
|
||||||
|
else:
|
||||||
|
hosts = get_devices(None, obj_ring)
|
||||||
|
|
||||||
|
if options.all:
|
||||||
|
async_check(hosts)
|
||||||
|
umount_check(hosts)
|
||||||
|
replication_check(hosts)
|
||||||
|
load_check(hosts)
|
||||||
|
disk_usage(hosts)
|
||||||
|
get_ringmd5(hosts, obj_ring)
|
||||||
|
quarantine_check(hosts)
|
||||||
|
else:
|
||||||
if options.async:
|
if options.async:
|
||||||
async_check()
|
async_check(hosts)
|
||||||
if options.unmounted:
|
if options.unmounted:
|
||||||
umount_check()
|
umount_check(hosts)
|
||||||
if options.replication:
|
if options.replication:
|
||||||
replication_check()
|
replication_check(hosts)
|
||||||
if options.loadstats:
|
if options.loadstats:
|
||||||
load_check()
|
load_check(hosts)
|
||||||
if options.diskusage:
|
if options.diskusage:
|
||||||
disk_usage()
|
disk_usage(hosts)
|
||||||
if options.objmd5:
|
if options.objmd5:
|
||||||
get_ringmd5(os.path.join(swift_dir, 'object.ring.gz'))
|
get_ringmd5(hosts, obj_ring)
|
||||||
if options.quarantined:
|
if options.quarantined:
|
||||||
quarantine_check()
|
quarantine_check(hosts)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user