summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Chmielowski <pawel@process-one.net>2022-09-01 13:37:48 +0200
committerPaweł Chmielowski <pawel@process-one.net>2022-09-01 13:37:48 +0200
commitf624b146369d473332e023bfca131b689402ca42 (patch)
treeee85fdfbee46c8dbf58e1f85b83d94fc6eb7795a
parentCatch all errors from jose_jwt:verify and log debugging details (#3890) (diff)
Add function for getting room diagnostics
-rw-r--r--src/mod_muc_admin.erl32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/mod_muc_admin.erl b/src/mod_muc_admin.erl
index 9651cfe1..f29a5b56 100644
--- a/src/mod_muc_admin.erl
+++ b/src/mod_muc_admin.erl
@@ -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.