Network SNMP Trap Handler Management - rConfig V8 CLI
SNMP Trap Handler: Real-Time Network Event Monitoring
Section titled “SNMP Trap Handler: Real-Time Network Event Monitoring”The SNMP Trap Handler enables rConfig to receive and process SNMP trap notifications from network devices in real-time, providing immediate visibility into critical network events, configuration changes, and system alerts. This guide covers deployment, configuration, and operational management of the SNMP Trap Handler service using Supervisor for reliable, production-grade operation.
Understanding SNMP Trap Handling
Section titled “Understanding SNMP Trap Handling”How SNMP Trap Reception Works
Section titled “How SNMP Trap Reception Works”SNMP traps are asynchronous notifications sent by network devices to inform management systems of significant events without polling. Unlike SNMP polling where the management system queries devices, traps are device-initiated, providing immediate notification of events such as:
Configuration Events: Device configuration changes, startup/reload notifications, and administrative modifications trigger traps that rConfig can correlate with configuration backups to provide audit trails and change tracking.
Operational Events: Link state changes, routing protocol updates, hardware failures, and environmental alerts generate traps that provide context for configuration analysis and troubleshooting workflows.
Security Events: Authentication failures, unauthorized access attempts, and security policy violations produce traps that complement configuration security analysis and compliance monitoring.
Integration with rConfig Workflows
Section titled “Integration with rConfig Workflows”The SNMP Trap Handler integrates seamlessly with rConfig’s configuration management capabilities:
Event Correlation: Traps received near configuration backup times provide context—a “configuration changed” trap followed by a backup captures the administrative action and resulting configuration in a unified timeline.
Automated Responses: Trap reception can trigger automated workflows such as immediate configuration backups, notification escalations, or compliance checks based on trap content and severity.
Historical Analysis: Trapped events stored in rConfig’s database enable historical correlation between network events and configuration changes, supporting root cause analysis and trend identification.
Prerequisites
Section titled “Prerequisites”System Requirements
Section titled “System Requirements”Supervisor Process Manager: The SNMP Trap Handler runs as a supervised background service, requiring Supervisor for process management, automatic restart, and operational monitoring. If rConfig was installed correctly, Supervisor should already be configured. Verify installation:
# Check Supervisor statussystemctl status supervisor
# Verify Supervisor is enabledsystemctl is-enabled supervisorPort Availability: SNMP trap reception requires a dedicated UDP port. The standard SNMP trap port (162) requires root privileges on most systems. Verify port availability:
# Check if port 162 is in usesudo netstat -ulnp | grep :162
# Check if port 1162 (alternative) is in usesudo netstat -ulnp | grep :1162PHP Requirements: The trap handler requires PHP CLI with necessary extensions. Verify PHP installation:
# Check PHP version (7.4+ required)php -v
# Verify required extensionsphp -m | grep -E 'snmp|sockets|pcntl'Network Configuration
Section titled “Network Configuration”Firewall Rules: Ensure the configured trap port accepts UDP traffic from network devices:
# For firewalld (RHEL/CentOS)sudo firewall-cmd --add-port=162/udp --permanentsudo firewall-cmd --reload
# For UFW (Ubuntu/Debian)sudo ufw allow 162/udpDevice Configuration: Network devices must be configured to send traps to the rConfig server. Example Cisco configuration:
snmp-server host <rconfig-server-ip> traps version 2c publicsnmp-server enable traps configsnmp-server enable traps syslogInitial Testing and Validation
Section titled “Initial Testing and Validation”Manual Testing Procedure
Section titled “Manual Testing Procedure”Run the trap handler manually to validate configuration and connectivity:
# Navigate to rConfig installation directorycd /var/www/html/rconfig8/current
# Test with default settings (requires root for port 162)sudo php artisan rconfig:snmp-trap-handler --host=0.0.0.0 --port=162
# Test with non-privileged portphp artisan rconfig:snmp-trap-handler --host=0.0.0.0 --port=1162
# Test with specific interface bindingphp artisan rconfig:snmp-trap-handler --host=192.168.1.100 --port=1162Testing Output: Without --daemon, the handler runs in interactive mode and prints the bind address and port. Successful startup shows:
Starting SNMP Trap Handler...Listening for SNMP traps on 0.0.0.0:162 (memory limit 512MB)Accepted versions, community check and v3 users come from Network Services > SNMP Traps > Settings.Running in interactive mode...🔄 Starting event loop...Press Ctrl+C to stop...From V8.4.0 the handler no longer prints the community string. Which SNMP versions are accepted, the community check and the SNMPv3 users all come from the Settings tab in the UI, not from command-line flags.
Sending Test Traps
Section titled “Sending Test Traps”Verify trap reception by sending test SNMP traps to the handler:
# Install SNMP utilities if not presentsudo apt-get install snmp # Debian/Ubuntusudo dnf install net-snmp-utils # RHEL/CentOS
# Send SNMPv2c test trapsnmptrap -v2c -c public 127.0.0.1:162 "" 1.3.6.1.4.1.9.9.43.2.0.1 \ 1.3.6.1.4.1.9.9.43.1.1.1.0 s "Configuration changed by admin"
# Send SNMPv1 test trapsnmptrap -v1 -c public 127.0.0.1:162 \ 1.3.6.1.4.1.9.9.43 localhost 6 1 "" \ 1.3.6.1.4.1.9.9.43.1.1.1.0 s "Test trap message"
# Send SNMPv3 test trap (V8.4.0+). Add the user under Network Services > SNMP Traps > Settings# first and switch on Accept SNMPv3, using the same protocols and passwords.snmptrap -v3 -l authPriv -u rconfig-traps \ -a SHA-256 -A 'auth-password' -x AES -X 'priv-password' \ 127.0.0.1:162 "" 1.3.6.1.6.3.1.1.5.3 \ 1.3.6.1.2.1.2.2.1.1.7 i 7Verification: The trap handler displays received traps in the terminal. Example output:
=== SNMP TRAP RECEIVED ===Source: 127.0.0.1:44123Time: 2026-10-10 14:32:15Version: SNMP v2cSecurity: communityTrap oid: 1.3.6.1.4.1.9.9.43.2.0.1=========================A v3 trap shows Version: SNMP v3 and Security: user rconfig-traps (authPriv). If a trap is refused, for example a wrong password or community, the terminal prints Trap rejected or unparseable - see the SNMP trap logs. and the reason is on the Logs tab.
Port Forwarding Configuration
Section titled “Port Forwarding Configuration”To run the handler without root privileges while receiving on port 162:
# Configure iptables to forward 162 → 1162sudo iptables -t nat -A PREROUTING -p udp --dport 162 -j REDIRECT --to-port 1162
# Make forwarding persistent (RHEL/CentOS)sudo service iptables save
# Make forwarding persistent (Ubuntu/Debian)sudo apt-get install iptables-persistentsudo netfilter-persistent saveService Deployment with Supervisor
Section titled “Service Deployment with Supervisor”Interactive Setup (Recommended for First-Time Deployment)
Section titled “Interactive Setup (Recommended for First-Time Deployment)”The interactive management interface provides a guided workflow for service installation and configuration:
# Navigate to rConfig directorycd /var/www/html/rconfig8/current
# Launch interactive setupphp artisan rconfig:snmp-trap-supervisor
🔧 SNMP Trap Handler Supervisor Management
? What would you like to do? › - Use arrow-keys. Return to submit.❯ 📦 Install service (add to supervisor) 🗑️ Uninstall service (remove from supervisor) 📊 Check service status 🔄 Restart service ❌ ExitMenu Options:
- Install service: Configure and deploy trap handler as supervised process
- Uninstall service: Remove trap handler from Supervisor (stops and deletes configuration)
- Check service status: Display current operational status and statistics
- Restart service: Gracefully restart the handler (applies configuration changes)
- Exit: Close management interface
Basic Configuration Parameters
Section titled “Basic Configuration Parameters”When installing the service, configure essential operational parameters:
Host (Bind Address):
0.0.0.0- Listen on all network interfaces (default, most common)192.168.1.100- Listen on specific interface only127.0.0.1- Listen on localhost only (testing/debugging)
Port (UDP Listener):
162- Standard SNMP trap port (requires root or port forwarding)1162- Common alternative for unprivileged operation- Custom port matching your network device configuration
Community String:
- The v1/v2c community your devices send. Defaults to
public. - From V8.4.0 the installer only asks for it when no community is stored under Network Services → SNMP Traps → Settings. The handler copies it into that setting the first time it starts, and from then on you manage it in the UI.
- Once a community is stored, the installer skips this prompt and never prints the value.
Advanced Configuration Options
Section titled “Advanced Configuration Options”Select “Configure advanced settings” during installation to access:
Timeout (seconds):
- SNMP socket timeout for trap reception
- Default: 5 seconds
- Lower values: More responsive to network issues but may drop slow traps
- Higher values: More tolerant but may delay error detection
Base Path:
- rConfig installation directory
- Default:
/var/www/html/rconfig8/current - Only modify if using non-standard installation path
Supervisor Config Directory:
- Location for Supervisor configuration files
- Default:
/etc/supervisor/conf.d/ - Alternative:
/etc/supervisord.d/(RHEL/CentOS)
Command Line Service Management
Section titled “Command Line Service Management”Installation and Configuration
Section titled “Installation and Configuration”For automated deployment or scripted installation, use command-line options:
# Install with default settingsphp artisan rconfig:snmp-trap-supervisor install --force
# Install with custom basic settingsphp artisan rconfig:snmp-trap-supervisor install \ --host=192.168.1.100 \ --port=1162 \ --community=private \ --force
# Install with advanced configurationphp artisan rconfig:snmp-trap-supervisor install \ --host=0.0.0.0 \ --port=162 \ --community=network_monitor \ --timeout=10 \ --memory-limit=1024 \ --base-path=/opt/rconfig \ --supervisor-config-dir=/etc/supervisor/conf.d \ --forceParameter Reference:
--force: Overwrite existing configuration without prompting--host: IP address or hostname to bind to--port: UDP port for trap reception--community: Deprecated from V8.4.0. Only used to seed the community setting when none is stored; set it in the UI instead--timeout: Socket timeout in seconds--memory-limit: PHP memory limit in MB--base-path: rConfig installation directory--supervisor-config-dir: Supervisor configuration location
Service Control Operations
Section titled “Service Control Operations”# Check current service statusphp artisan rconfig:snmp-trap-supervisor status
# Restart the service (apply configuration changes)php artisan rconfig:snmp-trap-supervisor restart
# Uninstall the service (remove from Supervisor)php artisan rconfig:snmp-trap-supervisor uninstallDirect Supervisor Commands
Section titled “Direct Supervisor Commands”For fine-grained control, use Supervisor’s CLI directly:
# View all supervised processessupervisorctl status
# Check SNMP trap handler specificallysupervisorctl status rconfig-snmp-trap
# Start the servicesupervisorctl start rconfig-snmp-trap
# Stop the servicesupervisorctl stop rconfig-snmp-trap
# Restart the servicesupervisorctl restart rconfig-snmp-trap
# Reload Supervisor configuration (after manual edits)supervisorctl rereadsupervisorctl updateMonitoring and Operational Management
Section titled “Monitoring and Operational Management”Where Trap Data and Logs Go
Section titled “Where Trap Data and Logs Go”Trap data and handler logs are kept apart, so each place answers one question.
| Location | What it holds | Look here when |
|---|---|---|
SNMP Traps → Logs in the UI (snmp_trap_logs table) | One row per received trap: source IP, OID, varbinds, matched filter, resolved device, status and the actions that ran. Traps that match no filter are kept with status filtered_out, and packets that can’t be parsed are kept too. From V8.4.0, traps refused for a wrong community, a failed SNMPv3 check or a disabled version get one rejected row per source and reason each minute. | You want to know whether a trap arrived and what rConfig did with it |
storage/logs/snmp-trap-handler.log | The handler process itself: startup, listening address, a health line every 5 minutes, memory warnings, socket errors, shutdown and any PHP fatal error. Supervisor rotates it at 10 MB and keeps 3 old copies. | The handler won’t start, keeps restarting, or you want to confirm it is alive |
storage/logs/snmp-YYYY-MM-DD.log | Processing problems only: packets that couldn’t be parsed, traps with no OID, IP mapping auto-create failures, and a fallback copy of any trap the database couldn’t store. Rotated daily, 14 days kept. | A trap you expected is missing from the Logs page |
Trap log rows are removed by the Data Purge Tool (snmp_trap_logs, 90 days by default).
Following the Handler Log
Section titled “Following the Handler Log”# Stream handler outputsupervisorctl tail -f rconfig-snmp-trap
# Last 100 linessupervisorctl tail -100 rconfig-snmp-trap
# Or read the file directlytail -f /var/www/html/rconfig8/current/storage/logs/snmp-trap-handler.logA healthy handler looks like this:
[2026-10-08 14:00:01] INFO: Starting SNMP Trap Handler...[2026-10-08 14:00:01] INFO: Listening for SNMP traps on 0.0.0.0:162 (memory limit 512MB)[2026-10-08 14:00:01] INFO: Socket bound successfully. Waiting for SNMP traps...[2026-10-08 14:05:01] INFO: Health: up 0.08h, 42 traps (504/hour), memory 38MB, peak 40MB[2026-10-08 18:30:12] INFO: Received SIGTERM, SNMP Trap Handler stopped.Individual traps are not printed here. Check the Logs page in the UI for those.
Tracing Trap Processing
Section titled “Tracing Trap Processing”The daily snmp-*.log only records problems by default. To see every step for each trap (parsing, filter matching, device resolution), raise the log level in .env:
SNMP_LOG_LEVEL=debug# Optional: days of snmp-*.log files to keep (default 14)SNMP_LOG_DAYS=14Then clear the config cache and restart the handler and Horizon so both pick up the change:
php artisan config:clearsupervisorctl restart rconfig-snmp-trapphp artisan horizon:terminateService Status Verification
Section titled “Service Status Verification”Check comprehensive service status:
# Via rConfig command (proxies supervisorctl output)php artisan rconfig:snmp-trap-supervisor status
# Via Supervisor directlysupervisorctl status rconfig-snmp-trap
# Example output (both produce the same supervisorctl output):# rconfig-snmp-trap RUNNING pid 12345, uptime 2 days, 14:32:18Upgrading from Earlier Versions
Section titled “Upgrading from Earlier Versions”Before 8.4.0 the daemon printed nothing, so snmp-trap-handler.log and snmp-trap-handler-error.log were usually empty. Every trap was also copied into a single, never-rotated snmp.log. After upgrading:
-
Re-run the install with the same host, port and community you used originally. Check the current values on the
command=line ofsnmptrap_supervisor.iniin your Supervisor config directory first.Terminal window php artisan rconfig:snmp-trap-supervisor install --force \--host=0.0.0.0 --port=162 --community=public -
Optionally delete the old files, which are no longer written to:
Terminal window rm storage/logs/snmp.log storage/logs/snmp-trap-handler-error.log -
Run the database migrations, restart Horizon and rebuild the frontend so the new Settings tab appears:
Terminal window php artisan migratephp artisan horizon:terminatenpm run build
What changes for existing installs in 8.4.0:
- The community from your
--communityflag is copied into Network Services → SNMP Traps → Settings the first time the upgraded handler starts. Edit it there from now on. - Require Community is off after the upgrade, so v1/v2c traps keep arriving whatever community they carry, as they did before. Switch it on once your devices all send the stored community.
- SNMPv3 is off until you add a user and switch on Accept SNMPv3.
- The community string is no longer saved with new trap log rows. Rows from before the upgrade keep it until the Data Purge Tool removes them (90 days by default).
Testing and Validation
Section titled “Testing and Validation”Comprehensive Trap Reception Testing
Section titled “Comprehensive Trap Reception Testing”After service deployment, verify end-to-end trap reception and processing:
1. Service Verification:
# Confirm service is runningsupervisorctl status rconfig-snmp-trap
# Check port bindingsudo netstat -ulnp | grep -E '162|1162'2. Send Test SNMPv2c Trap:
snmptrap -v2c -c public <rconfig-server-ip>:162 "" 1.3.6.1.4.1.9.9.43.2.0.1 \ 1.3.6.1.4.1.9.9.43.1.1.1.0 s "Test: Configuration changed by admin" \ 1.3.6.1.4.1.9.9.43.1.1.2.0 s "Device: test-router-01" \ 1.3.6.1.4.1.9.9.43.1.1.3.0 i 13. Send Test SNMPv1 Trap:
snmptrap -v1 -c public <rconfig-server-ip>:162 \ 1.3.6.1.4.1.9.9.43 <source-device-ip> 6 1 "" \ 1.3.6.1.4.1.9.9.43.1.1.1.0 s "Test: Link state change" \ 1.3.6.1.4.1.9.9.43.1.1.2.0 s "Interface: GigabitEthernet0/1"4. Verify Reception in Logs:
# Real-time log monitoringsupervisorctl tail -f rconfig-snmp-trap
# Or check log filetail -20 /var/www/html/rconfig8/current/storage/logs/snmp-trap-handler.log5. Verify Database Storage (if trap storage enabled):
# Connect to rConfig databasemysql -u rconfig -p rconfig
# Query recent trapsSELECT id, timestamp_received, source_ip, trap_oid, processing_statusFROM snmp_trap_logsORDER BY timestamp_received DESCLIMIT 10;Production Deployment Checklist
Section titled “Production Deployment Checklist”Before deploying to production, verify:
Troubleshooting
Section titled “Troubleshooting”Service Won’t Start
Section titled “Service Won’t Start”Symptom: Service fails to start, shows “FATAL” or “BACKOFF” status in Supervisor.
Diagnostic Steps:
# Check Supervisor statussupervisorctl status rconfig-snmp-trap
# Review the handler log (startup errors and PHP fatals land here)supervisorctl tail rconfig-snmp-trap
# Check service configuration (/etc/supervisord.d/ on RHEL)cat /etc/supervisor/conf.d/snmptrap_supervisor.ini
# Test manual execution (no --daemon, so output is printed)cd /var/www/html/rconfig8/currentphp artisan rconfig:snmp-trap-handler --host=0.0.0.0 --port=1162Common Causes and Resolutions:
-
Invalid Base Path: Verify
--base-pathpoints to correct rConfig installationTerminal window # Correct path should contain artisan filels -la /var/www/html/rconfig8/current/artisan -
Port Already in Use: Another process bound to trap port
Terminal window # Identify conflicting processsudo netstat -ulnp | grep :162# Stop conflicting service or use different port -
Permission Issues: Handler lacks permission to bind port or write logs
Terminal window # Verify log directory permissionsls -la /var/www/html/rconfig8/current/storage/logs/# Fix permissions if neededsudo chown -R www-data:www-data /var/www/html/rconfig8/current/storage/ -
PHP Missing Extensions: Required SNMP or socket extensions not installed
Terminal window # Check for required extensionsphp -m | grep -E 'snmp|sockets'# Install if missing (Ubuntu/Debian)sudo apt-get install php-snmp# Install if missing (RHEL/CentOS)sudo dnf install php-snmp
Permission Denied on Port 162
Section titled “Permission Denied on Port 162”Symptom: Error message “Permission denied” or “Cannot bind to port 162” when starting service.
Cause: Port 162 is privileged (< 1024), requiring root access to bind.
Resolution Options:
Option 1 - Use Port Forwarding (Recommended):
# Forward 162 → 1162 with iptablessudo iptables -t nat -A PREROUTING -p udp --dport 162 -j REDIRECT --to-port 1162
# Configure handler for port 1162php artisan rconfig:snmp-trap-supervisor install --port=1162 --force
# Make forwarding persistentsudo apt-get install iptables-persistent # Ubuntu/Debiansudo netfilter-persistent saveOption 2 - Run as Root (Security Implications):
# Modify Supervisor config to run as rootsudo nano /etc/supervisor/conf.d/rconfig-snmp-trap.conf
# Change user directive:user=root
# Reload Supervisorsupervisorctl rereadsupervisorctl updateOption 3 - Reconfigure Devices:
# Use alternative port (no privilege issues)php artisan rconfig:snmp-trap-supervisor install --port=1162 --force
# Update device configurations to send traps to port 1162# Example Cisco config:# snmp-server host 192.168.1.100 traps version 2c public udp-port 1162Service Stops Unexpectedly
Section titled “Service Stops Unexpectedly”Symptom: Service shows “STOPPED” or “EXITED” status, no longer processing traps.
Diagnostic Steps:
# Check exit reasonsupervisorctl status rconfig-snmp-trap
# Review the handler log for crash detailssupervisorctl tail rconfig-snmp-trap
# Check system logssudo journalctl -u supervisor -n 50
# Review PHP error logstail -50 /var/www/html/rconfig8/current/storage/logs/laravel.logCommon Causes and Resolutions:
-
Memory Limit Exceeded: Handler exhausted allocated memory
Terminal window # Check memory warnings and health lines in the handler loggrep -i "memory" /var/www/html/rconfig8/current/storage/logs/snmp-trap-handler.log# Increase memory limitphp artisan rconfig:snmp-trap-supervisor install --memory-limit=1024 --forcesupervisorctl restart rconfig-snmp-trap -
PHP Fatal Error: Code exception or unhandled error
Terminal window # Review the handler log for stack tracestail -100 /var/www/html/rconfig8/current/storage/logs/snmp-trap-handler.log# Update rConfig if bug identified# Contact support with error details -
Database Connection Lost: MySQL connection timeout or failure
Terminal window # Verify database connectivitymysql -u rconfig -p -e "SELECT 1"# Check database configurationgrep DB_ /var/www/html/rconfig8/current/.env# Restart service after database recoverysupervisorctl restart rconfig-snmp-trap
No Traps Received
Section titled “No Traps Received”Symptom: Service running but no traps appear in logs or database.
Diagnostic Checklist:
# 1. Verify service is listeningsudo netstat -ulnp | grep -E '162|1162'# Should show: php ... listening on configured port
# 2. Test with local trapsnmptrap -v2c -c public 127.0.0.1:162 "" 1.3.6.1.6.3.1.1.5.1
# 3. Check firewall rulessudo iptables -L -n | grep -E '162|1162'sudo firewall-cmd --list-all # RHEL/CentOS
# 4. Look for rejected traps (V8.4.0+)# Open SNMP Traps > Logs in the UI and check for rows with status "rejected".# The reason under the badge says why: wrong community, wrong v3 password,# unknown v3 user or an SNMP version that is switched off.
# 5. Test from remote device# From network device or another host:snmptrap -v2c -c public <rconfig-ip>:162 "" 1.3.6.1.6.3.1.1.5.1
# 6. Verify network device trap configuration# Example verification for Cisco:# show running-config | include snmp-server hostResolution Path:
- If local trap received: Firewall or network device configuration issue
- If local trap NOT received: Handler configuration or port binding issue
- If traps show as
rejected: Fix the device or the setting named in the reason. See rejected traps for each reason - If firewall blocking: Add rule to allow UDP traffic on trap port
High CPU or Memory Usage
Section titled “High CPU or Memory Usage”Symptom: Trap handler consuming excessive system resources.
Diagnostic Steps:
# Monitor resource usagetop -p $(pgrep -f snmp-trap-handler)
# Check trap reception rategrep "Trap received" /var/www/html/rconfig8/current/storage/logs/snmp-trap-handler.log | wc -l
# Analyze trap sourcesgrep "Trap received from" /var/www/html/rconfig8/current/storage/logs/snmp-trap-handler.log | \ awk '{print $NF}' | sort | uniq -c | sort -rn | head -10Common Causes and Resolutions:
-
Trap Storm: Device sending excessive traps
Terminal window # Identify problematic device from log analysis# Temporarily block device traps while investigating# Add firewall rule to block specific sourcesudo iptables -I INPUT -p udp -s <problematic-device-ip> --dport 162 -j DROP# Investigate and resolve device issue# Remove block after resolution -
Memory Leak: Handler not releasing memory (potential bug)
Terminal window # Monitor memory growth over timewatch -n 5 'ps aux | grep snmp-trap-handler'# Implement periodic restart as workaround# Add to crontab:0 2 * * * /usr/bin/supervisorctl restart rconfig-snmp-trap# Report issue to rConfig support -
Complex Trap Processing: Large traps or heavy database operations
Terminal window # Optimize database if trap storage enabledmysql -u rconfig -p rconfig -e "OPTIMIZE TABLE snmp_traps;"# Consider archiving old trapsmysql -u rconfig -p rconfig -e "DELETE FROM snmp_traps WHERE received_at < DATE_SUB(NOW(), INTERVAL 90 DAY);"
Performance Optimization
Section titled “Performance Optimization”High-Volume Environments
Section titled “High-Volume Environments”For deployments receiving thousands of traps per minute:
Increase Memory Allocation:
php artisan rconfig:snmp-trap-supervisor install --memory-limit=2048 --forcesupervisorctl restart rconfig-snmp-trapOptimize Database for Trap Storage:
-- Add indexes for common queriesALTER TABLE snmp_traps ADD INDEX idx_received_at (received_at);ALTER TABLE snmp_traps ADD INDEX idx_source_ip (source_ip);ALTER TABLE snmp_traps ADD INDEX idx_trap_oid (trap_oid);
-- Implement table partitioning for large datasetsALTER TABLE snmp_traps PARTITION BY RANGE (YEAR(received_at)) ( PARTITION p2024 VALUES LESS THAN (2025), PARTITION p2025 VALUES LESS THAN (2026), PARTITION p_future VALUES LESS THAN MAXVALUE);Configure Connection Pooling:
# Edit .env for database optimizationnano /var/www/html/rconfig8/current/.env
# Add or modify:DB_CONNECTION_POOL_SIZE=20DB_PERSISTENT_CONNECTIONS=trueResource Monitoring
Section titled “Resource Monitoring”Implement continuous resource monitoring:
# Create monitoring scriptsudo nano /usr/local/bin/monitor-snmp-trap.sh
#!/bin/bash# Monitor SNMP Trap Handler resources
PID=$(pgrep -f snmp-trap-handler)if [ -z "$PID" ]; then echo "CRITICAL: SNMP Trap Handler not running" exit 2fi
CPU=$(ps -p $PID -o %cpu= | awk '{print int($1)}')MEM=$(ps -p $PID -o %mem= | awk '{print int($1)}')
echo "CPU: ${CPU}% | MEM: ${MEM}%"
if [ $CPU -gt 80 ]; then echo "WARNING: High CPU usage"fi
if [ $MEM -gt 50 ]; then echo "WARNING: High memory usage"fi
# Make executablesudo chmod +x /usr/local/bin/monitor-snmp-trap.sh
# Add to cron for periodic checks*/5 * * * * /usr/local/bin/monitor-snmp-trap.sh >> /var/log/snmp-trap-monitor.logBest Practices
Section titled “Best Practices”Security Hardening
Section titled “Security Hardening”Prefer SNMPv3 (V8.4.0+): v1/v2c communities travel in clear text, so anyone on the path can read and replay them. SNMPv3 signs every trap and can encrypt it. Add a user under Network Services → SNMP Traps → Settings, switch on Accept SNMPv3, and once your devices have moved over, switch off Accept SNMPv1/v2c.
Require the community for v1/v2c: Where devices can only send v2c, store a long, unique community in the same tab and switch on Require Community. Traps carrying any other community are then rejected. Generate one with:
openssl rand -base64 24Restrict Bind Address: Limit trap reception to specific network interfaces:
# Listen only on management network interfacephp artisan rconfig:snmp-trap-supervisor install \ --host=192.168.100.10 \ --forceImplement Source Filtering: Configure firewall to accept traps only from known devices:
# Create chain for SNMP trap filteringsudo iptables -N SNMP_TRAP_FILTER
# Allow traps from known network rangessudo iptables -A SNMP_TRAP_FILTER -s 10.0.0.0/8 -j ACCEPTsudo iptables -A SNMP_TRAP_FILTER -s 192.168.0.0/16 -j ACCEPT
# Drop all other trap sourcessudo iptables -A SNMP_TRAP_FILTER -j DROP
# Apply filter to trap portsudo iptables -A INPUT -p udp --dport 162 -j SNMP_TRAP_FILTEROperational Excellence
Section titled “Operational Excellence”Implement Monitoring and Alerts: Use monitoring tools (e.g., Nagios, Zabbix) to track service health and receive alerts on failures. Regularly Review Logs: Schedule periodic log reviews to identify anomalies or unusual trap patterns. Backup Configuration: Regularly back up rConfig and Supervisor configurations to prevent data loss. Test Disaster Recovery: Periodically test recovery procedures to ensure rapid restoration of service in case of failure.
What’s next
Section titled “What’s next”- SNMP Traps UI and Administration - Configure trap filters, device resolution mappings, and view the trap log dashboard
- SNMP Traps Concepts - Background on how SNMP trap handling integrates with rConfig workflows
- Configuration Backups - Set up the automated backups that trap-driven filters can trigger