SnmpKit.SnmpMgr.Multi (snmpkit v0.3.6)
Concurrent multi-target SNMP operations.
Provides functions to perform SNMP operations against multiple targets concurrently, with configurable timeouts and error handling.
Summary
Functions
Executes mixed SNMP operations against multiple targets concurrently.
Performs GETBULK operations against multiple targets concurrently.
Performs GET operations against multiple targets concurrently.
Monitors multiple devices for changes by polling at regular intervals.
Performs walk operations against multiple targets concurrently.
Performs table walk operations against multiple targets concurrently.
Functions
Executes mixed SNMP operations against multiple targets concurrently.
Allows different operation types per target for maximum flexibility.
Parameters
operations
- List of {operation, target, oid_or_args, opts} tuplesopts
- Global options
Examples
iex> operations = [
...> {:get, "device1", "sysDescr.0", []},
...> {:get_bulk, "switch1", "ifTable", [max_repetitions: 20]},
...> {:walk, "router1", "system", [version: :v2c]}
...> ]
iex> SnmpKit.SnmpMgr.Multi.execute_mixed(operations)
[
{:ok, "Device 1 Description"},
{:ok, [{"1.3.6.1.2.1.2.2.1.2.1", "eth0"}, ...]},
{:ok, [{"1.3.6.1.2.1.1.1.0", "Router 1"}, ...]}
]
Performs GETBULK operations against multiple targets concurrently.
Parameters
targets_and_oids
- List of {target, oid} or {target, oid, opts} tuplesopts
- Global options applied to all requests
Examples
iex> requests = [
...> {"switch1", "ifTable"},
...> {"switch2", "ifTable"},
...> {"router1", "ipRouteTable"}
...> ]
iex> SnmpKit.SnmpMgr.Multi.get_bulk_multi(requests, max_repetitions: 20)
[
{:ok, [{[1,3,6,1,2,1,2,2,1,2,1], :octet_string, "eth0"}, ...]},
{:ok, [{[1,3,6,1,2,1,2,2,1,2,1], :octet_string, "GigE0/1"}, ...]},
{:error, :timeout}
]
Performs GET operations against multiple targets concurrently.
Parameters
targets_and_oids
- List of {target, oid} or {target, oid, opts} tuplesopts
- Global options applied to all requests
Examples
iex> requests = [
...> {"device1", "sysDescr.0"},
...> {"device2", "sysUpTime.0"},
...> {"device3", "ifNumber.0"}
...> ]
iex> SnmpKit.SnmpMgr.Multi.get_multi(requests)
[
{:ok, "Device 1 Description"},
{:ok, 123456},
{:error, :timeout}
]
Monitors multiple devices for changes by polling at regular intervals.
Parameters
targets_and_oids
- List of {target, oid} tuples to monitorcallback
- Function called with {target, oid, old_value, new_value} when changes occuropts
- Options including :interval, :initial_poll, :max_concurrent
Examples
targets = [{"device1", "sysUpTime.0"}, {"device2", "ifInOctets.1"}]
callback = fn change -> IO.inspect(change) end
{:ok, monitor_pid} = SnmpKit.SnmpMgr.Multi.monitor(targets, callback, interval: 30_000)
Performs walk operations against multiple targets concurrently.
Parameters
targets_and_oids
- List of {target, root_oid} or {target, root_oid, opts} tuplesopts
- Global options applied to all requests
Examples
iex> requests = [
...> {"device1", "system"},
...> {"device2", "interfaces"},
...> {"device3", [1, 3, 6, 1, 2, 1, 4]}
...> ]
iex> SnmpKit.SnmpMgr.Multi.walk_multi(requests, version: :v2c)
[
{:ok, [{[1,3,6,1,2,1,1,1,0], :octet_string, "Device 1"}, ...]},
{:ok, [{[1,3,6,1,2,1,2,1,0], :integer, 24}, ...]},
{:error, :timeout}
]
Performs table walk operations against multiple targets concurrently.
Parameters
targets_and_tables
- List of {target, table_oid} or {target, table_oid, opts} tuplesopts
- Global options applied to all requests
Examples
iex> requests = [
...> {"switch1", "ifTable"},
...> {"switch2", "ifTable"},
...> {"router1", "ipRouteTable"}
...> ]
iex> SnmpKit.SnmpMgr.Multi.walk_table_multi(requests, version: :v2c)
[
{:ok, [{"1.3.6.1.2.1.2.2.1.2.1", "eth0"}, ...]},
{:ok, [{"1.3.6.1.2.1.2.2.1.2.1", "GigE0/1"}, ...]},
{:error, :host_unreachable}
]