summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/ceph.in15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/ceph.in b/src/ceph.in
index 075ec80c20b..668e639cf4c 100755
--- a/src/ceph.in
+++ b/src/ceph.in
@@ -158,6 +158,7 @@ def parse_cmdargs(args=None, target=''):
parser.add_argument('-f', '--format', choices=['json', 'json-pretty',
'xml', 'xml-pretty', 'plain'], dest='output_format')
+ parser.add_argument('--ping', action='store_true', help='ping a monitor')
# returns a Namespace with the parsed args, and a list of all extras
parsed_args, extras = parser.parse_known_args(args)
@@ -578,7 +579,19 @@ def main():
return 1
try:
- cluster_handle.connect()
+ if parsed_args.ping:
+ (r,s) = cluster_handle.ping_monitor()
+ if r == 0:
+ print s
+ return 0
+ elif r == -errno.ETIMEDOUT:
+ print >> sys.stderr, 'Timed out attempting to connect to monitor'
+ return 1
+ else:
+ print >> sys.stderr, 'Error connecting to monitor: {0}'.format(r)
+ return 1
+ else:
+ cluster_handle.connect()
except KeyboardInterrupt:
print >> sys.stderr, 'Cluster connection aborted'
return 1