From: John Spray Date: Sun, 25 Jun 2017 22:50:39 +0000 (-0400) Subject: mon: filter `log last` by channel, default to `cluster` X-Git-Tag: ses5-milestone8~1^2~1^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d23452d013173fa9d68da9581bae14b41dcb624e;p=ceph.git mon: filter `log last` by channel, default to `cluster` Caller can pass "*" to get old behaviour (audit and cluster mixed together). The audit log messages are visually messy and usually not of interest to someone trying to see what their cluster is doing. Signed-off-by: John Spray --- diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index 76a725600139..50ae98cea3b1 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -426,16 +426,27 @@ bool LogMonitor::preprocess_command(MonOpRequestRef op) level = CLOG_INFO; } + std::string channel; + if (!cmd_getval(g_ceph_context, cmdmap, "channel", channel)) { + channel = CLOG_CHANNEL_DEFAULT; + } + + // We'll apply this twice, once while counting out lines + // and once while outputting them. + auto match = [level, channel](const LogEntry &entry) { + return entry.prio >= level && (entry.channel == channel || channel == "*"); + }; + auto p = summary.tail.end(); while (num > 0 && p != summary.tail.begin()) { - if (p->prio >= level) { + if (match(*p)) { num--; } --p; } ostringstream ss; for ( ; p != summary.tail.end(); ++p) { - if (p->prio < level) { + if (!match(*p)) { continue; } diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 8ab55e576e46..9328efb45289 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -199,7 +199,8 @@ COMMAND("log name=logtext,type=CephString,n=N", \ "log supplied text to the monitor log", "mon", "rw", "cli,rest") COMMAND("log last " "name=num,type=CephInt,range=1,req=false " - "name=level,type=CephChoices,strings=debug|info|sec|warn|error,req=false", \ + "name=level,type=CephChoices,strings=debug|info|sec|warn|error,req=false " + "name=channel,type=CephChoices,strings=*|cluster|audit,req=false", \ "print last few lines of the cluster log", \ "mon", "rw", "cli,rest") COMMAND_WITH_FLAG("injectargs " \