SnmpKit.SnmpMgr.Core (snmpkit v0.6.4)

Core SNMP operations using Erlang's SNMP PDU functions directly.

This module handles the low-level SNMP PDU encoding/decoding and UDP communication without requiring the heavyweight :snmpm manager process.

Summary

Functions

Parses and normalizes an OID to internal list format.

Sends an SNMP GETBULK request (SNMPv2c only).

Sends an asynchronous SNMP GETBULK request.

Sends a GETNEXT request to retrieve the next OID in the MIB tree.

Sends an SNMP GET request and returns the response.

Sends an asynchronous SNMP GET request.

Sends a GET request and returns the result in 3-tuple format.

Sends an SNMP SET request and returns the response.

Types

oid()

@type oid() :: binary() | [non_neg_integer()]

opts()

@type opts() :: keyword()

snmp_result()

@type snmp_result() :: {:ok, term()} | {:error, atom() | tuple()}

target()

@type target() :: binary() | tuple() | map()

Functions

parse_oid(oid)

@spec parse_oid(oid()) :: {:ok, [non_neg_integer()]} | {:error, term()}

Parses and normalizes an OID to internal list format.

Converts external OID input (string or list) to internal list of integers format. This function establishes the API boundary - all external input is converted to internal list format here.

send_get_bulk_request(target, oid, opts \\ [])

@spec send_get_bulk_request(target(), oid(), opts()) :: snmp_result()

Sends an SNMP GETBULK request (SNMPv2c only).

send_get_bulk_request_async(target, oid, opts \\ [])

@spec send_get_bulk_request_async(target(), oid(), opts()) :: reference()

Sends an asynchronous SNMP GETBULK request.

send_get_next_request(target, oid, opts \\ [])

@spec send_get_next_request(target(), oid(), opts()) :: snmp_result()

Sends a GETNEXT request to retrieve the next OID in the MIB tree.

Now uses the proper SnmpKit.SnmpLib.Manager.get_next/3 function which handles version-specific logic (GETNEXT for v1, GETBULK for v2c+) correctly.

send_get_request(target, oid, opts \\ [])

@spec send_get_request(target(), oid(), opts()) :: snmp_result()

Sends an SNMP GET request and returns the response.

send_get_request_async(target, oid, opts \\ [])

@spec send_get_request_async(target(), oid(), opts()) :: reference()

Sends an asynchronous SNMP GET request.

send_get_request_with_type(target, oid, opts \\ [])

@spec send_get_request_with_type(target(), oid(), opts()) ::
  {:ok, {String.t(), atom(), any()}} | {:error, any()}

Sends a GET request and returns the result in 3-tuple format.

This function returns {oid_string, type, value} for consistency with other operations like walk, bulk, etc.

send_set_request(target, oid, value, opts \\ [])

@spec send_set_request(target(), oid(), term(), opts()) :: snmp_result()

Sends an SNMP SET request and returns the response.