mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Add function for getting room diagnostics
This commit is contained in:
parent
aaf391b284
commit
f624b14636
@ -41,11 +41,11 @@
|
||||
set_room_affiliation/4, get_room_affiliations/2, get_room_affiliation/3,
|
||||
web_menu_main/2, web_page_main/2, web_menu_host/3,
|
||||
subscribe_room/4, subscribe_room_many/3,
|
||||
unsubscribe_room/2, get_subscribers/2,
|
||||
get_room_serverhost/1,
|
||||
web_page_host/3,
|
||||
mod_opt_type/1, mod_options/1,
|
||||
get_commands_spec/0, find_hosts/1]).
|
||||
unsubscribe_room/2, get_subscribers/2,
|
||||
get_room_serverhost/1,
|
||||
web_page_host/3,
|
||||
mod_opt_type/1, mod_options/1,
|
||||
get_commands_spec/0, find_hosts/1, room_diagnostics/2]).
|
||||
|
||||
-include("logger.hrl").
|
||||
-include_lib("xmpp/include/xmpp.hrl").
|
||||
@ -1184,6 +1184,28 @@ get_room_pid(Name, Service) ->
|
||||
invalid_service
|
||||
end.
|
||||
|
||||
room_diagnostics(Name, Service) ->
|
||||
try get_room_serverhost(Service) of
|
||||
ServerHost ->
|
||||
RMod = gen_mod:ram_db_mod(ServerHost, mod_muc),
|
||||
case RMod:find_online_room(ServerHost, Name, Service) of
|
||||
error ->
|
||||
room_hibernated;
|
||||
{ok, Pid} ->
|
||||
case rpc:pinfo(Pid, [current_stacktrace, message_queue_len, messages]) of
|
||||
[{_, R}, {_, QL}, {_, Q}] ->
|
||||
#{stacktrace => R, queue_size => QL, queue => lists:sublist(Q, 10)};
|
||||
_ ->
|
||||
unable_to_probe_process
|
||||
end
|
||||
end
|
||||
catch
|
||||
error:{invalid_domain, _} ->
|
||||
invalid_service;
|
||||
error:{unregistered_route, _} ->
|
||||
invalid_service
|
||||
end.
|
||||
|
||||
%% It is required to put explicitly all the options because
|
||||
%% the record elements are replaced at compile time.
|
||||
%% So, this can't be parametrized.
|
||||
|
Loading…
Reference in New Issue
Block a user