SnmpKit (snmpkit v2.0.1)
Unified API for SnmpKit - A comprehensive SNMP toolkit for Elixir.
This module provides a clean, organized interface to all SnmpKit functionality through context-based sub-modules:
SnmpKit.SNMP- SNMP operations (get, walk, bulk, etc.)SnmpKit.MIB- MIB compilation, loading, and resolutionSnmpKit.Sim- SNMP device simulation and testing
Timeout Behavior
SnmpKit uses two types of timeouts:
PDU Timeout (:timeout parameter)
- Controls how long to wait for each individual SNMP PDU response
- Default: 5 seconds for every call, from
SnmpKit.SnmpMgr.Config(config :snmpkit, timeout:), which documents the whole model - Applied per SNMP packet, not per operation
:retries(default 1) re-sends a PDU that timed out, under a fresh request id, before the request fails
Walk Timeout (:walk_timeout parameter)
- Prevents operations from hanging indefinitely
- Applies to the whole walk, while
:timeoutstill applies to each PDU - Defaults to
max(timeout * 10, 20 minutes), capped at 30 minutes
Walk Operations
Walk operations may send many GETBULK PDUs to retrieve all data:
- Each PDU has its own timeout (PDU timeout)
- A single-target regular walk reuses one private UDP socket for the walk
- Large tables may need 50-200+ PDUs
- Total time is bounded by
:walk_timeout
Quick Examples
# SNMP Operations (enriched varbind maps)
{:ok, %{value: value, type: :octet_string}} = SnmpKit.SNMP.get("192.168.1.1", "sysDescr.0")
{:ok, results} = SnmpKit.SNMP.walk("192.168.1.1", "system")
# With custom PDU timeout
{:ok, %{value: value}} = SnmpKit.SNMP.get("192.168.1.1", "sysDescr.0", timeout: 15_000)
{:ok, results} = SnmpKit.SNMP.walk("192.168.1.1", "ifTable", timeout: 30_000)
# MIB Operations
{:ok, oid} = SnmpKit.MIB.resolve("sysDescr.0")
{:ok, compiled} = SnmpKit.MIB.compile("MY-MIB.mib")
# Simulation
{:ok, device} = SnmpKit.Sim.start_device(profile, port: 1161)The most common operations are also available directly on SnmpKit
(get/3, walk/3, get_bulk/3, get_multi/2, resolve/1, ...).