./ct_report/coverage/stats_api.COVER.html

1 -module(stats_api).
2
3 -export([incoming_s2s_number/0, outgoing_s2s_number/0, stats/1, stats/2]).
4
5 -include("mongoose.hrl").
6
7 -spec incoming_s2s_number() -> {ok, non_neg_integer()}.
8 incoming_s2s_number() ->
9
:-(
{ok, length(supervisor:which_children(ejabberd_s2s_in_sup))}.
10
11 -spec outgoing_s2s_number() -> {ok, non_neg_integer()}.
12 outgoing_s2s_number() ->
13
:-(
{ok, length(supervisor:which_children(ejabberd_s2s_out_sup))}.
14
15 -spec stats(binary()) -> {ok, integer()} | {not_found, string()}.
16 stats(<<"uptimeseconds">>) ->
17
:-(
{ok, trunc(element(1, erlang:statistics(wall_clock)) / 1000)};
18 stats(<<"registeredusers">>) ->
19
:-(
Domains = lists:flatmap(fun mongoose_domain_api:get_domains_by_host_type/1,
20 ?ALL_HOST_TYPES),
21
:-(
{ok, lists:sum([ejabberd_auth:get_vh_registered_users_number(Domain) || Domain <- Domains])};
22 stats(<<"onlineusersnode">>) ->
23
:-(
{ok, ejabberd_sm:get_node_sessions_number()};
24 stats(<<"onlineusers">>) ->
25
:-(
{ok, ejabberd_sm:get_total_sessions_number()};
26 stats(_Name) ->
27
:-(
{not_found, "Stats not found"}.
28
29 -spec stats(binary(), jid:server()) -> {ok, integer()} | {not_found, string()}.
30 stats(<<"registeredusers">>, Host) ->
31
:-(
{ok, ejabberd_auth:get_vh_registered_users_number(Host)};
32 stats(<<"onlineusers">>, Host) ->
33
:-(
{ok, ejabberd_sm:get_vh_session_number(Host)};
34 stats(_Name, _Host) ->
35
:-(
{not_found, "Stats not found"}.
Line Hits Source