Skip to content

feat: add SNMP trap provider#6471

Open
Treasure520520 wants to merge 1 commit into
keephq:mainfrom
Treasure520520:bounty/2112-stdlib-snmp-provider
Open

feat: add SNMP trap provider#6471
Treasure520520 wants to merge 1 commit into
keephq:mainfrom
Treasure520520:bounty/2112-stdlib-snmp-provider

Conversation

@Treasure520520
Copy link
Copy Markdown

@Treasure520520 Treasure520520 commented May 12, 2026

/claim #2112

Fixes #2112

Summary

Adds a native SNMP provider that can receive SNMP v1/v2c traps over UDP and convert them into Keep alerts.

The implementation is intentionally dependency-light: it uses a small BER decoder plus a UDP listener, so Keep can receive common traps without adding a third-party SNMP runtime dependency.

What changed

  • Added SnmpProvider with configurable listen_host, listen_port, community, queue size, and socket timeout.
  • Supports SNMP v1 trap PDUs and SNMP v2c trap/inform PDUs.
  • Maps well-known traps such as linkDown, linkUp, coldStart, warmStart, and authenticationFailure into Keep status/severity.
  • Decouples UDP packet reception from Keep API pushes using a bounded queue and worker thread.
  • Filters incoming traps by configured community string.
  • Adds webhook-style formatting support for SNMP trap forwarders.
  • Adds tests for v1 decoding, v2c decoding, webhook formatting, and queued alert pushing.
  • Adds provider docs and mock alerts.

Demo

Short demo asset: https://github.com/Treasure520520/keep/releases/download/keep-snmp-provider-demo-2112/keep-snmp-provider-demo.gif

Validation

poetry run black --check keep/providers/snmp_provider tests/test_snmp_provider.py
poetry run ruff check keep/providers/snmp_provider tests/test_snmp_provider.py
poetry run python -m pytest tests/test_snmp_provider.py -q
git diff --check

The focused test run passes with 4 SNMP provider tests.

Notes

  • Default trap port is 162, but the docs recommend using an unprivileged port such as 1162 for local development.
  • SNMPv3 auth/privacy is not included in this PR.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 12, 2026

CLA assistant check
All committers have signed the CLA.

@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. Documentation Improvements or additions to documentation Feature A new feature Provider Providers related issues labels May 12, 2026
@Treasure520520 Treasure520520 force-pushed the bounty/2112-stdlib-snmp-provider branch from 4db09aa to 83c620a Compare May 12, 2026 23:29
@Treasure520520
Copy link
Copy Markdown
Author

CLA is now signed and the issue-link/title/security checks are green. This PR is ready for maintainer review from my side. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🙋 Bounty claim Documentation Improvements or additions to documentation Feature A new feature Provider Providers related issues size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🔌 Provider]: SNMP provider

2 participants