Enhance SNMP monitoring with full agent implementation - #19
Closed
NickBorgers wants to merge 4 commits into
Closed
Conversation
## Major Enhancements ### 1. Complete SNMP Agent Server - Implemented full SNMP v2c agent responding to GET, GETNEXT, and GETBULK requests - Proper OID tree structure with hierarchical organization - Support for general statistics, per-site statistics, and recent test results - Community string authentication ### 2. OID Tree Structure - **Branch 1 (.1.3.6.1.4.1.99999.1)**: General statistics (cache size, monitored sites, totals) - **Branch 2 (.1.3.6.1.4.1.99999.2)**: Per-site statistics table (tests, success/failure, timing metrics) - **Branch 3 (.1.3.6.1.4.1.99999.3)**: Recent test results table (last N tests with details) ### 3. SNMP Traps - Automatic trap sending for test failures - Service degradation traps when failure rate exceeds 50% - Configurable trap destinations (future feature, groundwork laid) ### 4. HTTP API for SNMP Data - `/snmp/data` - JSON representation of all SNMP metrics - `/snmp/mib` - Text format MIB definition - `/snmp/oids` - List of all available OIDs - Runs on SNMP_PORT + 1 (default 162) ### 5. Formal MIB Definition - Complete INTERNET-CONNECTION-MONITOR-MIB.txt following SNMPv2-SMI standards - Includes MODULE-IDENTITY, OBJECT-TYPE, and NOTIFICATION-TYPE definitions - Table structures for site statistics and recent tests - Conformance information with object groups ### 6. Comprehensive Testing - Unit tests for SNMP module (OID comparison, sorting, data export, statistics) - Integration tests for HTTP API endpoints - Tests for cache circular buffer behavior - Tests for GetSNMPData and MIB export functionality ### 7. Documentation - New SNMP_GUIDE.md with: - Configuration examples - OID reference tables - Usage examples (snmpget, snmpwalk, HTTP API) - Zabbix integration guide - Troubleshooting section - Security best practices - Updated README.md to highlight SNMP features - Updated TESTING.md to reflect SNMP test coverage ## Technical Details ### Implementation Changes - `internal/outputs/snmp.go`: - Replaced placeholder runSNMPAgent with full UDP server - Added OID tree initialization and handlers - Implemented SNMP packet processing (unmarshal, handle, marshal, respond) - Added HTTP server for easier debugging and testing - Implemented trap functionality with proper PDU construction - Enhanced Write() to send traps on failures ### New Files - `INTERNET-CONNECTION-MONITOR-MIB.txt`: Formal MIB definition - `SNMP_GUIDE.md`: Comprehensive SNMP setup and usage guide - `internal/outputs/snmp_test.go`: Unit tests for SNMP functionality ### Modified Files - `README.md`: Added SNMP features and documentation link - `TESTING.md`: Updated to reflect SNMP test coverage - `test-integration.sh`: Added SNMP HTTP API integration tests - `go.mod`: Temporarily set to Go 1.24 for build compatibility ## Breaking Changes None - SNMP is enabled by default but backwards compatible ## Configuration All configuration via environment variables: - `SNMP_ENABLED` (default: true) - `SNMP_PORT` (default: 161) - `SNMP_COMMUNITY` (default: public) - `SNMP_LISTEN_ADDRESS` (default: 0.0.0.0) - `SNMP_ENTERPRISE_OID` (default: .1.3.6.1.4.1.99999) ## Future Enhancements - SNMPv3 with authentication and encryption - Configurable trap destinations via environment variables - SNMP protocol integration tests (requires snmp client tools) - Custom OID registration with IANA 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The dependency github.com/go-json-experiment/json requires Go 1.25. This was temporarily changed to 1.24 for local build testing but needs to be 1.25 for CI/CD pipeline. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The handleOIDListRequest function was acquiring s.mu.RLock() and then calling s.getAllOIDs(), which also acquires the same lock. This caused a deadlock because RWMutex.RLock() is not reentrant in Go. Fixed by removing the lock from handleOIDListRequest since getAllOIDs() already handles its own locking internally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The custom recursive contains() function was inefficient and potentially problematic. Replaced with the standard library strings.Contains() which is faster and more reliable. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
NickBorgers
deleted the
claude/enhance-snmp-monitor-011CV2b3XeAzdtne85thkDDJ
branch
November 11, 2025 22:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Major Enhancements
1. Complete SNMP Agent Server
2. OID Tree Structure
3. SNMP Traps
4. HTTP API for SNMP Data
/snmp/data- JSON representation of all SNMP metrics/snmp/mib- Text format MIB definition/snmp/oids- List of all available OIDs5. Formal MIB Definition
6. Comprehensive Testing
7. Documentation
Technical Details
Implementation Changes
internal/outputs/snmp.go:New Files
INTERNET-CONNECTION-MONITOR-MIB.txt: Formal MIB definitionSNMP_GUIDE.md: Comprehensive SNMP setup and usage guideinternal/outputs/snmp_test.go: Unit tests for SNMP functionalityModified Files
README.md: Added SNMP features and documentation linkTESTING.md: Updated to reflect SNMP test coveragetest-integration.sh: Added SNMP HTTP API integration testsgo.mod: Temporarily set to Go 1.24 for build compatibilityBreaking Changes
None - SNMP is enabled by default but backwards compatible
Configuration
All configuration via environment variables:
SNMP_ENABLED(default: true)SNMP_PORT(default: 161)SNMP_COMMUNITY(default: public)SNMP_LISTEN_ADDRESS(default: 0.0.0.0)SNMP_ENTERPRISE_OID(default: .1.3.6.1.4.1.99999)Future Enhancements
🤖 Generated with Claude Code