snmp_ex v0.3.1 SNMP

An SNMP client library for Elixir.

Link to this section Summary

Functions

Returns a keyword list containing the given SNMP credentials.

Converts oid to dot-delimited string.

Called when an application is started.

Converts dot-delimited oid string to list.

Link to this section Types

Link to this type

asn1_type()

asn1_type() :: atom() | binary()
Link to this type

asn1_value()

asn1_value() :: any()
Link to this type

credential()

credential() :: map()
Link to this type

mib_name()

mib_name() :: String.t()
Link to this type

object_id()

object_id() :: object_name() | [non_neg_integer(), ...]
Link to this type

object_name()

object_name() :: binary()
Link to this type

req_options()

req_options() :: Keyword.t()
Link to this type

req_params()

req_params() :: %{
  uri: URI.t(),
  credential: credential(),
  varbinds: [req_varbind(), ...]
}
Link to this type

req_varbind()

req_varbind() ::
  %{oid: object_id()}
  | %{oid: object_id(), type: asn1_type()}
  | %{oid: object_id(), type: asn1_type(), value: asn1_value()}
Link to this type

request_result()

request_result() :: {:ok, varbind()} | {:error, any()}
Link to this type

snmp_credential()

Link to this type

varbind()

varbind() :: %{oid: object_id(), type: asn1_type(), value: asn1_value()}

Link to this section Functions

Link to this function

credential(map)

Returns a keyword list containing the given SNMP credentials.

Example

iex> SNMP.credential(%{community: "public"})
%SNMP.CommunityCredential{community: 'public'}

iex> SNMP.credential(
...>   %{version: :v2, community: "public"}
...> )
%SNMP.CommunityCredential{
  version: :v2,
  sec_model: :v2c,
  community: 'public',
}

iex> SNMP.credential(%{sec_name: "user"})
%SNMP.USMCredential{sec_name: 'user'}

iex> SNMP.credential(
...>   %{sec_name: "user",
...>     auth: :sha,
...>     auth_pass: "authpass",
...>   }
...> )
%SNMP.USMCredential{
  sec_name: 'user',
  sec_level: :authNoPriv,
  auth: :usmHMACSHAAuthProtocol,
  auth_pass: 'authpass',
}

iex> SNMP.credential(
...>   %{sec_name: "user",
...>     auth: :sha,
...>     auth_pass: "authpass",
...>     priv: :aes,
...>     priv_pass: "privpass",
...>   }
...> )
%SNMP.USMCredential{
  sec_name: 'user',
  sec_level: :authPriv,
  auth: :usmHMACSHAAuthProtocol,
  auth_pass: 'authpass',
  priv: :usmAesCfb128Protocol,
  priv_pass: 'privpass',
}
Link to this function

list_oid_to_string(oid)

list_oid_to_string([non_neg_integer()]) :: String.t() | no_return()

Converts oid to dot-delimited string.

Example

iex> SNMP.list_oid_to_string([1,3,6,1,2,1,1,5,0])
"1.3.6.1.2.1.1.5.0"
Link to this function

load_mib(mib_name)

load_mib(mib_name()) :: :ok | {:error, term()}
Link to this function

load_mib!(mib_name)

load_mib!(mib_name()) :: :ok | no_return()
Link to this function

request(map, options \\ [])

request(req_params(), req_options()) :: [request_result(), ...]
Link to this function

resolve_object_name_to_oid(oid)

Link to this function

start(type, args)

Called when an application is started.

This function is called when an application is started using Application.start/2 (and functions on top of that, such as Application.ensure_started/2). This function should start the top-level process of the application (which should be the top supervisor of the application's supervision tree if the application follows the OTP design principles around supervision).

start_type defines how the application is started:

  • :normal - used if the startup is a normal startup or if the application is distributed and is started on the current node because of a failover from another node and the application specification key :start_phases is :undefined.
  • {:takeover, node} - used if the application is distributed and is started on the current node because of a failover on the node node.
  • {:failover, node} - used if the application is distributed and is started on the current node because of a failover on node node, and the application specification key :start_phases is not :undefined.

start_args are the arguments passed to the application in the :mod specification key (e.g., mod: {MyApp, [:my_args]}).

This function should either return {:ok, pid} or {:ok, pid, state} if startup is successful. pid should be the PID of the top supervisor. state can be an arbitrary term, and if omitted will default to []; if the application is later stopped, state is passed to the stop/1 callback (see the documentation for the c:stop/1 callback for more information).

use Application provides no default implementation for the start/2 callback.

Callback implementation for Application.start/2.

Link to this function

string_oid_to_list(oid)

string_oid_to_list(String.t()) :: [non_neg_integer()] | no_return()

Converts dot-delimited oid string to list.

Example

iex> SNMP.string_oid_to_list("1.3.6.1.2.1.1.5.0")
[1,3,6,1,2,1,1,5,0]
Link to this function

walk(object, uri, credential, options \\ [])