Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ceph.in: filter out audit from ceph -w #16345

Merged
merged 1 commit into from
Jul 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions PendingReleaseNotes
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,7 @@
* Certain extra fields in the 'ceph health' structured output that
used to appear if the mons were low on disk space (which duplicated
the information in the normal health warning messages) are now gone.

* The "ceph -w" output no longer contains audit log entries by default.
Add a "--watch-channel=audit" or "--watch-channel=*" to see them.

19 changes: 13 additions & 6 deletions src/ceph.in
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ def parse_cmdargs(args=None, target=''):
parser.add_argument('--watch-error', action='store_true',
help='watch error events')

parser.add_argument('--watch-channel', dest="watch_channel",
help="which log channel to follow " \
"when using -w/--watch. One of ['cluster', 'audit', '*'",
default='cluster')

parser.add_argument('--version', '-v', action="store_true", help="display version")
parser.add_argument('--verbose', action="store_true", help="make verbose")
parser.add_argument('--concise', dest='verbose', action="store_false",
Expand Down Expand Up @@ -933,14 +938,16 @@ def main():
if k.startswith('watch') and v:
if k == 'watch':
level = 'info'
else:
elif k != "watch_channel":
level = k.replace('watch_', '')
if level:

# an awfully simple callback
def watch_cb(arg, line, who, stamp_sec, stamp_nsec, seq, level, msg):
print(line)
sys.stdout.flush()
def watch_cb(arg, line, channel, name, who, stamp_sec, stamp_nsec, seq, level, msg):
# Filter on channel
if (channel == parsed_args.watch_channel or \
parsed_args.watch_channel == "*"):
print(line)
sys.stdout.flush()

# first do a ceph status
ret, outbuf, outs = json_command(cluster_handle, prefix='status')
Expand All @@ -951,7 +958,7 @@ def main():

# this instance keeps the watch connection alive, but is
# otherwise unused
run_in_thread(cluster_handle.monitor_log, level, watch_cb, 0)
run_in_thread(cluster_handle.monitor_log2, level, watch_cb, 0)

# loop forever letting watch_cb print lines
try:
Expand Down