Search documentation of snmpkit

# SnmpKit.SnmpMgr.Bulk (snmpkit v1.3.17)

Advanced SNMP bulk operations using SNMPv2c GETBULK.

This module provides efficient bulk operations that are significantly faster than iterative GETNEXT requests for retrieving large amounts of data.

# Summary

## Functions

get_bulk(target, oids, opts \\ [])

Performs a single GETBULK request.

get_bulk_multi(targets_and_oids, opts \\ [])

Performs multiple concurrent GETBULK operations.

get_table_bulk(target, table_oid, opts \\ [])

Optimized table retrieval using GETBULK.

walk_bulk(target, root_oid, opts \\ [])

Bulk walk operation using GETBULK instead of iterative GETNEXT.

# Functions

# get_bulk(target, oids, opts \\ [])

Performs a single GETBULK request.

Returns enriched varbind maps (same standardized shape as other SnmpMgr APIs).

## Parameters

- `target` - The target device
- `oids` - Single OID or list of OIDs to retrieve
- `opts` - Options including :max_repetitions, :non_repeaters

## Examples

    iex> SnmpKit.SnmpMgr.Bulk.get_bulk("192.168.1.1", "ifTable", max_repetitions: 20)
    {:ok, [
      {[1,3,6,1,2,1,2,2,1,2,1], :octet_string, "eth0"},
      {[1,3,6,1,2,1,2,2,1,2,2], :octet_string, "eth1"},
      # ... up to 20 entries with type information
    ]}

# get_bulk_multi(targets_and_oids, opts \\ [])

Performs multiple concurrent GETBULK operations.

## Parameters

- `targets_and_oids` - List of {target, oid} tuples
- `opts` - Options for all requests

## Examples

    iex> requests = [
    ...>   {"device1", "sysDescr.0"},
    ...>   {"device2", "sysUpTime.0"},
    ...>   {"device3", "ifNumber.0"}
    ...> ]
    iex> SnmpKit.SnmpMgr.Bulk.get_bulk_multi(requests)
    [
      {:ok, [{"1.3.6.1.2.1.1.1.0", "Device 1"}]},
      {:ok, [{"1.3.6.1.2.1.1.3.0", 123456}]},
      {:error, :timeout}
    ]

# get_table_bulk(target, table_oid, opts \\ [])

Optimized table retrieval using GETBULK.

Returns enriched varbind maps for each entry, e.g.: {:ok, [%{oid: "1.3.6.1...", oid_list: [...], type: :octet_string, value: "eth0", name: ..., formatted: ...}, ...]}

Uses GETBULK to efficiently retrieve an entire SNMP table, automatically handling pagination when tables are larger than max_repetitions.

## Parameters

- `target` - The target device
- `table_oid` - The table OID to retrieve
- `opts` - Options including :max_repetitions, :max_entries

## Examples

    iex> SnmpKit.SnmpMgr.Bulk.get_table_bulk("switch.local", "ifTable")
    {:ok, [
      {"1.3.6.1.2.1.2.2.1.2.1", "eth0"},
      {"1.3.6.1.2.1.2.2.1.3.1", 6},
      {"1.3.6.1.2.1.2.2.1.2.2", "eth1"},
      {"1.3.6.1.2.1.2.2.1.3.2", 6}
    ]}

# walk_bulk(target, root_oid, opts \\ [])

Bulk walk operation using GETBULK instead of iterative GETNEXT.

Returns enriched varbind maps for each entry (same shape as other APIs).

Significantly more efficient than traditional walks for large subtrees.

## Parameters

- `target` - The target device
- `root_oid` - Starting OID for the walk
- `opts` - Options including :max_repetitions, :max_entries

## Examples

    iex> SnmpKit.SnmpMgr.Bulk.walk_bulk("device.local", "system")
    {:ok, [
      {"1.3.6.1.2.1.1.1.0", "System Description"},
      {"1.3.6.1.2.1.1.2.0", "1.3.6.1.4.1.9"},
      {"1.3.6.1.2.1.1.3.0", 12345}
    ]}