Automated network device discovery and inventory documentation
Features β’ Installation β’ Usage β’ Output
The Network Inventory Scanner automatically discovers network devices, collects detailed inventory information via SNMP, SSH, and active scanning, then generates comprehensive documentation in multiple formats.
| Feature | Description |
|---|---|
| π Auto-Discovery | Scan subnets to find active network devices |
| π SNMP Collection | Gather detailed device info via SNMP v2c/v3 |
| π SSH Collection | Collect data via CLI commands |
| π Multi-Format Export | CSV, JSON, Excel, HTML reports |
| π Delta Detection | Track inventory changes over time |
| π Visualization | Network topology diagrams |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DISCOVERY METHODS β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β ICMP PING β TCP SCAN β ARP SCAN β
β βββββββββββββββ β βββββββββββββββ β βββββββββββββββ β
β β’ Fast sweep β β’ Port detection β β’ Local segment β
β β’ Subnet range β β’ Service ID β β’ MAC address β
β β’ Parallel β β’ Banner grab β β’ Vendor lookup β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β COLLECTION METHODS β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β SNMP β SSH/CLI β API β
β βββββββββββββββ β βββββββββββββββ β βββββββββββββββ β
β β’ System OIDs β β’ Show commands β β’ REST endpoints β
β β’ Interface MIB β β’ Multi-vendor β β’ Vendor APIs β
β β’ Entity MIB β β’ Netmiko β β’ JSON parsing β
β β’ Custom OIDs β β’ Custom parsers β β’ Authentication β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β COLLECTED DATA β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β’ Hostname β β’ Model β β’ Interfaces β
β β’ IP Addresses β β’ Serial Number β β’ Neighbors (CDP) β
β β’ MAC Addresses β β’ Software Ver β β’ VLANs β
β β’ Vendor/OUI β β’ Uptime β β’ Routing Tables β
β β’ Location β β’ Memory/CPU β β’ ARP Tables β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Clone repository
git clone https://github.com/tamersaid2022/network-inventory-scanner.git
cd network-inventory-scanner
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# Install dependencies
pip install -r requirements.txt
# Install Nmap (if using port scanning)
# Ubuntu/Debian: sudo apt install nmap
# RHEL/CentOS: sudo yum install nmap
# macOS: brew install nmappysnmp>=4.4.12
netmiko>=4.2.0
python-nmap>=0.7.1
scapy>=2.5.0
pandas>=2.0.0
openpyxl>=3.1.0
jinja2>=3.1.0
pyyaml>=6.0
rich>=13.0.0
mac-vendor-lookup>=0.1.12
ipaddress>=1.0.23
concurrent-log-handler>=0.9.24from network_scanner import NetworkScanner
# Initialize scanner
scanner = NetworkScanner(
networks=["192.168.1.0/24", "10.0.0.0/24"],
snmp_community="public",
ssh_username="admin",
ssh_password="password"
)
# Run discovery
devices = scanner.discover()
# Collect detailed inventory
inventory = scanner.collect_inventory(devices)
# Export results
scanner.export_csv("inventory.csv")
scanner.export_excel("inventory.xlsx")
scanner.export_html("inventory.html")# Scan single subnet
python network_scanner.py scan --network 192.168.1.0/24
# Scan multiple networks
python network_scanner.py scan --network 192.168.1.0/24 --network 10.0.0.0/24
# Scan with SNMP collection
python network_scanner.py scan --network 192.168.1.0/24 --snmp-community public
# Scan with SSH collection
python network_scanner.py scan --network 192.168.1.0/24 --ssh-user admin --ssh-pass password
# Full scan with all collection methods
python network_scanner.py scan --network 192.168.1.0/24 \
--snmp-community public \
--ssh-user admin --ssh-pass password \
--output inventory.xlsx
# Export to multiple formats
python network_scanner.py export --input inventory.json --format csv,excel,html
# Compare inventories (delta report)
python network_scanner.py diff --old inventory_old.json --new inventory_new.json
# Schedule periodic scans
python network_scanner.py schedule --interval 24h --config scan_config.yaml# scan_config.yaml
---
discovery:
networks:
- 192.168.1.0/24
- 192.168.2.0/24
- 10.0.0.0/24
methods:
- icmp
- tcp
- arp
tcp_ports:
- 22 # SSH
- 23 # Telnet
- 80 # HTTP
- 443 # HTTPS
- 161 # SNMP
timeout: 2
threads: 50
snmp:
enabled: true
version: 2c
community: "${SNMP_COMMUNITY}"
# For SNMPv3:
# version: 3
# username: snmpuser
# auth_protocol: SHA
# auth_password: "${SNMP_AUTH_PASS}"
# priv_protocol: AES
# priv_password: "${SNMP_PRIV_PASS}"
timeout: 5
retries: 2
ssh:
enabled: true
username: "${SSH_USER}"
password: "${SSH_PASS}"
# Or use key-based auth:
# key_file: ~/.ssh/id_rsa
timeout: 30
output:
directory: ./inventory
formats:
- json
- csv
- excel
- html
timestamp: true
scheduling:
enabled: false
interval: 24h
notify:
email: netops@company.comββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β NETWORK INVENTORY SCAN RESULTS β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£
β Scan Date: 2024-01-15 14:30:00 β
β Networks: 192.168.1.0/24, 10.0.0.0/24 β
β Total IPs: 512 β
β Active Hosts: 47 β
β Network Devices: 23 β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£
β β
β IP Address Hostname Vendor Model Version β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β 192.168.1.1 core-router-01 Cisco ISR4451 16.12.4 β
β 192.168.1.2 core-router-02 Cisco ISR4451 16.12.4 β
β 192.168.1.10 dist-sw-01 Cisco C9300-48P 17.6.3 β
β 192.168.1.11 dist-sw-02 Cisco C9300-48P 17.6.3 β
β 192.168.1.20 access-sw-01 Cisco C2960X-48 15.2.7 β
β 192.168.1.100 firewall-01 Palo Alto PA-850 10.2.3 β
β 192.168.1.101 wlc-01 Cisco C9800-40 17.6.2 β
β 10.0.0.1 dc-core-01 Cisco N9K-C93180 10.2.5 β
β 10.0.0.2 dc-core-02 Cisco N9K-C93180 10.2.5 β
β ... β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
The Excel export includes multiple worksheets:
| Sheet | Contents |
|---|---|
| Summary | Scan statistics and overview |
| Devices | Complete device inventory |
| Interfaces | All interface details |
| Neighbors | CDP/LLDP neighbor data |
| VLANs | VLAN configurations |
| Changes | Delta from previous scan |
Beautiful, interactive HTML report with:
- Sortable/filterable tables
- Search functionality
- Device detail modals
- Network topology diagram
- Export buttons
| Field | Source | Description |
|---|---|---|
| IP Address | Discovery | Primary IP address |
| Hostname | SNMP/SSH | Device hostname |
| Vendor | OUI/SNMP | Manufacturer |
| Model | SNMP/SSH | Hardware model |
| Serial Number | SNMP/SSH | Device serial |
| Software Version | SNMP/SSH | OS version |
| Uptime | SNMP/SSH | System uptime |
| Location | SNMP | sysLocation |
| Contact | SNMP | sysContact |
| MAC Address | ARP/SNMP | Primary MAC |
| Device Type | Detection | Router/Switch/FW/etc |
| Field | Source | Description |
|---|---|---|
| Interface Name | SNMP/SSH | Interface identifier |
| Description | SNMP/SSH | Interface description |
| IP Address | SNMP/SSH | Assigned IP |
| MAC Address | SNMP/SSH | Interface MAC |
| Speed | SNMP | Link speed |
| Admin Status | SNMP/SSH | Admin up/down |
| Oper Status | SNMP/SSH | Operational state |
| VLAN | SNMP/SSH | Access/trunk VLAN |
| Errors | SNMP | Error counters |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β NETWORK SCANNER β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β Discovery β β Collector β β Exporter β β
β β Engine βββββΆβ Engine βββββΆβ Engine β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β β β β
β ββββββ΄βββββ ββββββ΄βββββ ββββββ΄βββββ β
β β β β β β β β
β βββΌββ βββββ β ββββΌβββ ββββΌβββ ββββΌβββ ββββΌβββ β
β βICMPβ βTCPβ β βSNMP β βSSH β βJSON β βExcelβ β
β βββββ βββββ β βββββββ βββββββ βββββββ βββββββ β
β βββββ β βββββββ βββββββ βββββββ β
β βARPβ β βAPI β βCSV β βHTML β β
β βββββ β βββββββ βββββββ βββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
network-inventory-scanner/
βββ network_scanner.py # Main scanner script
βββ scan_config.yaml # Configuration file
βββ requirements.txt # Dependencies
βββ lib/
β βββ discovery.py # Discovery engines
β βββ snmp_collector.py # SNMP collection
β βββ ssh_collector.py # SSH/CLI collection
β βββ exporters.py # Export formatters
β βββ utils.py # Utility functions
βββ templates/
β βββ report.html.j2 # HTML report template
β βββ email.html.j2 # Email notification
βββ inventory/ # Output directory
β βββ inventory_20240115.json
β βββ inventory_20240115.xlsx
β βββ inventory_20240115.html
βββ tests/
βββ test_scanner.py # Unit tests
| Concern | Mitigation |
|---|---|
| Credentials | Use environment variables or vault |
| SNMP Community | Use SNMPv3 with auth/privacy |
| Network Impact | Rate limiting, off-hours scanning |
| Data Storage | Encrypt sensitive fields |
| Access Control | Restrict who can run scans |
# Set credentials securely
export SNMP_COMMUNITY='your-community'
export SSH_USER='admin'
export SSH_PASS='password'
export SNMP_AUTH_PASS='authpass'
export SNMP_PRIV_PASS='privpass'Track changes between inventory scans:
# Compare two inventory files
python network_scanner.py diff --old inventory_jan.json --new inventory_feb.json
# Output:
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# β INVENTORY CHANGES β
# β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£
# β NEW DEVICES (3) β
# β ββ 192.168.1.50 - New access switch (C2960X) β
# β ββ 192.168.1.51 - New access switch (C2960X) β
# β ββ 10.0.0.100 - New server (Dell PowerEdge) β
# β β
# β REMOVED DEVICES (1) β
# β ββ 192.168.1.30 - Old switch decommissioned β
# β β
# β CHANGED DEVICES (2) β
# β ββ 192.168.1.1 - Version: 16.12.3 β 16.12.4 β
# β ββ 192.168.1.10 - Interfaces: 48 β 52 β
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββContributions are welcome! Please read our Contributing Guide for details.
This project is licensed under the MIT License - see the LICENSE file for details.