diff --git a/src/domain/mongoose_domain_core.erl b/src/domain/mongoose_domain_core.erl index 3c5cce85332..3ae77d7c298 100644 --- a/src/domain/mongoose_domain_core.erl +++ b/src/domain/mongoose_domain_core.erl @@ -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, + domains_count/0]). -export([for_each_domain/2]). @@ -94,6 +95,9 @@ get_all_static() -> get_domains_by_host_type(HostType) when is_binary(HostType) -> heads(ets:match(?TABLE, {'$1', HostType, '_'})). +domains_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), diff --git a/src/system_metrics/mongoose_system_metrics_collector.erl b/src/system_metrics/mongoose_system_metrics_collector.erl index b827121dfd4..4e0cf80a729 100644 --- a/src/system_metrics/mongoose_system_metrics_collector.erl +++ b/src/system_metrics/mongoose_system_metrics_collector.erl @@ -1,5 +1,7 @@ -module(mongoose_system_metrics_collector). +-include("mongoose.hrl"). + -type report_struct() :: #{ report_name := term(), @@ -24,6 +26,7 @@ get_reports(Fun) -> report_getters() -> [ fun get_hosts_count/0, + fun get_domains_count/0, fun get_modules/0, fun get_number_of_custom_modules/0, fun get_uptime/0, @@ -38,16 +41,20 @@ report_getters() -> ]. get_hosts_count() -> - Hosts = ejabberd_config:get_global_option(hosts), - NumberOfHosts = length(Hosts), + HostTypes = ?ALL_HOST_TYPES, + NumberOfHosts = length(HostTypes), [#{report_name => hosts, key => count, value => NumberOfHosts}]. +get_domains_count() -> + DomainsCount = mongoose_domain_core:domains_count(), + [#{report_name => domains, key => count, value => DomainsCount}]. + get_modules() -> - Hosts = ejabberd_config:get_global_option(hosts), - AllModules = lists:flatten([gen_mod:loaded_modules(H) || H <- Hosts]), + HostTypes = ?ALL_HOST_TYPES, + AllModules = lists:flatten([gen_mod:loaded_modules(H) || H <- HostTypes]), ModulesToReport = filter_behaviour_implementations(lists:usort(AllModules), mongoose_module_metrics), - ModsWithOpts = [get_modules_metrics(Host, ModulesToReport) || Host <- Hosts], + ModsWithOpts = [get_modules_metrics(Host, ModulesToReport) || Host <- HostTypes], [report_module_with_opts(Mod, Opt) || {Mod, Opt} <- lists:flatten(ModsWithOpts)]. filter_behaviour_implementations(Modules, Behaviour) -> @@ -78,9 +85,9 @@ report_module_with_opts(Module, Opts) -> end,Opts). get_number_of_custom_modules() -> - Hosts = ejabberd_config:get_global_option(hosts), + HostTypes = ?ALL_HOST_TYPES, AllModules = lists:flatten( - lists:map(fun gen_mod:loaded_modules/1, Hosts)), + lists:map(fun gen_mod:loaded_modules/1, HostTypes)), GenMods = filter_behaviour_implementations(AllModules, gen_mod), GenModsSet = sets:from_list(GenMods), MetricsModule = filter_behaviour_implementations(AllModules,