]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add perf counters to track current open/stale sessions
authorVenky Shankar <vshankar@redhat.com>
Wed, 27 Jun 2018 08:05:49 +0000 (04:05 -0400)
committerVenky Shankar <vshankar@redhat.com>
Thu, 16 Aug 2018 06:16:50 +0000 (02:16 -0400)
Signed-off-by: Venky Shankar <vshankar@redhat.com>
src/mds/SessionMap.cc
src/mds/SessionMap.h

index 756855e6992cb57239dc008fb0b6ea5751c7503b..8f324fae01356bc6951ba00da6d0afd829532c84 100644 (file)
@@ -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<Session*>).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();
 }
 
index 10e87a713e121125f104ed234ed082790e4ef145..6606cafff26c9e52cc3e48f2cffdefefce2b0d36 100644 (file)
@@ -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<entity_name_t> &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);