SnmpKit.SnmpSim.Recorder (snmpkit v2.0.1)

Records a real device into the walk-file format the simulator loads, so a device can be captured once and replayed with SnmpKit.SnmpSim.ProfileLoader.load_profile(type, {:walk_file, path}).

:ok = SnmpKit.Sim.record("192.168.1.1", "test/fixtures/core-switch.walk", community: "public")

The file uses net-snmp's numeric snmpwalk -On style, one line per object:

.1.3.6.1.2.1.1.1.0 = STRING: "Cisco IOS Software"
.1.3.6.1.2.1.2.2.1.6.1 = Hex-STRING: 00 1A 2B 3C 4D 5E
.1.3.6.1.2.1.1.3.0 = Timeticks: (123456) 0:20:34.56

Options

  • :root - subtree to record (default "1.3.6.1.2.1", mib-2; use "1.3.6.1" for everything the agent has, enterprise objects included)
  • :community, :version, :timeout, :retries, :walk_timeout - as for SnmpKit.SNMP.bulk_walk/3

Summary

Functions

One walk-file line for a varbind, or nil for values that cannot be recorded.

Walks target from root and writes the objects to path. Returns {:ok, count} with the number of objects written.

Renders enriched varbinds (as returned by walks) as walk-file text.

Types

record_result()

@type record_result() :: {:ok, non_neg_integer()} | {:error, term()}

Functions

line(map)

@spec line(map()) :: String.t() | nil

One walk-file line for a varbind, or nil for values that cannot be recorded.

record(target, path, opts \\ [])

@spec record(term(), Path.t(), keyword()) :: record_result()

Walks target from root and writes the objects to path. Returns {:ok, count} with the number of objects written.

to_lines(varbinds)

@spec to_lines([map()]) :: {:ok, iodata()}

Renders enriched varbinds (as returned by walks) as walk-file text.