From 315aa47a07429ba0a47fbd40078f0e8fd16b9ffd Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Wed, 27 Jun 2018 04:05:49 -0400 Subject: mds: add perf counters to track current open/stale sessions Signed-off-by: Venky Shankar --- src/mds/SessionMap.cc | 12 ++++++++++++ src/mds/SessionMap.h | 7 +++++++ 2 files changed, 19 insertions(+) (limited to 'src') diff --git a/src/mds/SessionMap.cc b/src/mds/SessionMap.cc index 756855e6992..8f324fae013 100644 --- a/src/mds/SessionMap.cc +++ b/src/mds/SessionMap.cc @@ -52,6 +52,10 @@ void SessionMap::register_perfcounters() "Sessions added"); plb.add_u64_counter(l_mdssm_session_remove, "session_remove", "Sessions removed"); + plb.add_u64(l_mdssm_session_open, "sessions_open", + "Sessions currently open"); + plb.add_u64(l_mdssm_session_stale, "sessions_stale", + "Sessions currently stale"); logger = plb.create_perf_counters(); g_ceph_context->get_perfcounters_collection()->add(logger); } @@ -483,7 +487,15 @@ uint64_t SessionMap::set_state(Session *session, int s) { if (by_state_entry == by_state.end()) by_state_entry = by_state.emplace(s, new xlist).first; by_state_entry->second->push_back(&session->item_session_list); + + // refresh number of sessions for states which have perf + // couters associated + logger->set(l_mdssm_session_open, + get_session_count_in_state(Session::STATE_OPEN)); + logger->set(l_mdssm_session_stale, + get_session_count_in_state(Session::STATE_STALE)); } + return session->get_state_seq(); } diff --git a/src/mds/SessionMap.h b/src/mds/SessionMap.h index 10e87a713e1..6606cafff26 100644 --- a/src/mds/SessionMap.h +++ b/src/mds/SessionMap.h @@ -41,6 +41,8 @@ enum { l_mdssm_session_count, l_mdssm_session_add, l_mdssm_session_remove, + l_mdssm_session_open, + l_mdssm_session_stale, l_mdssm_last, }; @@ -684,6 +686,11 @@ public: */ void save_if_dirty(const std::set &tgt_sessions, MDSGatherBuilder *gather_bld); + +private: + uint64_t get_session_count_in_state(int state) { + return !is_any_state(state) ? 0 : by_state[state]->size(); + } }; std::ostream& operator<<(std::ostream &out, const Session &s); -- cgit v1.2.3