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
req_params()
req_params() :: %{ uri: URI.t(), credential: credential(), varbinds: [req_varbind(), ...] }
req_varbind()
snmp_credential()
snmp_credential() :: SNMP.CommunityCredential.t() | SNMP.USMCredential.t()
varbind()
varbind() :: %{oid: object_id(), type: asn1_type(), value: asn1_value()}
Link to this section Functions
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',
}
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"
request(map, options \\ [])
request(req_params(), req_options()) :: [request_result(), ...]
resolve_object_name_to_oid(oid)
start()
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 nodenode
.{:failover, node}
- used if the application is distributed and is started on the current node because of a failover on nodenode
, 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
.
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]