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

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

index 8d3e650248434e517bfcc2948830eeacd74b0a66..c4e91bdaeb5ee13ab8374e0b1568b1591a27aa93 100644 (file)
@@ -988,7 +988,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);
@@ -1273,6 +1285,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");
@@ -1565,6 +1580,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 29244cb5ead200174ca7f5d5577e23fd28a9a754..b371fb23aea3e48d77caea7bd894502af5d45c81 100644 (file)
@@ -907,6 +907,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)