2222 feat integrate snmp checker into agent #2671
No reviewers
Labels
No labels
1week
2weeks
Failed compliance check
IP cameras
NATS
Possible security concern
Review effort 1/5
Review effort 2/5
Review effort 3/5
Review effort 4/5
Review effort 5/5
UI
aardvark
accessibility
amd64
api
arm64
auth
back-end
bgp
blog
bug
build
checkers
ci-cd
cleanup
cnpg
codex
core
dependencies
device-management
documentation
duplicate
dusk
ebpf
enhancement
eta 1d
eta 1hr
eta 3d
eta 3hr
feature
fieldsurvey
github_actions
go
good first issue
help wanted
invalid
javascript
k8s
log-collector
mapper
mtr
needs-triage
netflow
network-sweep
observability
oracle
otel
plug-in
proton
python
question
reddit
redhat
research
rperf
rperf-checker
rust
sdk
security
serviceradar-agent
serviceradar-agent-gateway
serviceradar-web
serviceradar-web-ng
siem
snmp
sysmon
topology
ubiquiti
wasm
wontfix
zen-engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
carverauto/serviceradar!2671
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2671/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from GitHub pull request.
Original GitHub pull request: #2300
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2300
Original created: 2026-01-14T17:56:31Z
Original updated: 2026-01-14T18:14:44Z
Original head: carverauto/serviceradar:2222-feat-integrate-snmp-checker-into-agent
Original base: staging
Original merged: 2026-01-14T18:14:35Z by @mfreeman451
User description
IMPORTANT: Please sign the Developer Certificate of Origin
Thank you for your contribution to ServiceRadar. Please note, when contributing, the developer must include
a DCO sign-off statement indicating the DCO acceptance in one commit message. Here
is an example DCO Signed-off-by line in a commit message:
Describe your changes
Issue ticket number and link
Code checklist before requesting a review
PR Type
Enhancement, Tests
Description
Integrates comprehensive SNMP monitoring capabilities into the ServiceRadar agent with full control plane support
Implements SNMP profile management system with support for SNMPv1, v2c, and v3 authentication protocols
Adds SRQL-based device targeting for dynamic profile assignment with priority-based resolution
Provides built-in OID templates organized by vendor (Standard, Cisco, Juniper, Arista) for common monitoring scenarios
Implements encrypted credential storage for SNMP community strings and SNMPv3 passwords using AES-256-GCM
Adds comprehensive LiveView UI for SNMP profile configuration with visual query builder and template browser
Implements agent-side SNMP service with support for local file, cache, and remote proto config sources
Includes extensive test coverage for profile management, config distribution, agent service, and integration scenarios
Extends protocol buffers with SNMP message types and enums for agent configuration delivery
Adds SNMP configuration routes and navigation menu items to web UI
Diagram Walkthrough
File Walkthrough
21 files
index.ex
SNMP Profiles LiveView with Query Builder and Template Managementweb-ng/lib/serviceradar_web_ng_web/live/settings/snmp_profiles_live/index.ex
2979 lines of new code
with SRQL-based device targeting
testing, and OID template browser
credential storage
builtin_templates.ex
Built-in SNMP OID templates for vendor-specific monitoringelixir/serviceradar_core/lib/serviceradar/snmp_profiles/builtin_templates.ex
organized by vendor (Standard, Cisco, Juniper, Arista)
seed templates into the database
info, interfaces, CPU, memory, environment sensors, BGP, etc.)
classification for seeding operations
snmp_profile.ex
SNMP profile resource with targeting and default managementelixir/serviceradar_core/lib/serviceradar/snmp_profiles/snmp_profile.ex
SNMPProfileAsh resource for managing reusable SNMPmonitoring configurations
retries, and SRQL-based device targeting
listing targeting profiles ordered by priority
allowing read access to all users
snmp_target.ex
SNMP target configuration with multi-version authenticationelixir/serviceradar_core/lib/serviceradar/snmp_profiles/snmp_target.ex
SNMPTargetAsh resource representing individual networkdevices to poll via SNMP
storage
community strings and v3 passwords
policies
snmp_oid_config.ex
OID configuration resource with data type and scaling supportelixir/serviceradar_core/lib/serviceradar/snmp_profiles/snmp_oid_config.ex
SNMPOIDConfigAsh resource for individual OID pollingconfigurations
float, timeticks) with scaling and delta calculation
snmp_oid_template.ex
Reusable OID template definitions with vendor organizationelixir/serviceradar_core/lib/serviceradar/snmp_profiles/snmp_oid_template.ex
SNMPOIDTemplateAsh resource for reusable OID templatedefinitions
organized by vendor and category
validation
srql_target_resolver.ex
SRQL-based profile targeting with device matchingelixir/serviceradar_core/lib/serviceradar/snmp_profiles/srql_target_resolver.ex
attacks
both device and interface targeting
match
snmp_compiler.ex
SNMP configuration compiler with profile resolutionelixir/serviceradar_core/lib/serviceradar/agent_config/compilers/snmp_compiler.ex
SNMPCompilermodule for transforming SNMP profiles intoagent-consumable configuration
profile
decryption for v1/v2c and v3 authentication
protocols for agent consumption
validate_srql_query.ex
SRQL query validation for profile targetingelixir/serviceradar_core/lib/serviceradar/snmp_profiles/changes/validate_srql_query.ex
target_queryattributes in SNMPprofiles
in:devicesprefix when needed, supportingboth device and interface targeting
invalid queries
set_as_default.ex
Default profile enforcement with automatic unsetelixir/serviceradar_core/lib/serviceradar/snmp_profiles/changes/set_as_default.ex
tenant
one
consistency
compiler.ex
Compiler registry update for SNMP supportelixir/serviceradar_core/lib/serviceradar/agent_config/compiler.ex
:snmpto theconfig_typeunion type definitionSNMPCompilerin the compiler registry mappingencrypt_credentials.ex
SNMP credential encryption change for Ash resourceselixir/serviceradar_core/lib/serviceradar/snmp_profiles/changes/encrypt_credentials.ex
storage
community,auth_password, andpriv_passwordfieldsstorage
user-friendly messages
encrypt_passwords.ex
SNMPv3 password encryption change for Ash resourceselixir/serviceradar_core/lib/serviceradar/snmp_profiles/changes/encrypt_passwords.ex
and privacy passwords
auth_passwordandpriv_passwordvirtualattributes
_encryptedfieldsmessages
snmp_profiles.ex
SNMP profiles domain configuration moduleelixir/serviceradar_core/lib/serviceradar/snmp_profiles.ex
SNMPProfile,SNMPTarget,SNMPOIDConfig,SNMPOIDTemplatesettings
router.ex
SNMP profile configuration routesweb-ng/lib/serviceradar_web_ng_web/router.ex
settings_components.ex
SNMP settings navigation menu itemweb-ng/lib/serviceradar_web_ng_web/components/settings_components.ex
/settings/snmpwith active state detectionmonitoring.pb.go
SNMP protocol buffer definitions and message typesproto/monitoring.pb.go
SNMPVersion,SNMPSecurityLevel,SNMPAuthProtocol,SNMPPrivProtocol,SNMPDataTypeSNMPConfig,SNMPTargetConfig,SNMPv3Auth,SNMPOIDConfigAgentConfigResponsewithsnmp_configfield for SNMPconfiguration delivery
snmp_service.go
SNMP agent service implementationpkg/agent/snmp_service.go
monitoring
refresh loops
change detection
application with factory pattern
client.go
SNMPv3 client implementation and protocol conversionpkg/checker/snmp/client.go
and privacy protocols
server.go
SNMP service integration into agent serverpkg/agent/server.go
initSNMPServicemethod to create and start SNMP serviceGetSNMPStatusmethod for status reportingtypes.go
SNMPv3 type definitions and authentication structurespkg/checker/snmp/types.go
SecurityLevel,AuthProtocol,PrivProtocolenumsV3Authstruct for SNMPv3 authentication parameters withsensitive field tags
Targetstruct with optionalV3Authfield for SNMPv3 support7 files
snmp_config_distribution_integration_test.exs
SNMP Config Distribution Integration Testselixir/serviceradar_core/test/serviceradar/edge/snmp_config_distribution_integration_test.exs
distribution from control plane to agent
config generation
definitions
snmp_profile_test.exs
SNMPProfile resource tests with CRUD validationelixir/serviceradar_core/test/serviceradar/snmp_profiles/snmp_profile_test.exs
actions
parameters
set_as_defaultaction ensuring only one default profile existssrql_target_resolver_test.exs
SRQL target resolver tests with device matchingelixir/serviceradar_core/test/serviceradar/snmp_profiles/srql_target_resolver_test.exs
UUIDs
resolution
snmp_compiler_test.exs
SNMPCompiler tests with profile and credential handlingelixir/serviceradar_core/test/serviceradar/snmp_profiles/snmp_compiler_test.exs
config type
v3 authentication
snmp_integration_test.go
SNMP agent service integration testspkg/agent/snmp_integration_test.go
lines)
updates
reloading
updates
testing.go
SNMP testing utilities and mock factoriespkg/checker/snmp/testing.go
noopCollector,noopAggregator, and factory implementationsNewMockServiceForTestinghelper for creating testable SNMPservices
checker_integration_test.go
ICMP checker test updates for new APIpkg/agent/checker_integration_test.go
NewICMPCheckerfactory functioninitialization
validation
4 files
config.exs
Register SNMPProfiles Domain in Ash Configurationweb-ng/config/config.exs
ServiceRadar.SNMPProfilesdomain in both web-ng andserviceradar_core Ash configurations
initialization
20260114074955_add_snmp_profiles.exs
Database schema for SNMP and system monitoring profileselixir/serviceradar_core/priv/repo/tenant_migrations/20260114074955_add_snmp_profiles.exs
snmp_profiles,snmp_targets,snmp_oid_configs,snmp_oid_templatessysmon_profilestable for system monitoring profiles with similartargeting capabilities
constraints per tenant
config_sourcecolumn toocsf_agentstable for trackingconfiguration origin
config.exs
Configuration update for SNMP profiles domainelixir/serviceradar_core/config/config.exs
ServiceRadar.SNMPProfilesto the list of domains for Ash resourcediscovery
test.exs
SNMP profiles domain test configurationelixir/serviceradar_core/config/test.exs
ServiceRadar.SNMPProfilesto the list of domains in testconfiguration
3 files
index.ex
Whitespace formatting adjustmentweb-ng/lib/serviceradar_web_ng_web/live/settings/networks_live/index.ex
index.ex
Code formatting improvementsweb-ng/lib/serviceradar_web_ng_web/live/log_live/index.ex
index.ex
Code formatting improvementweb-ng/lib/serviceradar_web_ng_web/live/analytics_live/index.ex
18 files
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2300#issuecomment-3750886011
Original created: 2026-01-14T17:57:45Z
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
Sensitive data exposure
Description: The compiler decrypts SNMP community strings and SNMPv3 auth/priv passwords and embeds
them into the generated agent configuration payload (e.g.,
community,v3_auth.auth_password,v3_auth.priv_password), which could expose credentials if theconfig distribution/storage/logging/transport path is not strictly protected end-to-end. snmp_compiler.ex [186-209]
Referred Code
🎫 #2222
snmp-checkerfunctionality intoserviceradar-agentso theagent no longer needs to talk to an external SNMP checker over gRPC, reducing the number
of components users must install.
Codebase context is not defined
Follow the guide to enable codebase context checks.
Generic: Meaningful Naming and Self-Documenting Code
Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting
Status: Passed
Generic: Robust Error Handling and Edge Case Management
Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation
Status:
Silent decryption failure: Credential decryption errors are silently swallowed by returning
nil(and query readerrors return empty lists), which can mask production failures without actionable context
or logs.
Referred Code
Generic: Secure Error Handling
Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.
Status:
Raw exception returned: The compiler rescues and returns the raw exception term in
{:error, {:compilation_error,e}}, which risks exposing internal implementation details to callers if propagated touser-facing layers.
Referred Code
Generic: Secure Logging Practices
Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.
Status:
Logs full exception: The error log writes
inspect(e)for compilation failures, which can inadvertently includesensitive data embedded in exception structs (e.g., config/changeset contents).
Referred Code
Generic: Comprehensive Audit Trails
Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.
Status:
Audit logging unclear: The PR adds sensitive configuration creation/seed operations (e.g.,
seed!/2) but noexplicit audit logging is visible in the diff, so it’s unclear whether critical actions
are recorded with actor context and outcome.
Referred Code
Generic: Security-First Input Validation and Data Handling
Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities
Status:
SRQL handling review: Although
device_uidis UUID-validated to reduce SRQL injection risk, the overall SRQLparsing/execution and tag filtering via SQL fragments requires a full security review
beyond the visible diff to confirm sanitization and authorization guarantees end-to-end.
Referred Code
Compliance status legend
🟢 - Fully Compliant🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2300#issuecomment-3750891616
Original created: 2026-01-14T17:59:00Z
PR Code Suggestions ✨
Explore these optional code suggestions:
Use correct relationship management type
In the
createaction, change themanage_relationshiptype from:appendto:replaceto correctly handle thebelongs_toassociation.elixir/serviceradar_core/lib/serviceradar/snmp_profiles/snmp_oid_config.ex [66-79]
Suggestion importance[1-10]: 9
__
Why: The suggestion correctly identifies a bug where an incorrect relationship management type (
:append) is used for abelongs_torelationship, which would cause creation to fail.Replace undefined min usage
Replace the call to the undefined
minfunction with an explicit length check toprevent a compilation error when slicing a hash string.
pkg/agent/snmp_service.go [209-213]
Suggestion importance[1-10]: 9
__
Why: The suggestion correctly points out the use of an undefined
minfunction, which would cause a compilation error, and provides a valid fix.Fix race condition in stop logic
Fix a race condition in the
Stopfunction by adjusting the mutex locking toensure safe concurrent access to shared state.
pkg/agent/snmp_service.go [221-261]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 8
__
Why: The suggestion correctly identifies a race condition in the
Stopfunction where the mutex is unlocked prematurely, potentially leading to concurrent access issues.Use specific error for uniqueness check
Refine error classification by matching on the specific
Ash.Error.Changes.Uniqueerror for uniqueness violations, instead of the generic
Ash.Error.Changes.InvalidChanges.elixir/serviceradar_core/lib/serviceradar/snmp_profiles/builtin_templates.ex [108-111]
Suggestion importance[1-10]: 7
__
Why: This suggestion correctly identifies a bug where any invalid change error would be misclassified as a uniqueness violation, improving the accuracy of error handling during template seeding.
Log error on credential decryption failure
Log an error when credential decryption fails to improve debuggability, as it
currently fails silently.
elixir/serviceradar_core/lib/serviceradar/agent_config/compilers/snmp_compiler.ex [214-219]
Suggestion importance[1-10]: 6
__
Why: The suggestion correctly points out that silent credential decryption failures are problematic for debugging. Adding logging significantly improves observability without changing the function's core behavior.
Use dynamic community string
Refactor
build_snmp_get_requestto accept a dynamic community string from theform. This involves computing packet lengths dynamically to ensure the SNMP
connection test uses the user-provided credentials.
web-ng/lib/serviceradar_web_ng_web/live/settings/snmp_profiles_live/index.ex [1049-1103]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 8
__
Why: The suggestion correctly identifies that the "Test Connection" feature is flawed because it uses a hard-coded "public" community string instead of the one provided by the user, making the test less useful. Implementing this would significantly improve the feature's correctness and utility.
Use dynamic module name in logs
Replace the hard-coded module name in the log message with the
MODULEmacrofor better maintainability.
elixir/serviceradar_core/lib/serviceradar/snmp_profiles/srql_target_resolver.ex [77]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 3
__
Why: This is a good code style and maintainability suggestion, as using
__MODULE__makes the log message more robust to future refactoring of the module name.Improve UUID validation to be more flexible
Update the UUID validation regex to optionally match hyphens, allowing for both
hyphenated and non-hyphenated UUID formats.
elixir/serviceradar_core/lib/serviceradar/snmp_profiles/srql_target_resolver.ex [38-39]
Suggestion importance[1-10]: 2
__
Why: While technically correct that UUIDs can be represented without hyphens, the
device_uidis consistently generated with hyphens throughout the codebase, making this change a minor improvement for a currently non-existent edge case.