Initial commit — LLDP network mapper
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
# LLDP Network Mapper
|
||||
|
||||
SSH-based network topology mapper for FS switches (and IOS-like CLIs).
|
||||
Discovers switch topology via LLDP, stores in SQLite, and visualises with Cytoscape.js.
|
||||
|
||||
## Quick Start
|
||||
|
||||
### 1. Configure your switches
|
||||
|
||||
Edit `mapper/config.py`:
|
||||
|
||||
```python
|
||||
SWITCHES = [
|
||||
"192.168.1.1",
|
||||
"192.168.1.2",
|
||||
# Add all switch management IPs
|
||||
]
|
||||
|
||||
SSH_USERNAME = "admin"
|
||||
SSH_PASSWORD = "yourpassword"
|
||||
```
|
||||
|
||||
### 2. Build and run
|
||||
|
||||
```bash
|
||||
docker-compose up --build
|
||||
```
|
||||
|
||||
### 3. Open the UI
|
||||
|
||||
Navigate to: http://localhost:5000
|
||||
|
||||
Click **Scan Now** to start discovery.
|
||||
|
||||
---
|
||||
|
||||
## What it does
|
||||
|
||||
- SSHs into each switch in parallel (up to 10 at once)
|
||||
- Runs `show lldp neighbors` and `show ip interface brief`
|
||||
- Parses neighbors, hostnames, management IPs, chassis IDs
|
||||
- Stores everything in SQLite (`data/network.db`)
|
||||
- De-duplicates bidirectional links automatically
|
||||
- Renders an interactive Cytoscape.js topology diagram
|
||||
- Exports to CSV, Mermaid (.md), and Graphviz PNG
|
||||
|
||||
## Outputs
|
||||
|
||||
All files written to `data/exports/`:
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `topology.csv` | Switch links with hostnames and IPs |
|
||||
| `topology.md` | Mermaid diagram (paste into any markdown viewer) |
|
||||
| `topology.dot` | Graphviz source |
|
||||
| `topology.png` | Rendered network diagram |
|
||||
|
||||
## Auto-scan
|
||||
|
||||
Toggle auto-scan on/off from the UI. Set interval (15 min to 6 hours).
|
||||
State persists across container restarts.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**Auth errors**: Check SSH_USERNAME / SSH_PASSWORD in config.py
|
||||
|
||||
**Timeout errors**: Increase SSH_TIMEOUT in config.py (default: 30s)
|
||||
|
||||
**Wrong device type**: If your FS switch uses a non-IOS CLI, try changing
|
||||
DEVICE_TYPE to `"linux"` or `"generic"` in config.py
|
||||
|
||||
**No management IP found**: The script looks for Vlan interfaces in
|
||||
`show ip interface brief`. If your switch uses a different command,
|
||||
edit `parser.py → parse_mgmt_ip_from_interfaces()`
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
lldp-mapper/
|
||||
├── mapper/
|
||||
│ ├── config.py # Switch IPs + credentials
|
||||
│ ├── db.py # SQLite operations
|
||||
│ ├── parser.py # LLDP output parser
|
||||
│ ├── ssh_client.py # Netmiko SSH + parallel scan
|
||||
│ ├── scanner.py # Orchestrator
|
||||
│ └── exports.py # CSV / Mermaid / Graphviz
|
||||
├── web/
|
||||
│ ├── app.py # Flask API + scheduler
|
||||
│ └── templates/
|
||||
│ └── index.html # Cytoscape.js frontend
|
||||
├── data/ # SQLite DB + exports (created at runtime)
|
||||
├── Dockerfile
|
||||
├── docker-compose.yml
|
||||
└── README.md
|
||||
```
|
||||
Reference in New Issue
Block a user