]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: add 'cluster_log [type] [message ...]' tell command
authorSage Weil <sage@redhat.com>
Mon, 3 Nov 2014 09:24:25 +0000 (01:24 -0800)
committerSage Weil <sage@redhat.com>
Wed, 5 Nov 2014 09:06:02 +0000 (01:06 -0800)
Useful for debugging.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/LogClient.h
src/osd/OSD.cc

index 8d808239992ff7964b1c79124c25a6d36407c884..c5acfcb34b32cf118f3ee274f19cef7d3a4e687f 100644 (file)
@@ -133,10 +133,10 @@ public:
 
   typedef shared_ptr<LogChannel> Ref;
 
-private:
   void do_log(clog_type prio, std::stringstream& ss);
   void do_log(clog_type prio, const std::string& s);
 
+private:
   CephContext *cct;
   LogClient *parent;
   Mutex channel_lock;
index 322cf5c0f6b2d2fcc6e667d27f70a791a2bd2905..5747257c22893fec14a1c2dd453bff6fe37f15d5 100644 (file)
@@ -4943,6 +4943,11 @@ COMMAND("injectargs " \
        "name=injected_args,type=CephString,n=N",
        "inject configuration arguments into running OSD",
        "osd", "rw", "cli,rest")
+COMMAND("cluster_log " \
+       "name=level,type=CephChoices,strings=error,warning,info,debug " \
+       "name=message,type=CephString,n=N",
+       "log a message to the cluster log",
+       "osd", "rw", "cli,rest")
 COMMAND("bench " \
        "name=count,type=CephInt,req=false " \
        "name=size,type=CephInt,req=false ", \
@@ -5046,6 +5051,27 @@ void OSD::do_command(Connection *con, ceph_tid_t tid, vector<string>& cmd, buffe
     cct->_conf->injectargs(args, &ss);
     osd_lock.Lock();
   }
+  else if (prefix == "cluster_log") {
+    vector<string> msg;
+    cmd_getval(cct, cmdmap, "message", msg);
+    if (msg.empty()) {
+      r = -EINVAL;
+      ss << "ignoring empty log message";
+      goto out;
+    }
+    string message = msg.front();
+    for (vector<string>::iterator a = ++msg.begin(); a != msg.end(); ++a)
+      message += " " + *a;
+    string lvl;
+    cmd_getval(cct, cmdmap, "level", lvl);
+    clog_type level = string_to_clog_type(lvl);
+    if (level < 0) {
+      r = -EINVAL;
+      ss << "unknown level '" << lvl << "'";
+      goto out;
+    }
+    clog->do_log(level, message);
+  }
 
   // either 'pg <pgid> <command>' or
   // 'tell <pgid>' (which comes in without any of that prefix)?