async-snmp
Modern, async-first SNMP client library for Rust.
Note
This library is not currently stable. While pre v1.0, breaking changes are likely to occur frequently, no attempt will be made to maintain backward compatibility pre-1.0.
Features
- Full protocol support: SNMPv1, v2c, and v3 (USM)
- Async-first: Built on Tokio for high-performance async I/O
- All operations: GET, GETNEXT, GETBULK, SET, WALK, BULKWALK
- SNMPv3 security: MD5/SHA-1/SHA-2 authentication, DES/3DES/AES-128/192/256 privacy
- Multiple transports: UDP, TCP, and shared UDP for scalable polling
- Zero-copy decoding: Minimal allocations using
bytescrate - Type-safe: Compile-time OID validation with
oid!macro
Protocol Support Matrix
| Feature | v1 | v2c | v3 |
|---|---|---|---|
| GET / GETNEXT | Y | Y | Y |
| GETBULK | - | Y | Y |
| SET | Y | Y | Y |
| WALK / BULKWALK | Y | Y | Y |
| Receive Traps | Y | Y | Y |
| Receive Informs | - | Y | Y |
SNMPv3 Security
Authentication: MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512
Privacy: DES, 3DES, AES-128, AES-192, AES-256
Installation
Or add to your Cargo.toml:
[]
= "0.5"
Quick Start
SNMPv2c
use ;
use Duration;
async
SNMPv3 with Authentication and Privacy
use ;
async
Walking a Subtree
use ;
use StreamExt;
async
Scalable Polling (Shared Transport)
For monitoring systems polling thousands of targets, share a single UDP socket across all clients. This provides significant resource efficiency without sacrificing throughput:
use ;
async
Benefits of shared transport:
- 1 file descriptor for all targets (vs 1 per target with separate sockets)
- Firewall session reuse between polls to the same target
- Lower memory from shared socket buffers
- No per-poll socket creation overhead
Scaling guidance:
| Approach | When to use |
|---|---|
| Single shared socket | Recommended for most use cases |
| Multiple shared sockets | Extreme scale (~100,000s+ targets), shard by target |
Per-client socket (.connect()) |
When scrape isolation is required (has FD and syscall overhead) |
Tracing
The library uses the tracing crate for structured logging. Filter by target:
# All library logs at debug level
RUST_LOG=async_snmp=debug
# Trace client operations only
RUST_LOG=async_snmp::client=trace
# Debug transport layer
RUST_LOG=async_snmp::transport=debug
Available targets:
- Core:
async_snmp::client,async_snmp::agent,async_snmp::notification - Protocol:
async_snmp::ber,async_snmp::pdu,async_snmp::oid,async_snmp::value - SNMPv3:
async_snmp::v3,async_snmp::usm,async_snmp::crypto,async_snmp::engine - Transport:
async_snmp::transport,async_snmp::transport::tcp,async_snmp::transport::udp - Operations:
async_snmp::walk,async_snmp::error
Documentation
Full API documentation is available on docs.rs.
Feature Flags
| Feature | Description |
|---|---|
cli |
CLI utilities (asnmp-get, asnmp-walk, asnmp-set) |
Minimum Supported Rust Version
This crate requires Rust 1.88 or later. The MSRV may be increased in minor version releases.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.