Testing monitoring templates often requires access to specific hardware that may be in production or physically unavailable. By using snmpsim, we can capture a "digital twin" of a real device and run it as a local daemon for safe, repeatable testing.
Step 1: Capturing the Device Snapshot
The first step in our workflow is to gather all OID keys from the target device. We use the standard snmpwalk utility to create a comprehensive dump.
To ensure the output is compatible with the emulator, we must use specific flags to format the data correctly.
From your terminal (Linux or WSL), run the following command to query your device (e.g., a Cisco ASR or Nexus):
- Numeric OIDs: Use
-Onto ensure all keys are saved as raw numbers rather than text labels. - Raw Values: Use
-beUto strip units and extra formatting that might confuse the parser. - Full Walk: Targeting the
1.3.6tree captures the majority of relevant networking and system metrics.
# Example command to dump device data
snmpwalk -ObentU -v2c -c public 192.168.1.1 1.3.6 > hardware_dump.snmpwalk
Step 2: Preparing the Test Folder
snmpsim maps community strings directly to the filenames in its data directory. This makes managing multiple test cases highly intuitive.
- Data Isolation: Create a dedicated directory (e.g.,
snmp_data/) to house your snapshots. - Community Mapping: Rename your captured file to the desired community string. For example,
cisco_asr.snmpwalkwill automatically be served under thecisco_asrcommunity. - Permission Check: Ensure the directory is accessible by the user running the daemon to prevent indexing errors.
Step 3: Running the Simulation
Once your .snmpwalk file is placed in the folder, launch the snmpsim-command-responder. Point the --data-dir argument to your new folder.
The daemon will scan the directory, index the OIDs, and start listening for incoming UDP requests.
This approach allows us to simulate high-load scenarios or complex interface configurations on our local workstations without touching the production network.
Technical Benefits
By leveraging this local extraction and replay pipeline, we achieve enterprise-grade testing quality:
- Offline Development: Work on Zabbix templates or Prometheus exporters while commuting or in environments without VPN access.
- Zero Risk: Experiment with destructive testing or high-frequency polling without impacting the performance of real hardware.
- Consistent Baselines: Share the same
.snmpwalkfiles across a team to ensure everyone is testing against identical data sets.
The extracted data is served exactly as it was captured, preserving the original structure of the MIB tree and all associated values.