Running the report browser (rb) for SASL error rep

2019-04-12 02:44发布

Folks we are now delploying a lot of Erlang instances and we are seeing bugs been thrown and would like to examine them...

Normally we connect to the running instance with a remote shell and get access to an Erlang console that way, but this doesn't work for rb or error messages...

How do I get remote access to my SASL error messages without dropping the server, starting it non-detached and looking at the shell?

3条回答
小情绪 Triste *
2楼-- · 2019-04-12 03:07

I ran into this back in R11B and ended up creating a clone of rb that works over a remote shell (http://github.com/archaelus/erms/blob/master/src/erms_rb.erl). The trick is to discover the group_leader of the caller and then send output there.

I should probably tidy that up and submit it as a patch to rb.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-04-12 03:19

I haven't used rb, so I don't know much about it, but maybe this will help you anyway:

You can set SASLs error report handler to write to disk, see http://www.erlang.org/doc/man/sasl_app.html :

sasl_error_logger = Value <optional>

Value is one of:

...

{file,FileName}

Installs sasl_report_file_h in the error logger. This makes all reports go to the file FileName. FileName is a string.

...

I also dimly remember there being a way to install a custom handler callback, but I can't seem to find it right now, unfortunately.

查看更多
▲ chillily
4楼-- · 2019-04-12 03:26

I start my remote shell via -remsh (${ROOTDIR}/bin/erl -name shell@${NODE_IP} -remsh ${NODE_NAME}). once there I set the rb_server group_leader to the current group_leader of the shell and rb henceforth prints its output to the active shell:

(cacherl@192.168.2.31)1> rb:start().
{ok,<0.213.0>}
(cacherl@192.168.2.31)2> group_leader(group_leader(),erlang:whereis(rb_server)).
true
(cacherl@192.168.2.31)3> rb:show(1).

PROGRESS REPORT  <0.77.0>                                   2011-01-28 17:49:23
===============================================================================
supervisor                                                     {local,sasl_sup}
started
         [{pid,<4543.96.0>},
         {name,rb_server},
         {mfargs,{rb,start_link,[[]]}},
         {restart_type,temporary},
         {shutdown,brutal_kill},
         {child_type,worker}]

ok
(cacherl@192.168.2.31)4> 

EDIT: encapsulate it in a function for convenience:

%% @doc Start the report browser and reset its group-leader. 
%% For use in a remote shell
start_remote_rb() ->
    {ok, Pid} = rb:start(),
    true = erlang:group_leader(erlang:group_leader(), Pid),
    ok.

regards, Tom

查看更多
登录 后发表回答