elixirerlang-otpelixir-iexbeam

How can I use :observer from IEx when my remote is an embedded system?


I would like to demonstrate the use of the :observer GUI from a remote IEx shell. My target is BEAM running my Elixir app on a resource contrained embedded system.

I built the remote OS using Buildroot including support for Erlang. I added a checkout of the elixir-lang repo to give me Elixir and IEx. (Version is reported as 1.13.0-dev and I'm using Erlang/OTP 22.)

My host OS is Ubuntu and I'm using the same versions of Elixir and OTP for consistency.

I start my app on the remote machine with: iex --sname foo --cookie <cookie> -S mix run and connect to it from my host with: iex --sname bar --cookie <cookie> --remsh foo@<remote machine name>

This gives me a remote shell. However when I try entering :observer.start(), I get an error, ERROR: Could not find 'wxe_driver.so' in: /usr/lib/erlang/lib/wx-1.9/priv

The .so file actually exists at that path on my Ubuntu machine, but not on my embedded system which lacks WX widgets (and X windows and any sort of graphical output hardware). Is there any way around this? Have I done something wrong?


Solution

  • The problem is with --remsh. Using --remsh will open a remote session like you were executing IEx from that machine in a similar way of a typical SSH session.

    You need to connect to the remote node from a local IEx session using Node.connect/1 and then open the Observer :observer.start(). This will require SSH access to the remote machine (your embedded system) and the forward of two ports from that system to your localhost. The first port is from epmd - the Erlang Port Manager Daemon - and the second port is from your system's node.

    epmd names showing two ports

    This works because Observer runs a several of RPC calls to the remote machine in order to get data from that system. This way you don't need anything "graphical" installed on your embedded system.

    To know more, see http://blog.plataformatec.com.br/2016/05/tracing-and-observing-your-remote-node/