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 19, 2021
1 parent e5609db commit 907b90d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 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,
get_all_domains/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, '_'})).

get_all_domains() ->
heads(ets:match(?TABLE, {'$1', '$2', '_'})).

-spec for_each_domain(host_type(), fun((host_type(), domain())-> any())) -> ok.
for_each_domain(HostType, Func) ->
ets:safe_fixtable(?TABLE, true),
Expand Down
4 changes: 1 addition & 3 deletions src/system_metrics/mongoose_system_metrics_collector.erl
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ 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,
Hosts = ejabberd_config:get_global_option_or_default(hosts, []) ++ mongoose_domain_core:get_all_domains(),
NumberOfHosts = length(Hosts),
[#{report_name => hosts, key => count, value => NumberOfHosts}].

Expand Down

0 comments on commit 907b90d

Please sign in to comment.