Skip to content

Commit

Permalink
System metrics error with no static hosts configured
Browse files Browse the repository at this point in the history
  • Loading branch information
vkatsuba committed Aug 18, 2021
1 parent 51bc7f0 commit b5a2daa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/mod_smart_markers.erl
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ get_host(groupchat, SubHost, From, To) ->
can_access_room(HostType, From, To) andalso {true, HostType}
end;
get_host(one2one, Host, _, _) ->
Hosts = ejabberd_config:get_global_option(hosts),
Hosts = ejabberd_config:get_global_option_or_default(hosts, []),
case lists:member(Host, Hosts) of
false -> false;
_ -> {true, Host}
Expand Down
8 changes: 5 additions & 3 deletions src/system_metrics/mongoose_system_metrics_collector.erl
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ report_getters() ->
].

get_hosts_count() ->
Hosts = ejabberd_config:get_global_option(hosts),
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),
[#{report_name => hosts, key => count, value => NumberOfHosts}].

get_modules() ->
Hosts = ejabberd_config:get_global_option(hosts),
Hosts = ejabberd_config:get_global_option_or_default(host_types, []),
AllModules = lists:flatten([gen_mod:loaded_modules(H) || H <- Hosts]),
ModulesToReport = filter_behaviour_implementations(lists:usort(AllModules),
mongoose_module_metrics),
Expand Down Expand Up @@ -78,7 +80,7 @@ report_module_with_opts(Module, Opts) ->
end,Opts).

get_number_of_custom_modules() ->
Hosts = ejabberd_config:get_global_option(hosts),
Hosts = ejabberd_config:get_global_option_or_default(host_types, []),
AllModules = lists:flatten(
lists:map(fun gen_mod:loaded_modules/1, Hosts)),
GenMods = filter_behaviour_implementations(AllModules, gen_mod),
Expand Down

0 comments on commit b5a2daa

Please sign in to comment.