SnmpKit.SnmpMgr.Engine (snmpkit v0.6.6)

High-performance streaming PDU engine with request routing and connection pooling.

This module provides the core infrastructure for handling large volumes of SNMP requests efficiently through connection pooling, request batching, and intelligent routing strategies.

Summary

Functions

Returns a specification to start this module under a supervisor.

Gets connection pool status.

Gets engine statistics and metrics.

Starts the streaming PDU engine.

Gracefully shuts down the engine.

Submits multiple requests as a batch.

Submits a request to the engine for processing.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_pool_status(engine)

Gets connection pool status.

get_stats(engine)

Gets engine statistics and metrics.

start_link(opts \\ [])

Starts the streaming PDU engine.

Options

  • :pool_size - Number of UDP socket connections to maintain (default: 10)
  • :max_rps - Maximum requests per second (default: 100)
  • :request_timeout - Individual request timeout in ms (default: 5000)
  • :batch_size - Maximum requests per batch (default: 50)
  • :batch_timeout - Maximum time to wait for batch in ms (default: 100)

Examples

{:ok, engine} = SnmpKit.SnmpMgr.Engine.start_link(
  pool_size: 20,
  max_rps: 200,
  batch_size: 100
)

stop(engine)

Gracefully shuts down the engine.

submit_batch(engine, requests, opts \\ [])

Submits multiple requests as a batch.

Parameters

  • engine - Engine PID or name
  • requests - List of request specification maps
  • opts - Batch options

Examples

requests = [
  %{type: :get, target: "device1", oid: "sysDescr.0"},
  %{type: :get, target: "device2", oid: "sysDescr.0"}
]

{:ok, batch_ref} = SnmpKit.SnmpMgr.Engine.submit_batch(engine, requests)

submit_request(engine, request, opts \\ [])

Submits a request to the engine for processing.

Parameters

  • engine - Engine PID or name
  • request - Request specification map
  • opts - Request options

Examples

request = %{
  type: :get,
  target: "192.168.1.1",
  oid: "1.3.6.1.2.1.1.1.0",
  community: "public"
}

{:ok, ref} = SnmpKit.SnmpMgr.Engine.submit_request(engine, request)