Commit Graph

8 Commits

Author SHA1 Message Date
Jason Staack
d3ad0f7013 fix(poller): fall back to generic-snmp when device has no profile assigned
SNMP devices added without a profile (e.g., via simplified add flow)
were failing with "no SNMP profile assigned". Now falls back to the
generic-snmp profile which collects standard MIB-II metrics.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 08:41:35 -05:00
Jason Staack
9480ba9e3f feat(18-03): implement SNMPCollector.Collect with profile-driven polling
- SNMPCollector implements poller.Collector interface
- Profile-driven OID collection: scalars via Get, tables via Walk/BulkWalk
- BulkWalk wrapped in withTimeout to prevent indefinite hangs
- SNMPv1 uses Walk, v2c/v3 uses BulkWalk (MaxRepetitions=10)
- Safety valve: walkTable aborts at 10,000 PDUs per walk
- Counter delta computation via CounterCache for rate metrics
- Standard metrics routed to DeviceMetricsEvent (interfaces, health)
- Custom metrics routed to SNMPMetricsEvent (snmp_custom)
- DeviceStatusEvent published with online/offline status
- Each poll group collects independently (partial failure tolerant)
- Credential resolution via GetRawCredentials + ParseSNMPCredentials
- ifXTable Counter64 data supersedes ifTable Counter32 via PreferOver
- ssCpuIdle invert_percent transform for CPU load fallback

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 19:28:28 -05:00
Jason Staack
590b1c8d4d test(18-03): add failing tests for SNMPCollector interface and edge cases
- Compile-time Collector interface assertion
- Collect returns error with nil SNMPProfileID
- Collect returns error with unknown profile ID
- NewSNMPCollector returns initialized struct

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 19:26:23 -05:00
Jason Staack
2aaccb77be feat(18-03): add OID result mappers for standard and custom metrics
- mapInterfaceMetrics: ifTable/ifXTable to InterfaceStats with Counter64 preference
- mapHealthMetrics: hrProcessorLoad/ssCpuIdle + hrStorageTable to HealthMetrics
- mapCustomMetrics: generic scalar/table results to SNMPMetricEntry
- mapDeviceStatus: sysDescr/sysUptime to DeviceStatusEvent fields
- pduToUint64, pduToString, extractIndex, formatUptime helpers

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 19:25:55 -05:00
Jason Staack
8d3952e92d feat(18-02): implement ProfileCache with JSONB compilation and sysObjectID matching
- compileProfileData parses JSONB profile_data into typed CompiledProfile structs
- ProfileCache.Get provides O(1) lookup by profile UUID
- MatchSysObjectID uses longest-prefix-first matching with generic-snmp fallback
- StartRefresh runs background goroutine with configurable interval (default 5min)
- Load atomically replaces in-memory cache under write lock
- counter.go created as blocking prerequisite (Rule 3 deviation from 18-01)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 19:21:39 -05:00
Jason Staack
0697563a13 feat(18-01): add counter cache with Redis delta computation and SNMPMetricsEvent
- Implement computeCounterDelta for Counter32/Counter64 with wraparound handling
- Sanity threshold discards deltas > 90% of max value (device reset detection)
- CounterCache uses Redis MGET/MSET pipelining for efficient state persistence
- Counter keys use "snmp:counter:{device_id}:{oid}" format with 600s TTL
- Add SNMPMetricsEvent and SNMPMetricEntry structs to bus package
- Add PublishSNMPMetrics publishing to "device.metrics.snmp_custom.{device_id}"
- Full test coverage: 10 counter tests including miniredis integration

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 19:21:25 -05:00
Jason Staack
cec0a8c6d4 test(18-02): add failing tests for ProfileCache and compileProfileData
- 11 test cases covering JSONB compilation, prefix matching, fallback
- Tests reference compileProfileData, ProfileCache, sysOIDEntry (not yet implemented)
- types.go created with CompiledProfile, PollGroup, ScalarOID, TableOID, ColumnOID

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 19:18:50 -05:00
Jason Staack
9458dadc90 feat(18-01): add gosnmp dependency, SNMP types, and client builder
- Install gosnmp v1.43.2 as direct dependency
- Create snmp package with SNMPConfig, CompiledProfile, PollGroup types
- Implement BuildSNMPClient for v1, v2c, and v3 (all security levels)
- Map auth protocols (MD5, SHA, SHA224-512) and priv protocols (DES, AES128-256)
- MaxRepetitions set to 10 (not gosnmp default 50) for embedded devices
- Full test coverage: 9 tests covering all SNMP versions and protocol mappings

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 19:18:37 -05:00