25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Ignore offline sessions in statistics

Offline sessions should not be counted when reporting the number of
connected resources.

Apart from that, this number is now also reported when using a
non-default session management backend.
This commit is contained in:
Holger Weiss 2016-10-11 22:20:22 +02:00
parent d701230555
commit ead7e21037
2 changed files with 4 additions and 9 deletions

View File

@ -1552,7 +1552,7 @@ su_to_list({Server, User}) ->
%%%% get_stats
get_stats(global, Lang) ->
OnlineUsers = mnesia:table_info(session, size),
OnlineUsers = ejabberd_sm:connected_users_number(),
RegisteredUsers = lists:foldl(fun (Host, Total) ->
ejabberd_auth:get_vh_registered_users_number(Host)
+ Total
@ -2178,7 +2178,7 @@ get_node(global, Node, [<<"stats">>], _Query, Lang) ->
CPUTime = ejabberd_cluster:call(Node, erlang, statistics, [runtime]),
CPUTimeS = list_to_binary(io_lib:format("~.3f",
[element(1, CPUTime) / 1000])),
OnlineUsers = mnesia:table_info(session, size),
OnlineUsers = ejabberd_sm:connected_users_number(),
TransactionsCommitted = ejabberd_cluster:call(Node, mnesia,
system_info, [transaction_commits]),
TransactionsAborted = ejabberd_cluster:call(Node, mnesia,

View File

@ -161,13 +161,8 @@ get_local_stat(Server, [], Name)
end;
get_local_stat(_Server, [], Name)
when Name == <<"users/all-hosts/online">> ->
case catch mnesia:table_info(session, size) of
{'EXIT', _Reason} ->
?STATERR(<<"500">>, <<"Internal Server Error">>);
Users ->
?STATVAL((iolist_to_binary(integer_to_list(Users))),
<<"users">>)
end;
Users = ejabberd_sm:connected_users_number(),
?STATVAL((iolist_to_binary(integer_to_list(Users))), <<"users">>);
get_local_stat(_Server, [], Name)
when Name == <<"users/all-hosts/total">> ->
NumUsers = lists:foldl(fun (Host, Total) ->