SnmpKit.SnmpMgr.AdaptiveWalk (snmpkit v0.6.4)

Intelligent SNMP walk operations with adaptive parameter tuning.

This module provides advanced walk operations that automatically adjust bulk parameters based on device response characteristics for optimal performance.

Summary

Functions

Benchmarks a device to determine optimal bulk parameters.

Performs an adaptive bulk walk that automatically tunes parameters.

Gets optimal parameters for a previously benchmarked device.

Performs an adaptive table walk optimized for large tables.

Functions

benchmark_device(target, test_oid, opts \\ [])

Benchmarks a device to determine optimal bulk parameters.

Performs a series of test requests with different bulk sizes to determine the best parameters for the target device.

Parameters

  • target - The target device to benchmark
  • test_oid - OID to use for testing (should have multiple entries)
  • opts - Options including :test_sizes, :iterations

Examples

# Note: This function makes actual network calls and is not suitable for doctests
{:ok, benchmark} = SnmpKit.SnmpMgr.AdaptiveWalk.benchmark_device("switch.local", "ifTable")
# Returns comprehensive performance analysis:
# %{
#   optimal_bulk_size: 25,
#   avg_response_time: 45,
#   error_rate: 0.0,
#   all_results: [
#     {1, 120}, {5, 85}, {10, 52}, {15, 48},
#     {20, 44}, {25, 42}, {30, 45}, {40, 52}, {50, 68}
#   ],
#   recommendations: %{
#     max_repetitions: 25,
#     timeout: 3000,
#     adaptive_tuning: false  # Device has consistent performance
#   }
# }

# Custom benchmark with specific test sizes:
{:ok, results} = SnmpKit.SnmpMgr.AdaptiveWalk.benchmark_device("router.local", "ipRouteTable",
  test_sizes: [5, 10, 20, 50], iterations: 5)

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

Performs an adaptive bulk walk that automatically tunes parameters.

Starts with a conservative bulk size and adapts based on response times and error rates to find the optimal parameters for the target device.

Parameters

  • target - The target device
  • root_oid - Starting OID for the walk
  • opts - Options including :adaptive_tuning, :performance_threshold

Examples

# Note: This function makes actual network calls and is not suitable for doctests
{:ok, results} = SnmpKit.SnmpMgr.AdaptiveWalk.bulk_walk("switch.local", "ifTable")
# Automatically adjusts bulk size for optimal performance:
# [
#   {"1.3.6.1.2.1.2.2.1.2.1", :octet_string, "FastEthernet0/1"},
#   {"1.3.6.1.2.1.2.2.1.2.2", :octet_string, "FastEthernet0/2"},
#   {"1.3.6.1.2.1.2.2.1.2.3", :octet_string, "GigabitEthernet0/1"},
#   # ... optimally retrieved with adaptive bulk sizing
# ]

# With custom options:
{:ok, results} = SnmpKit.SnmpMgr.AdaptiveWalk.bulk_walk("router.local", "sysDescr",
  adaptive_tuning: true, max_entries: 100, performance_threshold: 50)
# [{"1.3.6.1.2.1.1.1.0", :octet_string, "Cisco IOS Software, Version 15.1"}]

get_optimal_params(target, opts \\ [])

Gets optimal parameters for a previously benchmarked device.

Returns cached optimal parameters or performs a quick benchmark if no cached data is available.

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

Performs an adaptive table walk optimized for large tables.

Automatically determines the optimal bulk size for table retrieval and handles pagination for very large tables.

Parameters

  • target - The target device
  • table_oid - The table OID to walk
  • opts - Options including :adaptive_tuning, :stream, :max_entries

Examples

# Note: This function makes actual network calls and is not suitable for doctests
{:ok, table_data} = SnmpKit.SnmpMgr.AdaptiveWalk.table_walk("switch.local", "ifTable", max_entries: 1000)
# Efficiently walks large tables with automatic optimization:
# [
#   {"1.3.6.1.2.1.2.2.1.1.1", :integer, 1},           # ifIndex.1
#   {"1.3.6.1.2.1.2.2.1.2.1", :octet_string, "Ethernet1"}, # ifDescr.1
#   {"1.3.6.1.2.1.2.2.1.3.1", :integer, 6},           # ifType.1 (ethernetCsmacd)
#   {"1.3.6.1.2.1.2.2.1.5.1", :gauge32, 1000000000},  # ifSpeed.1 (1 Gbps)
#   # ... continues with adaptive pagination for large tables
# ]

# For very large tables with streaming:
{:ok, results} = SnmpKit.SnmpMgr.AdaptiveWalk.table_walk("core-switch", "ipRouteTable",
  max_entries: 10000, adaptive_tuning: true)