Skip to content

Commit

Permalink
mds: add uptime to MDS status
Browse files Browse the repository at this point in the history
Fixes: https://tracker.ceph.com/issues/23094

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
(cherry picked from commit 2498f0a)

Conflicts:
	src/common/ceph_time.h: Added func mono_clock::zero
  • Loading branch information
batrick authored and Prashant D committed Feb 28, 2018
1 parent ba2e120 commit 512b1d9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/common/ceph_time.h
Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion src/mds/MDSDaemon.cc
Expand Up @@ -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;
Expand Down Expand Up @@ -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
}

Expand Down
12 changes: 12 additions & 0 deletions src/mds/MDSDaemon.h
Expand Up @@ -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;

Expand Down Expand Up @@ -152,6 +161,9 @@ class MDSDaemon : public Dispatcher, public md_config_obs_t {
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();
};


Expand Down
4 changes: 3 additions & 1 deletion src/mds/MDSRank.cc
Expand Up @@ -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());

Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/mds/MDSRank.h
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 512b1d9

Please sign in to comment.