Getting current users number for a specific cluster node.

I have a cluster running multiple nodes on different machines and would like to create different graphs showing the current number of users connected per machine.

Running ejabberdctl connected_users_number on any of the machines returns the sum of connected users to all cluster nodes.

Is it possible to get the number of users currently connected only to specific specific machine/node?

Thanks!

You can apply this patch to

You can apply this patch to ejabberd:

--- a/src/ejabberd_sm.erl
+++ b/src/ejabberd_sm.erl
@@ -50,6 +50,7 @@
         force_update_presence/1,
         connected_users/0,
         connected_users_number/0,
+        connected_users_number_mine/0,
         user_resources/2,
         get_session_pid/3,
         get_user_info/3,
@@ -745,6 +746,12 @@ commands() ->
                       module = ?MODULE, function = connected_users_number,
                       args = [],
                       result = {num_sessions, integer}},
+     #ejabberd_commands{name = connected_users_number_mine,
+                      tags = [session, stats],
+                      desc = "Get the number of established sessions in this node",
+                      module = ?MODULE, function = connected_users_number_mine,
+                      args = [],
+                      result = {num_sessions, integer}},
      #ejabberd_commands{name = user_resources,
                       tags = [session],
                       desc = "List user's connected resources",
@@ -761,6 +768,9 @@ connected_users() ->
 connected_users_number() ->
     length(dirty_get_sessions_list()).

+connected_users_number_mine() ->
+    length(dirty_get_my_sessions_list()).
+
 user_resources(User, Server) ->
     Resources =  get_user_resources(User, Server),
     lists:sort(Resources).

and then you can run:

$ ejabberdctl connected_users_number_mine
1
Syndicate content