From 301fc0cefdf86c5f37358bf10b92e8c6ab193ec6 Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Fri, 18 Jul 2014 16:24:13 +0100 Subject: [PATCH] mon: Monitor: log administrative actions via admin socket Signed-off-by: Joao Eduardo Luis --- src/mon/Monitor.cc | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 68486667a0e..972f5dd4853 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -269,20 +269,36 @@ void Monitor::do_admin_command(string command, cmdmap_t& cmdmap, string format, boost::scoped_ptr f(new_formatter(format)); + string args; + for (cmdmap_t::iterator p = cmdmap.begin(); + p != cmdmap.end(); ++p) { + if (p->first == "prefix") + continue; + if (!args.empty()) + args += ", "; + args += cmd_vartype_stringify(p->second); + } + args = "[" + args + "]"; + + audit_clog->info() << "from='admin socket' " + << "entity='admin socket' " + << "cmd=" << command << " " + << "args=" << args << ": dispatch"; + if (command == "mon_status") { get_mon_status(f.get(), ss); if (f) f->flush(ss); - } else if (command == "quorum_status") + } else if (command == "quorum_status") { _quorum_status(f.get(), ss); - else if (command == "sync_force") { + } else if (command == "sync_force") { string validate; if ((!cmd_getval(g_ceph_context, cmdmap, "validate", validate)) || (validate != "--yes-i-really-mean-it")) { ss << "are you SURE? this will mean the monitor store will be erased " "the next time the monitor is restarted. pass " "'--yes-i-really-mean-it' if you really do."; - return; + goto abort; } sync_force(f.get(), ss); } else if (command.find("add_bootstrap_peer_hint") == 0) { @@ -297,8 +313,20 @@ void Monitor::do_admin_command(string command, cmdmap_t& cmdmap, string format, start_election(); elector.stop_participating(); ss << "stopped responding to quorum, initiated new election"; - } else + } else { assert(0 == "bad AdminSocket command binding"); + } + audit_clog->info() << "from='admin socket' " + << "entity='admin socket' " + << "cmd=" << command << " " + << "args=" << args << ": finished"; + return; + +abort: + audit_clog->info() << "from='admin socket' " + << "entity='admin socket' " + << "cmd=" << command << " " + << "args=" << args << ": aborted"; } void Monitor::handle_signal(int signum) -- 2.47.3