2

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

2240
  • 1,547
  • 2
  • 12
  • 30
zhihuifan
  • 1,093
  • 2
  • 16
  • 30

1 Answers1

2

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.

Mathieu Kerjouan
  • 495
  • 5
  • 13
  • thanks you! but I still have some issue. when I want to try observer, I found it is a gui program and I don't have GUI env for this purpose now. – zhihuifan Oct 31 '16 at 08:48
  • thanks you! But I still have some issue. when I want to try observer, I found it is a gui program and I don't have GUI env for this purpose now. when I want to use observerweb, I run to issue https://github.com/freecnpro/observerweb/issues/4. about the -i flag, per my understanding, if there are some erlang process and no matter if it is couchdb or couchdb -i or not couchdb at all, I think it should be able to verified with with the above tool. I am probably wrong, I raise this just because I want to refresh my knowledge. Thanks! – zhihuifan Oct 31 '16 at 09:01
  • ok, edited the answer with more information concerning profiling tool w/o GUI. Hope this will help! :) – Mathieu Kerjouan Oct 31 '16 at 09:40