SNMP Agent Implementation in Elixir

We are developing a simple application in Elixir and Phoenix Framework. This is a hardware-based application and we have done with all stuff. Now we have to write SNMP Agent software in our application, so the clients SNMP Manager can read data from our device.

We are looking for libraries or any help materials. I just found 3 things on google:

  1. https://github.com/jonnystorm/mib-2-elixir
  2. https://gitlab.com/jonnystorm/snmp-elixir
  3. https://github.com/jonnystorm/net-snmp-elixir

The problem is the bad documentation that is not suitable for beginners like me.

We need help to deploy SNMP Agent in our application. This is our focus task.

Why not use Erlang’s library directly?

1 Like

C and PHP Development background. How we use erlang, have no idea.

Elixir and Erlang both run on the same virtual machine (BEAM), and it’s possible to call Erlang functions from Elixir.

For example, here’s the syntax for calling the date/0 (0-argument function, date) in the erlang module.

iex(1)> :erlang.date()
{2019, 5, 23}

Similarly, to run Erlang’s interactive SNMP configuration generator, config/0 in the snmp module you’d type:

iex(2)> :snmp.config()

Simple SNMP configuration tool (version 5.2.11)
------------------------------------------------
Note: Non-trivial configurations still has to be
      done manually. IP addresses may be entered 
      as dront.ericsson.se (UNIX only) or
      123.12.13.23
------------------------------------------------

Configure an agent (y/n)? [y]

Erlang ships with a lot of SNMP-related modules and functions, so looking through the docs I linked and tinkering around in iex should give you a sense whether it supports what you need.

7 Likes

Usage of Erlang modules is pretty simple: :module_name.function_name(arguments) as this is exactly how all functions are called (Elixir’s Foo.Bar module is in reality alias for :'Elixir.Foo.Bar' atom). There are few differences how to write some things in Elixir and Erlang, but this is not part of this discussion. So in the end the usage is almost the same.

About SNMP there is more detailed guide about using it.

5 Likes