summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-06-14 12:35:46 -0700
committerSage Weil <sage@inktank.com>2013-06-14 12:35:46 -0700
commitb1293ee834abd75d600d984e5a7b35424ffd8161 (patch)
treed3a88729141177a2a41c2337f23eb67ad48178ce
parent82ff72f827b9bd7f91d30a09d35e42b25d2a7344 (diff)
downloadceph-b1293ee834abd75d600d984e5a7b35424ffd8161.tar.gz
ceph: flush stderr, stdout for sane output; add prefix
Aie. e.g., ceph tell mon.* injectargs '--debug-ms 1' mon.a: injectargs:debug_ms=1/1 mon.b: injectargs:debug_ms=1/1 mon.c: injectargs:debug_ms=1/1 or osd.0: debug_ms=1/1 osd.1: debug_ms=1/1 osd.2: Problem getting command descriptions from ('osd', '2'), ENXIO osd.3: Problem getting command descriptions from ('osd', '3'), ENXIO osd.4: Problem getting command descriptions from ('osd', '4'), ENXIO osd.5: Problem getting command descriptions from ('osd', '5'), ENXIO Signed-off-by: Sage Weil <sage@inktank.com> Reviewed-by: Dan Mick <dan.mick@inktank.com>
-rwxr-xr-xsrc/ceph.in27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/ceph.in b/src/ceph.in
index 9089faec93c..4fc5ab3eed7 100755
--- a/src/ceph.in
+++ b/src/ceph.in
@@ -1562,12 +1562,19 @@ def main():
final_ret = 0
for target in targets:
+ # prettify? prefix output with target, if there was a wildcard used
+ prefix = ''
+ suffix = ''
+ if not parsed_args.output_file and len(targets) > 1:
+ prefix='{0}.{1}:'.format(*target)
+ suffix='\n'
+
ret, outbuf, outs = json_command(target=target,
prefix='get_command_descriptions')
if ret == -errno.EINVAL:
# send command to old monitor or OSD
if verbose:
- print '{0} to old {1}'.format(' '.join(childargs), target[0])
+ print prefix, '{0} to old {1}'.format(' '.join(childargs), target[0])
ret, outbuf, outs = send_command(target, childargs, inbuf)
# combine nonerror outbuf and outs; either may have cmd output
if ret == 0:
@@ -1577,7 +1584,7 @@ def main():
elif ret:
if ret < 0:
ret = -ret
- print >> sys.stderr, \
+ print >> sys.stderr, prefix, \
'Problem getting command descriptions from {0}, {1}'.\
format(target, errno.errorcode[ret])
else:
@@ -1591,9 +1598,7 @@ def main():
if ret < 0:
ret = -ret
- if len(targets) > 1:
- sys.stderr.write('{0}.{1}: '.format(*target))
- print >> sys.stderr, 'Error {0}: {1}'.format(errno.errorcode[ret], outs)
+ print >> sys.stderr, prefix, 'Error {0}: {1}'.format(errno.errorcode[ret], outs)
if len(targets) > 1:
final_ret = ret
else:
@@ -1601,7 +1606,7 @@ def main():
# this assumes outs never has useful command output, only status
if outs:
- print >> sys.stderr, outs
+ print >> sys.stderr, prefix, outs
if (parsed_args.output_file):
outf.write(outbuf)
@@ -1614,11 +1619,13 @@ def main():
parsed_args.output_format.startswith('json'):
sys.stdout.write('\n');
- # prefix output with target, if there was a wildcard used
- if len(targets) > 1:
- sys.stdout.write('{0}.{1}: '.format(*target))
+ # if we are prettifying things, normalize newlines. sigh.
+ if suffix != '':
+ outbuf = outbuf.rstrip()
+ if outbuf != '':
+ sys.stdout.write(prefix + outbuf + suffix)
- sys.stdout.write(outbuf)
+ sys.stdout.flush()
if (parsed_args.output_file):
outf.close()