SnmpKit.SnmpSim.Device (snmpkit v0.6.3)
Lightweight Device GenServer for handling SNMP requests. Uses shared profiles and minimal device-specific state for scalability.
Features:
- Dynamic value generation with realistic patterns
- Shared profile system for memory efficiency
- Counter and gauge simulation with proper incrementing
- Comprehensive error handling and fallback mechanisms
- Support for SNMP walk operations
Summary
Functions
Returns a specification to start this module under a supervisor.
Cleanup all orphaned SNMP simulator device processes. Useful for test cleanup when devices may have been left running.
Get an OID value from the device (for testing).
Get bulk OID values from the device (for testing).
Get device information and statistics.
Get the next OID value from the device (for testing).
Monitor a device process and get notified when it dies. Returns a monitor reference that can be used with Process.demonitor/1.
Simulate a device reboot.
Set a gauge value manually (useful for testing).
Start a device with the given device configuration.
Create a device with monitoring enabled. Returns {:ok, {device_pid, monitor_ref}} or {:error, reason}.
Stop a device gracefully with resilient error handling.
Update device counters manually (useful for testing).
Walk OID values from the device (for testing).
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Cleanup all orphaned SNMP simulator device processes. Useful for test cleanup when devices may have been left running.
Get an OID value from the device (for testing).
Get bulk OID values from the device (for testing).
Get device information and statistics.
Get the next OID value from the device (for testing).
Monitor a device process and get notified when it dies. Returns a monitor reference that can be used with Process.demonitor/1.
Simulate a device reboot.
Set a gauge value manually (useful for testing).
Start a device with the given device configuration.
Device Config
Device config should contain:
:port
- UDP port for the device (required):device_type
- Type of device (:cable_modem, :switch, etc.):device_id
- Unique device identifier:community
- SNMP community string (default: "public"):mac_address
- MAC address (auto-generated if not provided)
Examples
device_config = %{
port: 9001,
device_type: :cable_modem,
device_id: "cable_modem_9001",
community: "public"
}
{:ok, device} = SnmpKit.SnmpSim.Device.start_link(device_config)
Create a device with monitoring enabled. Returns {:ok, {device_pid, monitor_ref}} or {:error, reason}.
Stop a device gracefully with resilient error handling.
Update device counters manually (useful for testing).
Walk OID values from the device (for testing).