]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add uptime to MDS status 20626/head
authorPatrick Donnelly <pdonnell@redhat.com>
Thu, 22 Feb 2018 22:11:12 +0000 (14:11 -0800)
committerPrashant D <pdhange@redhat.com>
Wed, 28 Feb 2018 03:31:11 +0000 (22:31 -0500)
Fixes: https://tracker.ceph.com/issues/23094
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
(cherry picked from commit 2498f0a81dc992d04efcb7baf6b739ec435c1b98)

Conflicts:
src/common/ceph_time.h: Added func mono_clock::zero

src/common/ceph_time.h
src/mds/MDSDaemon.cc
src/mds/MDSDaemon.h
src/mds/MDSRank.cc
src/mds/MDSRank.h

index 8479a0d5494c62beb7c9caa88ce4fafd7fd7a22b..d3d5dfa362e857b976eed8b34439d92d1bd5d8b8 100644 (file)
@@ -240,6 +240,10 @@ namespace ceph {
        return time_point(seconds(ts.tv_sec) + nanoseconds(ts.tv_nsec));
       }
 
+      static time_point zero() {
+        return time_point::min();
+      }
+
       // A monotonic clock's timepoints are only meaningful to the
       // computer on which they were generated. Thus having an
       // optional skew is meaningless.
index 6fe1e2488de022d807ee561ca7b1680d7e9cd0e4..5a6df7809a81bf4c37eb88bb2b818ee97d5b0a37 100644 (file)
@@ -90,7 +90,8 @@ MDSDaemon::MDSDaemon(const std::string &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;
@@ -180,6 +181,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 0e3bbaf26398f9e7d6ff197e961fee3da8acbe88..dda35e1bc631ca18d7100825e678e4c5e71432fd 100644 (file)
@@ -45,6 +45,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;
 
@@ -152,6 +161,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 5b7c9744ec51e1cc36e24eed8e008aa9b1eaa2fc..5db31eedb93a5235a4b7e8a5d8a10360196f62ce 100644 (file)
@@ -89,7 +89,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());
 
@@ -2510,6 +2511,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 170bb6ed5a5a5e354274792217897d396c5fc103..cacf893a8484d037d954bd04475648407fba3e56 100644 (file)
@@ -136,6 +136,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;
@@ -506,6 +514,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.