]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: 'status' admin socket command
authorSage Weil <sage@inktank.com>
Mon, 3 Mar 2014 15:03:01 +0000 (07:03 -0800)
committerSage Weil <sage@inktank.com>
Sat, 14 Jun 2014 07:59:48 +0000 (00:59 -0700)
Basic stuff, like what state is the OSD in, and what osdmap epoch are
we on.

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 09099c9e4c7d2aa31eb8a0b7c18e43272fae7ce2)

src/osd/OSD.cc
src/osd/OSD.h

index b6345e4efac552a9276725fad90dd68283d3eb3e..90e3dcc5cf6bde6b6f1b15f85acd816e4bd0eedb 100644 (file)
@@ -1022,7 +1022,19 @@ bool OSD::asok_command(string command, cmdmap_t& cmdmap, string format,
   Formatter *f = new_formatter(format);
   if (!f)
     f = new_formatter("json-pretty");
-  if (command == "dump_ops_in_flight") {
+  if (command == "status") {
+    f->open_object_section("status");
+    f->dump_stream("cluster_fsid") << superblock.cluster_fsid;
+    f->dump_stream("osd_fsid") << superblock.osd_fsid;
+    f->dump_unsigned("whoami", superblock.whoami);
+    f->dump_string("state", get_state_name(state));
+    f->dump_unsigned("oldest_map", superblock.oldest_map);
+    f->dump_unsigned("newest_map", superblock.newest_map);
+    osd_lock.Lock();
+    f->dump_unsigned("num_pgs", pg_map.size());
+    osd_lock.Unlock();
+    f->close_section();
+  } else if (command == "dump_ops_in_flight") {
     op_tracker.dump_ops_in_flight(f);
   } else if (command == "dump_historic_ops") {
     op_tracker.dump_historic_ops(f);
@@ -1276,6 +1288,9 @@ void OSD::final_init()
   int r;
   AdminSocket *admin_socket = cct->get_admin_socket();
   asok_hook = new OSDSocketHook(this);
+  r = admin_socket->register_command("status", "status", asok_hook,
+                                    "high-level status of OSD");
+  assert(r == 0);
   r = admin_socket->register_command("dump_ops_in_flight",
                                     "dump_ops_in_flight", asok_hook,
                                     "show the ops currently in flight");
@@ -1505,6 +1520,7 @@ int OSD::shutdown()
   }
 
   // unregister commands
+  cct->get_admin_socket()->unregister_command("status");
   cct->get_admin_socket()->unregister_command("dump_ops_in_flight");
   cct->get_admin_socket()->unregister_command("dump_historic_ops");
   cct->get_admin_socket()->unregister_command("dump_op_pq_state");
index 60547722fcb3e363f99dbc3f0eab072ec221a8d0..8cd4c8dd51493e5e0b225f1b98dece085ddb7e91 100644 (file)
@@ -705,6 +705,17 @@ public:
   static const int STATE_STOPPING = 4;
   static const int STATE_WAITING_FOR_HEALTHY = 5;
 
+  static const char *get_state_name(int s) {
+    switch (s) {
+    case STATE_INITIALIZING: return "initializing";
+    case STATE_BOOTING: return "booting";
+    case STATE_ACTIVE: return "active";
+    case STATE_STOPPING: return "stopping";
+    case STATE_WAITING_FOR_HEALTHY: return "waiting_for_healthy";
+    default: return "???";
+    }
+  }
+
 private:
   int state;
   epoch_t boot_epoch;  // _first_ epoch we were marked up (after this process started)