From: Xinze Chi Date: Tue, 24 Mar 2015 04:50:52 +0000 (+0800) Subject: ceph.in: add ceph ping mon.* for ping all monitor X-Git-Tag: v9.0.0~35^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c3c609095e994cae9bad9a0438a78969b652ce97;p=ceph.git ceph.in: add ceph ping mon.* for ping all monitor Signed-off-by: Xinze Chi --- diff --git a/src/ceph.in b/src/ceph.in index e56ff85dd018..69dadd398e9b 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -466,14 +466,20 @@ def complete(sigdict, args, target): ### # ping a monitor ### -def ping_monitor(cluster_handle, name): +def ping_monitor(cluster_handle, name, timeout): if 'mon.' not in name: print >> sys.stderr, '"ping" expects a monitor to ping; try "ping mon."' return 1 mon_id = name[len('mon.'):] - s = cluster_handle.ping_monitor(mon_id) - print s + if (mon_id == '*') : + cluster_handle.connect(timeout=timeout) + for m in monids() : + s = cluster_handle.ping_monitor(m) + print "mon.{0}".format(m) + '\n' + s + else : + s = cluster_handle.ping_monitor(mon_id) + print s return 0 ### @@ -639,7 +645,7 @@ def main(): try: if childargs and childargs[0] == 'ping': - return ping_monitor(cluster_handle, childargs[1]) + return ping_monitor(cluster_handle, childargs[1], timeout) cluster_handle.connect(timeout=timeout) except KeyboardInterrupt: print >> sys.stderr, 'Cluster connection aborted' diff --git a/src/ceph.in.cmake b/src/ceph.in.cmake index 295450e6ab7a..805393e75a8c 100755 --- a/src/ceph.in.cmake +++ b/src/ceph.in.cmake @@ -479,14 +479,20 @@ def complete(sigdict, args, target): ### # ping a monitor ### -def ping_monitor(cluster_handle, name): +def ping_monitor(cluster_handle, name, timeout): if 'mon.' not in name: print >> sys.stderr, '"ping" expects a monitor to ping; try "ping mon."' return 1 mon_id = name[len('mon.'):] - s = cluster_handle.ping_monitor(mon_id) - print s + if (mon_id == '*') : + cluster_handle.connect(timeout=timeout) + for m in monids() : + s = cluster_handle.ping_monitor(m) + print "mon.{0}".format(m) + '\n' + s + else : + s = cluster_handle.ping_monitor(mon_id) + print s return 0 ### @@ -624,7 +630,7 @@ def main(): try: if childargs and childargs[0] == 'ping': - return ping_monitor(cluster_handle, childargs[1]) + return ping_monitor(cluster_handle, childargs[1], timeout) cluster_handle.connect(timeout=timeout) except KeyboardInterrupt: print >> sys.stderr, 'Cluster connection aborted'