A high-performance Go-based SNMP network monitoring backend with RSA-encrypted authentication, dynamic polling, and comprehensive device metrics collection.
- π Secure Authentication: RSA-2048 encrypted login with JWT session management
- π Comprehensive Monitoring: SNMP v2c polling for interfaces, health, storage, protocols, and sensors
- π¨ SNMP Trap Receiver: Real-time alert collection on UDP port 162
- π₯ Role-Based Access Control: Admin and user roles with granular device permissions
- π Network Discovery: Automated CIDR-based SNMP scanning
- β‘ Dynamic Polling: Configurable poll intervals and SNMP timeouts
- π‘ Multi-Metric Collection: CPU load, memory, network traffic, storage utilization, and temperature sensors
- π System Logging: Centralized logging to database with console output
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β React βββββββΊβ Go Backend βββββββΊβ MySQL β
β Frontend β HTTPSβ REST API β β Database β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β
βΌ
ββββββββββββββββ
β SNMP Devices β
β (UDP 161/162)β
ββββββββββββββββ
- Go: 1.25.5 or higher
- MySQL: 8.0 or higher
- Network Access: UDP ports 161 (SNMP), 162 (Traps)
- Operating System: Linux, macOS, or Windows
git clone
cdgo mod downloadCreate the MySQL database and import the schema:
mysql -u root -pCREATE DATABASE network_monitor CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE network_monitor;
-- Import your SQL schema here (devices, users, sessions, etc.)Required tables:
devices- Network device inventoryusers- Authentication and authorizationsessions- JWT token sessionsuser_device_permissions- RBAC permissionsdevice_health- CPU, RAM, uptime metricsinterface_metrics- Network interface statisticsstorage_metrics- Disk utilizationprotocol_metrics- TCP/UDP/ICMP counterssensor_metrics- Temperature and hardware sensorsalerts- Active system alertssystem_logs- Application logssettings- Configuration key-value store
Create a .env file in the root directory:
# Database Configuration
DB_USER=root
DB_PASS=your_secure_password
DB_HOST=127.0.0.1
DB_PORT=3306
DB_NAME=network_monitor
# HTTP Server
HTTP_PORT=:8080# Development
go run .
# Production Build
go build -o nms-backend
./nms-backend| Method | Endpoint | Description |
|---|---|---|
| GET | /api/auth/key |
Retrieve RSA public key for encryption |
| POST | /api/login |
Authenticate with encrypted credentials |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/auth/me |
Get current user profile |
| GET | /api/devices |
List all accessible devices |
| POST | /api/devices |
Create new device (Admin/Write) |
| PUT | /api/devices |
Update device configuration |
| POST | /api/device/action |
Pause/Resume/Delete device |
| GET | /api/device/detail?id={id} |
Detailed telemetry for device |
| GET | /api/alerts |
List active alerts |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/logs |
View system logs |
| GET/POST | /api/settings |
Manage system configuration |
| POST | /api/scan |
Discover devices via CIDR scan |
| GET/POST/PUT/DELETE | /api/admin/users |
User management |
| GET/POST | /api/admin/permissions |
Device permission management |
- Client requests public key:
GET /api/auth/key - Server responds with RSA-2048 public key (PEM format)
- Client encrypts JSON payload:
{"username":"admin","password":"password"} - Client Base64-encodes ciphertext and sends:
POST /api/login - Server decrypts with private key, validates credentials
- Server creates session token, returns JWT + user object
- Client includes
Authorization: Bearer <token>in all subsequent requests
- System: sysDescr, sysContact, sysLocation, sysName, sysUptime
- Interfaces: ifXTable (HC counters), ifTable (errors, status)
- Health: UCD-SNMP-MIB (load averages, memory)
- Storage: HOST-RESOURCES-MIB (disk utilization)
- Protocols: TCP/UDP/ICMP statistics
- Sensors: LM-SENSORS-MIB (temperature)
1. Fetch active devices (WHERE is_paused = 0)
2. For each device (concurrent goroutines):
a. Connect via SNMPv2c
b. Ping check (sysUptime)
c. Collect system info
d. Collect health metrics
e. Walk interface table
f. Walk storage table
g. Walk sensor table
3. Sleep for poll_interval seconds
4. Repeat
| Status | Condition |
|---|---|
up |
Successful SNMP response |
down |
Socket error or timeout |
unknown |
Never polled |
Settings are stored in the settings table and can be modified via /api/settings:
| Key | Description | Default |
|---|---|---|
poll_interval |
Seconds between poll cycles | 60 |
snmp_timeout |
SNMP request timeout (ms) | 2000 |
retention_days |
Metrics retention period | 30 |
Logs are written to:
- Console (stdout): Real-time monitoring
- Database (
system_logstable): Persistent storage
Log levels: INFO, WARNING, ERROR
Example:
2025-12-07 10:15:30 [INFO] System: Server started on :8080
2025-12-07 10:16:00 [ERROR] Poller: [Core-SW-01] Unreachable: Timeout
- β RSA-2048 encryption for login credentials
- β Bcrypt SHA-256 password hashing
- β JWT session tokens with expiration
- β CORS enabled for frontend integration
- β Role-based access control (RBAC)
- β SQL prepared statements (injection prevention)
- β HTTPS should be configured via reverse proxy (Nginx/Caddy)
- β Firewall UDP ports 161/162 to trusted networks only
# Verify MySQL is running
systemctl status mysql
# Test connection
mysql -u root -p -h 127.0.0.1 -e "SELECT 1"# SNMP traps require root/CAP_NET_BIND_SERVICE
sudo setcap 'cap_net_bind_service=+ep' ./nms-backend- Verify SNMP community string matches device configuration
- Check firewall rules allow UDP 161 outbound
- Test with
snmpwalk:snmpwalk -v2c -c public 192.168.1.1 system
- Concurrent Polling: Devices are polled in parallel (goroutines)
- Connection Pooling: MySQL connection pool managed by
database/sql - Bulk Operations: Interface/storage data uses prepared statements
- Rate Limiting: Network scans use semaphore (50 concurrent)
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-metric - Commit changes:
git commit -am 'Add CPU temperature monitoring' - Push to branch:
git push origin feature/new-metric - Submit a Pull Request
This project is licensed under the MIT License.
For issues and questions:
- GitHub Issues: /issues
- Documentation:
- Email: atharvshirgurkar@gmail.com