Automating Inventory Collection Using SNMPWalk Scripts
Overview
Automating inventory collection uses SNMP walks to regularly query devices’ MIBs and extract device identifiers, interfaces, uptime, firmware, serial numbers, IP/MAC, and other inventory fields. Scripts run snmpwalk (or snmpget) against IP ranges, parse outputs, and store results in CSV/JSON or a CMDB.
What to collect (common OIDs)
- sysName (.1.3.6.1.2.1.1.5) — hostname
- sysDescr (.1.3.6.1.2.1.1.1) — model/OS string
- sysUpTime (.1.3.6.1.2.1.1.3) — uptime
- entPhysicalSerialNum (.1.3.6.1.2.1.47.1.1.1.1.11) — serial
- ifDescr (.1.3.6.1.2.1.2.2.1.2) — interface names
- ifPhysAddress (.1.3.6.1.2.1.2.2.1.6) — MACs
- Vendor-specific enterprise OIDs for hardware details (e.g., .1.3.6.1.4.1.*)
Basic script pattern (bash + net-snmp)
- Enumerate target IPs (CIDR or list).
- For each IP: run snmpwalk/snmpget with appropriate version/community or v3 creds.
- Parse values (awk/sed/python).
- Normalize and dedupe.
- Output to CSV/JSON and import to CMDB or database.
- Schedule via cron/automation runner.
Example command snippets:
- SNMPv2c: snmpwalk -v2c -c public 192.0.2.5 .1.3.6.1.2.1.1
- SNMPv3: snmpwalk -v3 -u user -A authPass -a MD5 -X privPass -x AES 192.0.2
Leave a Reply