Skip to content

Commit

Permalink
mongoose_domain_core:get_all_domains/0
Browse files Browse the repository at this point in the history
  • Loading branch information
vkatsuba committed Aug 20, 2021
1 parent e5609db commit 85b291b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/domain/mongoose_domain_core.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

-export([get_all_static/0,
get_all_outdated/1,
get_domains_by_host_type/1]).
get_domains_by_host_type/1,
domain_count/0]).

-export([for_each_domain/2]).

Expand Down Expand Up @@ -94,6 +95,9 @@ get_all_static() ->
get_domains_by_host_type(HostType) when is_binary(HostType) ->
heads(ets:match(?TABLE, {'$1', HostType, '_'})).

domain_count() ->
ets:info(?TABLE, size).

-spec for_each_domain(host_type(), fun((host_type(), domain())-> any())) -> ok.
for_each_domain(HostType, Func) ->
ets:safe_fixtable(?TABLE, true),
Expand Down
6 changes: 2 additions & 4 deletions src/system_metrics/mongoose_system_metrics_collector.erl
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ report_getters() ->
].

get_hosts_count() ->
HostTypes = ejabberd_config:get_global_option_or_default(host_types, []),
Domains = lists:flatten([mongoose_domain_core:get_domains_by_host_type(HT) || HT <- HostTypes]),
Hosts = ejabberd_config:get_global_option_or_default(hosts, []) ++ Domains,
NumberOfHosts = length(Hosts),
Hosts = ejabberd_config:get_global_option_or_default(hosts, []),
NumberOfHosts = length(Hosts) + mongoose_domain_core:domain_count(),
[#{report_name => hosts, key => count, value => NumberOfHosts}].

get_modules() ->
Expand Down

0 comments on commit 85b291b

Please sign in to comment.