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:
parent
d701230555
commit
ead7e21037
|
@ -1552,7 +1552,7 @@ su_to_list({Server, User}) ->
|
||||||
%%%% get_stats
|
%%%% get_stats
|
||||||
|
|
||||||
get_stats(global, Lang) ->
|
get_stats(global, Lang) ->
|
||||||
OnlineUsers = mnesia:table_info(session, size),
|
OnlineUsers = ejabberd_sm:connected_users_number(),
|
||||||
RegisteredUsers = lists:foldl(fun (Host, Total) ->
|
RegisteredUsers = lists:foldl(fun (Host, Total) ->
|
||||||
ejabberd_auth:get_vh_registered_users_number(Host)
|
ejabberd_auth:get_vh_registered_users_number(Host)
|
||||||
+ Total
|
+ Total
|
||||||
|
@ -2178,7 +2178,7 @@ get_node(global, Node, [<<"stats">>], _Query, Lang) ->
|
||||||
CPUTime = ejabberd_cluster:call(Node, erlang, statistics, [runtime]),
|
CPUTime = ejabberd_cluster:call(Node, erlang, statistics, [runtime]),
|
||||||
CPUTimeS = list_to_binary(io_lib:format("~.3f",
|
CPUTimeS = list_to_binary(io_lib:format("~.3f",
|
||||||
[element(1, CPUTime) / 1000])),
|
[element(1, CPUTime) / 1000])),
|
||||||
OnlineUsers = mnesia:table_info(session, size),
|
OnlineUsers = ejabberd_sm:connected_users_number(),
|
||||||
TransactionsCommitted = ejabberd_cluster:call(Node, mnesia,
|
TransactionsCommitted = ejabberd_cluster:call(Node, mnesia,
|
||||||
system_info, [transaction_commits]),
|
system_info, [transaction_commits]),
|
||||||
TransactionsAborted = ejabberd_cluster:call(Node, mnesia,
|
TransactionsAborted = ejabberd_cluster:call(Node, mnesia,
|
||||||
|
|
|
@ -161,13 +161,8 @@ get_local_stat(Server, [], Name)
|
||||||
end;
|
end;
|
||||||
get_local_stat(_Server, [], Name)
|
get_local_stat(_Server, [], Name)
|
||||||
when Name == <<"users/all-hosts/online">> ->
|
when Name == <<"users/all-hosts/online">> ->
|
||||||
case catch mnesia:table_info(session, size) of
|
Users = ejabberd_sm:connected_users_number(),
|
||||||
{'EXIT', _Reason} ->
|
?STATVAL((iolist_to_binary(integer_to_list(Users))), <<"users">>);
|
||||||
?STATERR(<<"500">>, <<"Internal Server Error">>);
|
|
||||||
Users ->
|
|
||||||
?STATVAL((iolist_to_binary(integer_to_list(Users))),
|
|
||||||
<<"users">>)
|
|
||||||
end;
|
|
||||||
get_local_stat(_Server, [], Name)
|
get_local_stat(_Server, [], Name)
|
||||||
when Name == <<"users/all-hosts/total">> ->
|
when Name == <<"users/all-hosts/total">> ->
|
||||||
NumUsers = lists:foldl(fun (Host, Total) ->
|
NumUsers = lists:foldl(fun (Host, Total) ->
|
||||||
|
|
Loading…
Reference in New Issue