]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add uptime to MDS status 20547/head
authorPatrick Donnelly <pdonnell@redhat.com>
Thu, 22 Feb 2018 22:11:12 +0000 (14:11 -0800)
committerPatrick Donnelly <pdonnell@redhat.com>
Thu, 22 Feb 2018 22:34:17 +0000 (14:34 -0800)
Fixes: https://tracker.ceph.com/issues/23094
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/mds/MDSDaemon.cc
src/mds/MDSDaemon.h
src/mds/MDSRank.cc
src/mds/MDSRank.h

index 305d630239910dc63467dac950211060ea4c1d90..a516a6ff25cb7dd51ac9e693232462abacb2caf0 100644 (file)
@@ -89,7 +89,8 @@ MDSDaemon::MDSDaemon(std::string_view n, Messenger *m, MonClient *mc) :
   mgrc(m->cct, m),
   log_client(m->cct, messenger, &mc->monmap, LogClient::NO_FLAGS),
   mds_rank(NULL),
-  asok_hook(NULL)
+  asok_hook(NULL),
+  starttime(mono_clock::now())
 {
   orig_argc = 0;
   orig_argv = NULL;
@@ -179,6 +180,9 @@ void MDSDaemon::dump_status(Formatter *f)
     f->dump_unsigned("osdmap_epoch", 0);
     f->dump_unsigned("osdmap_epoch_barrier", 0);
   }
+
+  f->dump_float("uptime", get_uptime().count());
+
   f->close_section(); // status
 }
 
index 4ba26d54ee9d553f8250ea609ab654b77ec344d2..8d746b547ac5f0a23cef6cccae962e1912f0dd5f 100644 (file)
@@ -47,6 +47,15 @@ class MDSDaemon : public Dispatcher, public md_config_obs_t {
 
   SafeTimer    timer;
 
+
+  mono_time get_starttime() const {
+    return starttime;
+  }
+  chrono::duration<double> get_uptime() const {
+    mono_time now = mono_clock::now();
+    return chrono::duration<double>(now-starttime);
+  }
+
  protected:
   Beacon  beacon;
 
@@ -154,6 +163,9 @@ protected:
   void handle_command(class MCommand *m);
   void handle_mds_map(class MMDSMap *m);
   void _handle_mds_map(MDSMap *oldmap);
+
+private:
+    mono_time starttime = mono_clock::zero();
 };
 
 
index 6650755e58fed93349b758694b1e8e991df9740e..82d65ba0d5e4948402cb18d6a975cc9720c35033 100644 (file)
@@ -91,7 +91,8 @@ MDSRank::MDSRank(
     messenger(msgr), monc(monc_),
     respawn_hook(respawn_hook_),
     suicide_hook(suicide_hook_),
-    standby_replaying(false)
+    standby_replaying(false),
+    starttime(mono_clock::now())
 {
   hb = g_ceph_context->get_heartbeat_map()->add_worker("MDSRank", pthread_self());
 
@@ -2534,6 +2535,7 @@ void MDSRank::dump_status(Formatter *f) const
   } else if (state == MDSMap::STATE_CLIENTREPLAY) {
     dump_clientreplay_status(f);
   }
+  f->dump_float("rank_uptime", get_uptime().count());
 }
 
 void MDSRank::dump_clientreplay_status(Formatter *f) const
index fa64d1d8b7adc63abe85c124acd2cd1d912799ab..f6c95b950355283ea40c21322f9257dbe62716ef 100644 (file)
@@ -138,6 +138,14 @@ class MDSRank {
     // a separate lock here in future potentially.
     Mutex &mds_lock;
 
+    mono_time get_starttime() const {
+      return starttime;
+    }
+    chrono::duration<double> get_uptime() const {
+      mono_time now = mono_clock::now();
+      return chrono::duration<double>(now-starttime);
+    }
+
     class CephContext *cct;
 
     bool is_daemon_stopping() const;
@@ -510,6 +518,9 @@ class MDSRank {
 
     /* Update MDSMap export_targets for this rank. Called on ::tick(). */
     void update_targets(utime_t now);
+
+private:
+    mono_time starttime = mono_clock::zero();
 };
 
 /* This expects to be given a reference which it is responsible for.