PowerSNMPv3 is a pure Go SNMP library designed for both v2c and v3 protocols. It supports various authentication and encryption methods, ensuring secure communications. With minimal dependencies and efficient performance, this library is perfect for developers seeking a reliable solution for network management, featuring user-to-credentials mapping, and TRAP reception.
PowerSNMPv3 is a comprehensive SNMP library written in pure Go, supporting both SNMP v2c and v3 with robust authentication and encryption capabilities. It is designed for developers looking for a reliable way to manage network devices using Simple Network Management Protocol (SNMP).
Key Features
- Protocol Support: Offers full support for SNMPv2c and v3, enabling flexible options for device management.
- Authentication Mechanisms: Supports multiple authentication algorithms including MD5, SHA, and SHA-512, ensuring secure access to devices.
- Encryption Options: Provides various encryption techniques such as DES and AES (up to 256 bits), reinforcing data protection.
- SNMP Operations: Facilitates core SNMP operations including Get, GetMulti, Set, SetMulti, Walk, and BulkWalk, allowing for comprehensive device management.
- Streaming Operations: Implements streaming functionality via channels, enhancing performance for bulk data retrieval.
- TRAP/INFORM Reception: Features automatic acknowledgment for TRAP/INFORM messages, ensuring seamless monitoring of network events.
- Minimal Dependencies: Utilizes a lightweight dependency—
github.com/OlegPowerC/asn1modsnmp—for optimized performance and reliability. - User-Credentials Mapping: Includes user-to-credentials mapping in trap receivers, simplifying device authentication.
Quick Start Examples
SNMPv3 Get
This example demonstrates how to initialize a session and perform a SNMP Get operation using SNMPv3:
package main
import (
"fmt"
"log"
snmp "github.com/OlegPowerC/powersnmpv3"
)
func main() {
device := snmp.NetworkDevice{
IPaddress: "192.168.1.1",
Port: 161,
SNMPparameters: snmp.SNMPUserParameters{
SNMPversion: 3,
Username: "snmpuser",
AuthProtocol: "sha",
AuthKey: "authpass123",
PrivProtocol: "aes",
PrivKey: "privpass123",
RetryCount: 3,
TimeoutBtwRepeat: 500,
},
}
sess, err := snmp.SNMP_Init(device)
if err != nil {
log.Fatal(err)
}
defer sess.Close()
oid, _ := snmp.ParseOID("1.3.6.1.2.1.1.1.0")
result, err := sess.SNMP_Get(oid)
if err != nil {
log.Fatal(err)
}
for _, vb := range result {
fmt.Printf("%s = %s\n",
snmp.Convert_OID_IntArrayToString_RAW(vb.RSnmpOID),
snmp.Convert_Variable_To_String(vb.RSnmpVar))
}
}
SNMP Trap Receiver
To receive and parse SNMP TRAP/INFORM messages, configure the receiver as follows:
Userv3Map := make(map[string]*snmp.SNMPTrapParameters)
Userv3Map["snmpuser"] = &snmp.SNMPTrapParameters{
Username: "snmpuser",
AuthProtocol: "sha",
AuthKey: "authpass123",
PrivProtocol: "aes",
PrivKey: "privpass123",
}
conn, _ := net.ListenPacket("udp", ":162")
n, addr, _ := conn.ReadFrom(buff)
version, msgtype, data, err := snmp.ParseTrapWithCredentials(
addr.IP.String(), addr.Port, buff[:n], credentials, 0)
Error Handling
PowerSNMPv3 distinguishes between fatal and partial errors, providing comprehensive error handling strategies. It allows for clear diagnosis and troubleshooting during SNMP operations.
Performance
Benchmarked for efficiency, PowerSNMPv3 is designed to be one of the fastest SNMP libraries, significantly outperforming competitors in both speed and memory usage. This makes it an ideal choice for environments with a large number of devices to manage.
For more detailed information, including performance benchmarks and configuration options, refer to the complete documentation in the repository.
No comments yet.
Sign in to be the first to comment.