2222 feat integrate snmp checker into agent #2669
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!2669
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2669/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: #2298
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2298
Original created: 2026-01-14T17:26:03Z
Original updated: 2026-01-14T17:56:14Z
Original head: carverauto/serviceradar:2222-feat-integrate-snmp-checker-into-agent
Original base: staging
Original merged: 2026-01-14T17:56:04Z 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 SNMP checker into the ServiceRadar agent with comprehensive configuration management and dynamic profile targeting
Implements SNMP profiles domain with four Ash resources (
SNMPProfile,SNMPTarget,SNMPOIDConfig,SNMPOIDTemplate) supporting SNMPv1/v2c/v3 authenticationAdds SRQL-based device targeting for dynamic profile resolution with priority-based selection and default profile fallback
Provides 342 built-in OID templates organized by vendor (Standard, Cisco, Juniper, Arista) with template management and customization
Implements
SNMPCompilerfor transforming SNMP profiles into agent-consumable configuration with credential decryptionAdds embedded SNMP agent service with dynamic configuration loading, hot-reload capability, and status reporting
Extends protobuf definitions with SNMP configuration messages and enums for agent communication
Includes comprehensive LiveView UI for SNMP profiles management with CRUD operations, device targeting via query builder, and OID template browser
Adds encrypted credential storage for SNMP targets using AES-256-GCM encryption
Provides extensive test coverage including integration tests for config distribution, profile targeting, and agent service functionality
Includes database migration for SNMP infrastructure tables with proper foreign key relationships and constraints
Diagram Walkthrough
File Walkthrough
22 files
index.ex
SNMP Profiles LiveView with targeting and OID managementweb-ng/lib/serviceradar_web_ng_web/live/settings/snmp_profiles_live/index.ex
profile CRUD operations, device targeting via SRQL query builder, and
OID template management
SNMPv1/v2c/v3 authentication and connection testing via UDP
reachability checks
and custom templates, with ability to copy and customize templates
real-time device count preview and filter management
compiler.ex
Register SNMP compiler in agent config systemelixir/serviceradar_core/lib/serviceradar/agent_config/compiler.ex
snmpto theconfig_typetype definitionSNMPCompilerin the compilers registry for SNMPconfiguration compilation
settings_components.ex
Add SNMP settings navigation menu itemweb-ng/lib/serviceradar_web_ng_web/components/settings_components.ex
/settings/snmppath with active state detectionbuiltin_templates.ex
Built-in SNMP OID templates for vendor-specific monitoringelixir/serviceradar_core/lib/serviceradar/snmp_profiles/builtin_templates.ex
vendor (Standard, Cisco, Juniper, Arista)
all(),all_templates(),vendors(),for_vendor(), andseed!()(system info, interfaces, CPU, memory, BGP, environment sensors)
duplicate detection
snmp_profile.ex
SNMP profile resource with SRQL-based device targetingelixir/serviceradar_core/lib/serviceradar/snmp_profiles/snmp_profile.ex
multitenancy support
poll_interval,timeout,retries), device targeting via SRQL queries, and priority-basedresolution
set_as_default,get_default,list_targeting_profilesfor profile managementchecks, default profile protection on deletion
snmp_target.ex
SNMP target configuration with multi-version authentication supportelixir/serviceradar_core/lib/serviceradar/snmp_profiles/snmp_target.ex
devices) within a profile
storage via
EncryptCredentialschangeparameters (username, security level, auth/priv protocols)
snmp_oid_config.ex
OID configuration resource for SNMP data collectionelixir/serviceradar_core/lib/serviceradar/snmp_profiles/snmp_oid_config.ex
boolean, etc.), scale factor, and delta calculation flag
create_bulkactionsnmp_oid_template.ex
Reusable OID template definitions with vendor categorizationelixir/serviceradar_core/lib/serviceradar/snmp_profiles/snmp_oid_template.ex
vendor and category
is_builtinflaglist_by_vendor,list_custom,list_builtinfor template filtering
per vendor/tenant
srql_target_resolver.ex
SRQL query evaluation for dynamic profile targetingelixir/serviceradar_core/lib/serviceradar/snmp_profiles/srql_target_resolver.ex
SNMP profiles
attacks
target_queryfields on profiles to determine which profileapplies to a device
resolution (highest priority first)
snmp_compiler.ex
SNMP configuration compiler for agent consumptionelixir/serviceradar_core/lib/serviceradar/agent_config/compilers/snmp_compiler.ex
ServiceRadar.AgentConfig.Compilerbehaviour for SNMP configuration
credential decryption and version formatting
priority) then default profile fallback
compile/4,validate/1,disabled_config/0, andresolve_profile/4functionsvalidate_srql_query.ex
SRQL query validation change for profile targetingelixir/serviceradar_core/lib/serviceradar/snmp_profiles/changes/validate_srql_query.ex
target_queryattribute is valid SRQLsyntax
in:devicesprefix if noin:prefix existsset_as_default.ex
Default profile enforcement change for SNMP profileselixir/serviceradar_core/lib/serviceradar/snmp_profiles/changes/set_as_default.ex
tenant
via
unset_defaultactiontenant_)encrypt_credentials.ex
SNMP credential encryption change for Ash resourceselixir/serviceradar_core/lib/serviceradar/snmp_profiles/changes/encrypt_credentials.ex
storage using Cloak/AES-256-GCM
community,auth_password, andpriv_passwordarguments and encrypts them to
_encryptedfieldsbe read back in plaintext
messages
encrypt_passwords.ex
SNMPv3 password encryption change moduleelixir/serviceradar_core/lib/serviceradar/snmp_profiles/changes/encrypt_passwords.ex
and privacy passwords
auth_passwordandpriv_passwordvirtual attributesto encrypted storage fields
error handling for encryption failures
snmp_profiles.ex
SNMP profiles domain with resource registrationelixir/serviceradar_core/lib/serviceradar/snmp_profiles.ex
SNMPProfile,SNMPTarget,SNMPOIDConfig,SNMPOIDTemplatedefault authorization enabled
SysmonProfiles
router.ex
SNMP profiles routes in web routerweb-ng/lib/serviceradar_web_ng_web/router.ex
Settings.SNMPProfilesLive.Indexwith actions for index,new profile, and edit profile
monitoring.pb.go
Protobuf SNMP configuration messages and enumsproto/monitoring.pb.go
SNMPVersion,SNMPSecurityLevel,SNMPAuthProtocol,SNMPPrivProtocol,SNMPDataTypeSNMPConfig,SNMPTargetConfig,SNMPv3Auth,SNMPOIDConfigwith full protobuf marshaling supportAgentConfigResponsemessage with newsnmp_configfield toinclude SNMP configuration
accommodate new types
snmp_service.go
Embedded SNMP agent service with dynamic configurationpkg/agent/snmp_service.go
agent with config management
control plane via
ApplyProtoConfigcapability
pattern for testability
server.go
SNMP service integration into agent serverpkg/agent/server.go
initSNMPServicemethod to initialize and start embedded SNMPservice during server startup
GetSNMPStatusmethod to retrieve current SNMP status if serviceis running and enabled
Stopmethod with error handlingNewServerconstructor withgraceful error handling
config.go
SNMP config loading and agent validationpkg/checker/snmp/config.go
Enabledfield toSNMPConfigstruct for controlling SNMPcollection
DefaultConfigfunction returning disabled SNMPconfiguration
LoadConfigFromFilefunction to load SNMP config from JSONfiles
ValidateForAgentmethod with less strict validation foragent use (no NodeAddress/ListenAddr requirement)
service.go
SNMP service factory for agent embeddingpkg/checker/snmp/service.go
NewSNMPServiceForAgentfunction for creating SNMP services withagent-specific validation
newSNMPServiceInternalhelper function
configuration requirements
types.go
SNMP service field in agent server typepkg/agent/types.go
snmpServicefield of type*SNMPAgentServicetoServerstruct7 files
snmp_config_distribution_integration_test.exs
SNMP config distribution integration testselixir/serviceradar_core/test/serviceradar/edge/snmp_config_distribution_integration_test.exs
control plane to agent
config generation
credential handling
generation
snmp_profile_test.exs
SNMPProfile resource tests with CRUD and policy validationelixir/serviceradar_core/test/serviceradar/snmp_profiles/snmp_profile_test.exs
and CRUD operations
set_as_defaultbehaviorsrql_target_resolver_test.exs
SrqlTargetResolver tests for SRQL-based profile targetingelixir/serviceradar_core/test/serviceradar/snmp_profiles/srql_target_resolver_test.exs
matching logic
queries, and priority-based selection
and error handling
execution
snmp_compiler_test.exs
SNMPCompiler tests for config compilation and validationelixir/serviceradar_core/test/serviceradar/snmp_profiles/snmp_compiler_test.exs
compilation and validation
generation
credential handling, and profile resolution
credential decryption
snmp_integration_test.go
SNMP agent service integration testspkg/agent/snmp_integration_test.go
agent service functionality
updates, and concurrent operations
and error handling
tests
testing.go
SNMP testing utilities and mock factoriespkg/checker/snmp/testing.go
Collector,Aggregator, and their factoriesNewMockServiceForTestingfunction to create SNMP services foragent tests without network requirements
connections
checker_integration_test.go
ICMP checker integration test updatespkg/agent/checker_integration_test.go
NewICMPCheckerconstructor with loggerparameter
Checkmethod call to includeproto.StatusRequestparameterconversion
require.NoErrorfor checker creation4 files
20260114074955_add_snmp_profiles.exs
Database migration for SNMP profile infrastructureelixir/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 and addsconfig_sourcecolumn toocsf_agentsunique constraints per tenant
credentials
config.exs
Register SNMPProfiles domain in application configurationweb-ng/config/config.exs
ServiceRadar.SNMPProfilesdomain to both web-ng andserviceradar_core domain registrations
config.exs
Register SNMP profiles domain in configelixir/serviceradar_core/config/config.exs
ServiceRadar.SNMPProfilesto the list of Ash domains inapplication configuration
test.exs
Register SNMP profiles domain in test configelixir/serviceradar_core/config/test.exs
ServiceRadar.SNMPProfilesto the list of Ash domains in testconfiguration
3 files
index.ex
Minor formatting improvements in log live viewweb-ng/lib/serviceradar_web_ng_web/live/log_live/index.ex
duration_statsandsparklinesfunctions for formatting consistencyindex.ex
Whitespace formatting adjustment in networks live viewweb-ng/lib/serviceradar_web_ng_web/live/settings/networks_live/index.ex
index.ex
Blank line formatting in analytics live viewweb-ng/lib/serviceradar_web_ng_web/live/analytics_live/index.ex
consistency
2 files
sysmon_service.go
Documentation comment for sysmon service stop methodpkg/agent/sysmon_service.go
SNMPAgentService.Stopmethodproposal.md
SNMP agent integration change proposal documentopenspec/changes/integrate-snmp-agent/proposal.md
into the agent
Proto), and implementation approach
capabilities
13 files
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2298#issuecomment-3750702808
Original created: 2026-01-14T17:27:31Z
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
Sensitive config exposure
Description: The compiled SNMP config includes decrypted SNMPv2c community strings and SNMPv3 auth/priv
passwords (e.g., via
decrypt_credential/1andcompile_v3_auth/1), which could beexfiltrated if agent config payloads are logged, stored, or transmitted insecurely;
additionally the rescue logging
inspect(e)risks leaking sensitive values if exceptionscontain decrypted data. snmp_compiler.ex [73-218]
Referred Code
🎫 #2222
profiles, targets, OIDs, compilation, config distribution tests).
snmp-checkerdeployment requirement and remove the agent→checkergRPC interaction.
behaviour), and that users no longer need to install/run the standalone
snmp-checker.snmp-checkerisremoved/disabled and documentation/release notes reflect the new installation model.
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:
Errors silently dropped: Several Ash read/decrypt failure paths return empty results or nil without surfacing
actionable context (e.g.,
decrypt_credential/1,load_profile_targets/3,load_target_oids/3), which can mask production failures and make debugging difficult.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:
Exception returned outward: The
compile/4rescue returns{:error, {:compilation_error, e}}which can propagateinternal exception structures upstream instead of returning a generic user-facing error
while keeping details only in secure logs.
Referred Code
Generic: Comprehensive Audit Trails
Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.
Status:
No audit logging: The new
seed!/2performs bulk creation of SNMP OID templates but does not emit anyexplicit audit log entries indicating who seeded what and the outcome.
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:
Logging raw exception: Logging
inspect(e)in the SNMP compiler may emit sensitive internal details depending onexception contents, and should be reviewed/structured to avoid leaking secrets in logs.
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:
Partial SRQL validation: While
device_uidis UUID-validated, thetarget_querycontent is executed via SRQL parsingand filter application, so additional validation/authorization controls for user-provided
SRQL queries may be required but cannot be confirmed from this diff alone.
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/2298#issuecomment-3750712054
Original created: 2026-01-14T17:29:03Z
PR Code Suggestions ✨
Explore these optional code suggestions:
✅
Prevent accidental deletion of credentialsSuggestion Impact:
The commit adds logic in handle_event("save_target") to reject empty values for community/auth_password/priv_password when editing a target, preventing accidental clearing of stored encrypted credentials. (Other unrelated changes were also included.)code diff:
In the
save_targetevent handler, when editing a target, remove blank passwordand community string fields from the submitted parameters to avoid
unintentionally clearing existing credentials.
web-ng/lib/serviceradar_web_ng_web/live/settings/snmp_profiles_live/index.ex [459-495]
[Suggestion processed]Suggestion importance[1-10]: 9
__
Why: This suggestion fixes a critical bug where leaving password fields blank during an edit would incorrectly clear the stored credentials, leading to monitoring failures and data loss.
✅
Fix bug losing OID inputSuggestion Impact:
The commit addresses the same "lost edits on blur" issue but via a different implementation: it refactors the update_oid/update_template_oid handlers to accept a "field" and read the new value from params["value"] (or params["delta"] for checkboxes), and updates the UI to send phx-value-field instead of passing all fields. This prevents relying on missing/incorrect param keys and avoids losing the edited OID value.code diff:
In the
update_oidevent handler, correctly retrieve the OID value from theparamsmap using the input's unique name (oid_#{index}_oid) to prevent editsfrom being lost on blur.
web-ng/lib/serviceradar_web_ng_web/live/settings/snmp_profiles_live/index.ex [576-592]
[Suggestion processed]Suggestion importance[1-10]: 9
__
Why: This suggestion fixes a significant UI bug where user edits to an OID field were lost on blur, making the feature unusable. The fix correctly retrieves the updated value from the form parameters.
✅
Align filter operatorsSuggestion Impact:
The commit updated apply_field_filter to recognize "not_equals" (alongside legacy "not_eq") and added explicit handling for "contains". It also added handling for "not_contains" (grouped with "not_like"), though instead of translating it to an Ash not_contains filter it skips the negative-contains filter and leaves the query unchanged (approximate count).code diff:
In
apply_field_filter, align the function clauses with the SRQL parser's outputby handling
contains,not_contains, andnot_equalsoperators to ensure correctfilter translation.
web-ng/lib/serviceradar_web_ng_web/live/settings/snmp_profiles_live/index.ex [2718-2730]
[Suggestion processed]Suggestion importance[1-10]: 8
__
Why: This suggestion fixes a bug where SRQL filter operators were incorrectly mapped, causing the device count preview to be inaccurate. The fix aligns the filter logic with the parser's output.
Match template id as string
In the
add_template_oidsevent handler, convert the template's ID to a stringbefore comparing it with the
template_idfrom the event parameters to fix a typemismatch bug.
web-ng/lib/serviceradar_web_ng_web/live/settings/snmp_profiles_live/index.ex [617]
Suggestion importance[1-10]: 8
__
Why: This suggestion fixes a type mismatch bug where a string
template_idfrom the client would never match the template's ID, causing the "Add Template OIDs" feature to fail silently.✅
Properly handle SNMPv3 authentication parametersSuggestion Impact:
The commit removes the "temporary workaround" comments and now populates a dedicated SNMPv3 auth struct (target.V3Auth) with username, security level, auth/priv protocols and passwords, along with adding the required proto-to-SNMP conversion helpers. It still clears target.Community for v3. While it doesn't match the exact suggested fields (e.g., target.V3Params/target.Version), it implements the intended proper handling of SNMPv3 auth parameters.code diff:
Implement proper SNMPv3 authentication parameter handling instead of using the
current workaround which stores a username in the community string field.
pkg/agent/snmp_service.go [664-670]
[Suggestion processed]Suggestion importance[1-10]: 8
__
Why: The suggestion correctly identifies a significant issue where SNMPv3 authentication is handled via a non-functional workaround, which would cause authentication to fail.
✅
Safely parse port inputSuggestion Impact:
The port parsing logic was updated to use Integer.parse/1 for binary inputs and fall back to 161 on parse errors, preventing crashes from non-numeric port values.code diff:
In the
test_connectionevent handler, replaceString.to_integer/1with the saferInteger.parse/1to handle non-numeric port inputs gracefully and preventcrashes.
web-ng/lib/serviceradar_web_ng_web/live/settings/snmp_profiles_live/index.ex [529-534]
[Suggestion processed]Suggestion importance[1-10]: 7
__
Why: The suggestion correctly points out that
String.to_integer/1can crash with invalid input. UsingInteger.parse/1makes the port parsing more robust and prevents potential process crashes.✅
Skip disabled profilesSuggestion Impact:
Updated the conditional to require both a resolved profile and profile.enabled before compiling; otherwise returns disabled_config, including for disabled profiles. Also updated the comment accordingly.code diff:
Check if a profile is enabled before compiling it; if it is disabled, return the
disabled configuration to avoid unnecessary processing.
elixir/serviceradar_core/lib/serviceradar/agent_config/compilers/snmp_compiler.ex [81-87]
[Suggestion processed]Suggestion importance[1-10]: 7
__
Why: This is a good optimization that avoids unnecessarily compiling a disabled profile, making the logic more efficient and consistent with the case where no profile is found.
Prevent connection test race condition
In the
test_connectionevent handler, add a check for thetest_connection_loadingflag to prevent multiple concurrent connection tests andavoid potential race conditions.
web-ng/lib/serviceradar_web_ng_web/live/settings/snmp_profiles_live/index.ex [521-552]
Suggestion importance[1-10]: 6
__
Why: The suggestion correctly identifies a potential race condition from multiple clicks on the "Test Connection" button and provides a simple, effective fix by checking the loading state, improving UI stability.
✅
Use bulk update for efficiencySuggestion Impact:
The commit removed the Enum.each loop that built and updated individual changesets and replaced it with a single Ash.bulk_update call to perform the unset_default action for all profiles at once.code diff:
Use
Ash.bulk_update/4to unset previous default profiles in a single, moreefficient database operation instead of iterating and updating them
individually.
elixir/serviceradar_core/lib/serviceradar/snmp_profiles/changes/set_as_default.ex [37-52]
[Suggestion processed]Suggestion importance[1-10]: 6
__
Why: The suggestion proposes using
Ash.bulk_update/4for better performance and atomicity, which is a valid and good practice for updating multiple records.✅
Trim and concatenate SRQL querySuggestion Impact:
Updated combined_query construction to use String.trim(target_query) <> " uid:" <> device_uid, preventing malformed SRQL queries due to extra/missing whitespace.code diff:
In
matches_device?/4, trim whitespace fromtarget_queryand ensure a space ispresent before concatenating the
uidfilter to prevent malformed SRQL queries.elixir/serviceradar_core/lib/serviceradar/snmp_profiles/srql_target_resolver.ex [134]
[Suggestion processed]Suggestion importance[1-10]: 5
__
Why: This change improves the robustness of SRQL query construction by handling potential leading/trailing whitespace in
target_query, preventing malformed queries.