Erlang中的pstack等效项

xytpbqjk  于 2022-12-08  发布在  Erlang
关注(0)|答案(1)|浏览(91)

When a Erlang system hangs I want to know what the system is doing during that time. For a c/c++ program, I can easily run the pstack, but I didn't find out a handy tool for this purpose in Erlang.

  1. What is the pstack equivalent in Erlang?
  2. Actually I want to check the running stack trace of the following process.
"/opt/couchbase/lib/erlang/erts-5.10.4.0.0.1/bin/beam.smp -P 327680 -K true -- -root /opt/couchbase/lib/erlang -progname erl --... "

and I started a new Erlang shell and start the webtool and check the appmon however I can't find the above application. What may cause this?
Thanks

0yycz8jy

0yycz8jy1#

Concerning pstack equivalent, have you read Erlang Profiling from official guide? It gives you lot of example on how to profile your application and find where your code stuck.
Another useful tools is observer it will show all working process, CPU usage, process stack and lot of more information.
If you don't see anything with these tools, you can try with Erlang debugger .
Now concerning couchbase, if your application is currently running, you can connect to it with Erlang shell and launch previous quoted commands and applications.
I don't know if you are using couchbase alone or with couchdb, but, if you want to use observer or other tools from command line, you can start couchdb with -i flag:

# -i use the interactive Erlang shell
couchdb -i

In case of your application run remotely without GUI, you can use etop , its a CLI alternative to observer . You can also dump etop output to file if you don't want to run it directly from your Erlang shell. IHMO, if you want more information concerning I/O or debug, use eprof , fprof and other profiling tools with dump file (see also eep profiling tool, easy to use).
Another alternative, if you are using SSH and want to see observer window, you can use X11Forwarding with ssh: ssh -X $yourserver or ssh -Y $yourserver and simply run observer:start(). in your Erlang shell.

相关问题