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).
github.com/OlegPowerC/asn1modsnmp—for optimized performance and reliability.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))
}
}
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)
PowerSNMPv3 distinguishes between fatal and partial errors, providing comprehensive error handling strategies. It allows for clear diagnosis and troubleshooting during SNMP operations.
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.