GoSNMPServer is an SNMP server library fully written in Go. It provides Server Get, GetNext, GetBulk, Walk, BulkWalk, Set and Traps. It supports IPv4 and IPv6, using SNMPv2c or SNMPv3.
--> for this code i am trying below command to fetch snmp get/set. get is working fine but set is not working.
snmpget -v 3 -l authPriv -n private -u testuser -a md5 -A testauth -x des -X testpriv 127.0.0.1:1111 oid
Press Ctrl-C to stop.
SNMPv2-SMI::enterprises.1.5.3.1.14.1 = Integer: 30
^CShutting down...
_### # snmpset -v 3 -l authPriv -n private -u testuser -a md5 -A testauth -x des -X testpriv 127.0.0.1:1111 oid i 20
Press Ctrl-C to stop.
No SNMP response received before timeout_
Logs from GoSNMPServer package:-
Received set for : &{Version:3 MsgFlags:Reportable SecurityModel:UserSecurityModel SecurityParameters:0xc0000b1a00 ContextEngineID: ContextName:private Community: PDUType:SetRequest MsgID:16201700 RequestID:799352 MsgMaxSize:65507 Error:NoError ErrorIndex:0 NonRepeaters:0 MaxRepetitions:0 Variables:[] Logger:{logger:0xc00009e5a0} SnmpTrap:{Variables:[] IsInform:false Enterprise: AgentAddress: GenericTrap:0 SpecificTrap:0 Timestamp:0}}Received set for : []
toRet := []*GoSNMPServer.PDUValueControlItem{ { OID: APRA_SNMPREG_battery_Rated_Capacity, Type: gosnmp.Integer, //Type: gosnmp.Asn1BER(slayercat.Integer), OnGet: func() (value interface{}, err error) { fmt.Printf("Received get") return GoSNMPServer.Asn1IntegerWrap(batteryRatedCapacity), nil }, OnSet: func(value interface{}) (err error) { fmt.Printf("Received set: %d, unwrap value: %+v\n", value,GoSNMPServer.Asn1IntegerUnwrap(value) batteryRatedCapacity = GoSNMPServer.Asn1IntegerUnwrap(value) fmt.Printf("Battery Rated Capacity set to: %d\n", batteryRatedCapacity) return nil }, Document: "Battery Rated Capacity", }, }
--> for this code i am trying below command to fetch snmp get/set. get is working fine but set is not working.
snmpget -v 3 -l authPriv -n private -u testuser -a md5 -A testauth -x des -X testpriv 127.0.0.1:1111 oid
Press Ctrl-C to stop. SNMPv2-SMI::enterprises.1.5.3.1.14.1 = Integer: 30 ^CShutting down... _### # snmpset -v 3 -l authPriv -n private -u testuser -a md5 -A testauth -x des -X testpriv 127.0.0.1:1111 oid i 20 Press Ctrl-C to stop. No SNMP response received before timeout_
Logs from GoSNMPServer package:- Received set for : &{Version:3 MsgFlags:Reportable SecurityModel:UserSecurityModel SecurityParameters:0xc0000b1a00 ContextEngineID: ContextName:private Community: PDUType:SetRequest MsgID:16201700 RequestID:799352 MsgMaxSize:65507 Error:NoError ErrorIndex:0 NonRepeaters:0 MaxRepetitions:0 Variables:[] Logger:{logger:0xc00009e5a0} SnmpTrap:{Variables:[] IsInform:false Enterprise: AgentAddress: GenericTrap:0 SpecificTrap:0 Timestamp:0}}Received set for : []