alouca / gosnmp Goto Github PK
View Code? Open in Web Editor NEWA simple SNMP library written in GoLang
License: Other
A simple SNMP library written in GoLang
License: Other
Currently NewGoSNMP uses 161 as a hard coded port. Allowing the caller to specify the port of the target would provide more flexibility.
I'm unable to get get-response with gosnmp.Version1 and gosnmp
but I'm able to get it using snmpget
.
I get:
panic: Error reading from UDP: WSARecv udp <ip>:56671: i/o timeout
Here's the output of wireshark :
(not working)
s, err := gosnmp.NewGoSNMP(host, "private", gosnmp.Version1, 5)
resp, err := s.Get(".1.3.6.1.4.1.318.1.1.10.3.13.1.1.3.1")
00000000 30 2f 02 01 01 04 07 70 72 69 76 61 74 65 a0 21 0/.....p rivate.!
00000010 02 01 00 02 01 00 02 01 00 30 16 30 14 06 10 2b ........ .0.0...+
00000020 06 01 04 01 82 3e 01 01 0a 03 0d 01 01 03 01 05 .....>.. ........
00000030 00
(working) snmpget -v1 -cprivate ip .1.3.6.1.4.1.318.1.1.10.3.13.1.1.3.1
00000000 30 32 02 01 00 04 07 70 72 69 76 61 74 65 a0 24 02.....p rivate.$
00000010 02 04 59 80 62 82 02 01 00 02 01 00 30 16 30 14 ..Y.b... ....0.0.
00000020 06 10 2b 06 01 04 01 82 3e 01 01 0a 03 0d 01 01 ..+..... >.......
00000030 03 01 05 00
I'm running into a timeout error when trying to make a GetMulti request with six OIDs. The error is "Error reading from UDP: WSARecv udp 172.16.1.2:50964: i/o timeout".
When I watch for the SNMP packet with Wireshark the packets that time out are sent but Wireshark can't decode them as valid SNMP packets. My suspicion is that the packet is too big and is truncated.
The error occurs when the length of the byte array return from SnmpPacket.marshal() is 140. It does not occur when the length is 123. That's as far as I've been able to narrow down the problem.
func (x *GoSNMP) Close() error {
return x.conn.Close()
}
snmp, err := gosnmp.NewGoSNMP(ip, community, gosnmp.Version2c, timeout)
if err != nil {
return err
}
defer snmp.Close()
I can't use this package to decode MAC(hex-string). who can help me?
Even though the library takes a version it appears to only work with v1.
It would be really nice if gosnmp provides and trap support.
https://github.com/alouca/gosnmp/blob/master/gosnmp.go#L159
it's needed to consider whether the response is 'endOfMibView'
for {
res, err := x.GetNext(oid)
log.Printf("oid=%s, res=%v, err=%s", oid, res, err)
if err != nil {
return results, err
}
if res != nil {
if len(res.Variables) > 0 {
if res.Variables[0].Type == EndOfMibView {
break
`}`
Otherwise, is some situation, this loop will never come to its end!!!
It appears that results are being truncated. Here are two different examples comparing snmpget with example.go.
snmpget -c public 192.168.1.181 .1.3.6.1.2.1.1.1.0
SNMPv2-MIB::sysDescr.0 = STRING: Linux ubuntu 3.2.0-23-virtual #36-Ubuntu SMP Tue Apr 10 22:29:03 UTC 2012 x86_64
./example -target="192.168.1.181" -oid=".1.3.6.1.2.1.1.1.0"
Getting .1.3.6.1.2.1.1.1.0
2012/09/30 00:05:06 [DEBUG] packet.go:74 (github.com/alouca/gosnmp.Unmarshal) Packet sanity verified, we got all the bytes (120)
2012/09/30 00:05:06 [DEBUG] packet.go:94 (github.com/alouca/gosnmp.Unmarshal) Parsed community public
2012/09/30 00:05:06 [DEBUG] packet.go:97 (github.com/alouca/gosnmp.Unmarshal) SNMP Packet is get response
2012/09/30 00:05:06 [DEBUG] packet.go:108 (github.com/alouca/gosnmp.Unmarshal) Response length: 120
2012/09/30 00:05:06 [DEBUG] packet.go:146 (github.com/alouca/gosnmp.Unmarshal) Request ID: 0 Error: 0 Error Index: 0
2012/09/30 00:05:06 [DEBUG] packet.go:154 (github.com/alouca/gosnmp.Unmarshal) Parsing var bind response (Cursor at 26/120)
2012/09/30 00:05:06 [DEBUG] packet.go:165 (github.com/alouca/gosnmp.Unmarshal) OID ([1 3 6 1 2 1 1 1 0]) Field was 10 bytes
2012/09/30 00:05:06 [DEBUG] packet.go:178 (github.com/alouca/gosnmp.Unmarshal) PDU Value length: 80
.1.3.6.1.2.1.1.1.0 -> Linux ubuntu 3.2.0-23-virtual #36-Ubuntu SMP Tue Apr 10 22:29:03 UTC 2012 x86_
snmpget -c public -v 2c 192.168.1.181 .1.3.6.1.4.1.2021.10.1.3.1
UCD-SNMP-MIB::laLoad.1 = STRING: 0.00
./example -target="192.168.1.181" -oid=".1.3.6.1.4.1.2021.10.1.3.1"
Getting .1.3.6.1.4.1.2021.10.1.3.1
2012/09/30 00:26:16 [DEBUG] packet.go:74 (github.com/alouca/gosnmp.Unmarshal) Packet sanity verified, we got all the bytes (47)
2012/09/30 00:26:16 [DEBUG] packet.go:94 (github.com/alouca/gosnmp.Unmarshal) Parsed community public
2012/09/30 00:26:16 [DEBUG] packet.go:97 (github.com/alouca/gosnmp.Unmarshal) SNMP Packet is get response
2012/09/30 00:26:16 [DEBUG] packet.go:108 (github.com/alouca/gosnmp.Unmarshal) Response length: 47
2012/09/30 00:26:16 [DEBUG] packet.go:146 (github.com/alouca/gosnmp.Unmarshal) Request ID: 0 Error: 0 Error Index: 0
2012/09/30 00:26:16 [DEBUG] packet.go:154 (github.com/alouca/gosnmp.Unmarshal) Parsing var bind response (Cursor at 26/47)
2012/09/30 00:26:16 [DEBUG] packet.go:165 (github.com/alouca/gosnmp.Unmarshal) OID ([1 3 6 1 4 1 2021 10 1 3 1]) Field was 13 bytes
2012/09/30 00:26:16 [DEBUG] packet.go:178 (github.com/alouca/gosnmp.Unmarshal) PDU Value length: 4
.1.3.6.1.4.1.2021.10.1.3.1 -> 0.
I am trying to get the Hostname of a SNMP device. I am polling the unified OID ".1.3.6.1.2.1.1.5.0" which returns a type of OctetString.
When i execute
fmt.Println(v.Type)
fmt.Println(v.Value)
I get the output
OctetString
[99 112 101 52 50 57 50 53 49 46 113 115 99 46 100 101]
And i can't figure out how to convert the []uint8 to a String.
When trying to execute string(v.Value)
i get
cannot convert v.Value (type interface {}) to type string: need type assertion
And when i try to execute v.Value.(string)
i get
panic: interface conversion: interface is []uint8, not string
goroutine 1 [running]:
main.interfacecheck(0x7fffef54641d, 0xc)
/home/simonszu/hello.go:19 +0x2e0
main.main()
/home/simonszu/hello.go:41 +0x174
Please help.
go version go1.2.1 linux/386
go test
2014/03/20 10:14:38 [DEBUG] packet.go:51 (_/home/bbigras/test/gosnmp.Unmarshal) Begin SNMP Packet unmarshal
2014/03/20 10:14:38 [DEBUG] packet.go:233 (_/home/bbigras/test/gosnmp.parseField) Field length is padded to 2 bytes
2014/03/20 10:14:38 [DEBUG] packet.go:234 (_/home/bbigras/test/gosnmp.parseField) Decoded final length: 50
2014/03/20 10:14:38 [DEBUG] packet.go:69 (_/home/bbigras/test/gosnmp.Unmarshal) Packet sanity verified, we got all the bytes (50)
2014/03/20 10:14:38 [DEBUG] packet.go:84 (_/home/bbigras/test/gosnmp.Unmarshal) Parsed Version 1
2014/03/20 10:14:38 [DEBUG] packet.go:95 (_/home/bbigras/test/gosnmp.Unmarshal) Parsed community public
2014/03/20 10:14:38 [DEBUG] packet.go:233 (_/home/bbigras/test/gosnmp.parseField) Field length is padded to 2 bytes
2014/03/20 10:14:38 [DEBUG] packet.go:234 (_/home/bbigras/test/gosnmp.parseField) Decoded final length: 35
2014/03/20 10:14:38 [DEBUG] packet.go:108 (_/home/bbigras/test/gosnmp.Unmarshal) SNMP Packet is GetResponse
2014/03/20 10:14:38 [DEBUG] packet.go:109 (_/home/bbigras/test/gosnmp.Unmarshal) PDU Size is 35
2014/03/20 10:14:38 [DEBUG] packet.go:125 (_/home/bbigras/test/gosnmp.Unmarshal) Parsed Request ID: 0
2014/03/20 10:14:38 [DEBUG] packet.go:149 (_/home/bbigras/test/gosnmp.Unmarshal) Request ID: 0 Error: 0 Error Index: 0
2014/03/20 10:14:38 [DEBUG] packet.go:233 (_/home/bbigras/test/gosnmp.parseField) Field length is padded to 2 bytes
2014/03/20 10:14:38 [DEBUG] packet.go:234 (_/home/bbigras/test/gosnmp.parseField) Decoded final length: 22
2014/03/20 10:14:38 [DEBUG] packet.go:159 (_/home/bbigras/test/gosnmp.Unmarshal) Parsing var bind response (Cursor at 32/54)
2014/03/20 10:14:38 [DEBUG] packet.go:233 (_/home/bbigras/test/gosnmp.parseField) Field length is padded to 2 bytes
2014/03/20 10:14:38 [DEBUG] packet.go:234 (_/home/bbigras/test/gosnmp.parseField) Decoded final length: 18
2014/03/20 10:14:38 [DEBUG] packet.go:170 (_/home/bbigras/test/gosnmp.Unmarshal) Varbind length: 4/18
2014/03/20 10:14:38 [DEBUG] packet.go:170 (_/home/bbigras/test/gosnmp.Unmarshal) Parsing OID (Cursor at 36)
2014/03/20 10:14:38 [DEBUG] packet.go:180 (_/home/bbigras/test/gosnmp.Unmarshal) OID (&{ObjectIdentifier 2 10 [43 6 1 2 1 2 2 1 10 2] 0x1862d920}) Field was 10 bytes
2014/03/20 10:14:38 [DEBUG] packet.go:191 (_/home/bbigras/test/gosnmp.Unmarshal) Value field was 4 bytes
2014/03/20 10:14:38 [DEBUG] packet.go:193 (_/home/bbigras/test/gosnmp.Unmarshal) Varbind decoding success
.1.3.6.1.2.1.2.2.1.10.2 -> 162791045
--- FAIL: TestWalk (0.53 seconds)
gosnmp_test.go:55: Running walk test
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x1 pc=0x808025c]
goroutine 5 [running]:
runtime.panic(0x81566c0, 0x82c37e8)
/usr/local/go/src/pkg/runtime/panic.c:266 +0xac
testing.func·005()
/usr/local/go/src/pkg/testing/testing.go:385 +0xda
runtime.panic(0x81566c0, 0x82c37e8)
/usr/local/go/src/pkg/runtime/panic.c:248 +0xef
_/home/bbigras/test/gosnmp.TestWalk(0x18646e40)
/home/bbigras/test/gosnmp/gosnmp_test.go:57 +0xec
testing.tRunner(0x18646e40, 0x82c1c4c)
/usr/local/go/src/pkg/testing/testing.go:391 +0x88
created by testing.RunTests
/usr/local/go/src/pkg/testing/testing.go:471 +0x6d3
goroutine 1 [chan receive]:
testing.RunTests(0x81a7c4c, 0x82c1c40, 0x4, 0x4, 0x1)
/usr/local/go/src/pkg/testing/testing.go:472 +0x6ee
testing.Main(0x81a7c4c, 0x82c1c40, 0x4, 0x4, 0x82c0118, ...)
/usr/local/go/src/pkg/testing/testing.go:403 +0x6b
main.main()
_/home/bbigras/test/gosnmp/_test/_testmain.go:55 +0x83
goroutine 7 [syscall]:
runtime.goexit()
/usr/local/go/src/pkg/runtime/proc.c:1394
exit status 2
FAIL _/home/bbigras/test/gosnmp 0.597s
I'm not quite sure what's going on here but I get wildly different results when running example.go versus snmpget. Below are a couple of examples. For what it's worth these OIDs were working with an older release of the code.
snmpget -c public -v 2c 192.168.1.181 .1.3.6.1.2.1.1.3.0
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (1131111) 3:08:31.11
./example -target="192.168.1.181" -oid=".1.3.6.1.2.1.1.3.0"
Getting .1.3.6.1.2.1.1.3.0
2012/09/30 00:27:54 [DEBUG] packet.go:74 (github.com/alouca/gosnmp.Unmarshal) Packet sanity verified, we got all the bytes (43)
2012/09/30 00:27:54 [DEBUG] packet.go:94 (github.com/alouca/gosnmp.Unmarshal) Parsed community public
2012/09/30 00:27:54 [DEBUG] packet.go:97 (github.com/alouca/gosnmp.Unmarshal) SNMP Packet is get response
2012/09/30 00:27:54 [DEBUG] packet.go:108 (github.com/alouca/gosnmp.Unmarshal) Response length: 43
2012/09/30 00:27:54 [DEBUG] packet.go:146 (github.com/alouca/gosnmp.Unmarshal) Request ID: 0 Error: 0 Error Index: 0
2012/09/30 00:27:54 [DEBUG] packet.go:154 (github.com/alouca/gosnmp.Unmarshal) Parsing var bind response (Cursor at 26/43)
2012/09/30 00:27:54 [DEBUG] packet.go:165 (github.com/alouca/gosnmp.Unmarshal) OID ([1 3 6 1 2 1 1 3 0]) Field was 10 bytes
2012/09/30 00:27:54 [DEBUG] packet.go:178 (github.com/alouca/gosnmp.Unmarshal) PDU Value length: 3
.1.3.6.1.2.1.1.3.0 -> Type: 67 - Value: 17
snmpget -c public -v 2c 192.168.1.181 .1.3.6.1.4.1.2021.4.6.0
UCD-SNMP-MIB::memAvailReal.0 = INTEGER: 121116 kB
./example -target="192.168.1.181" -oid=".1.3.6.1.4.1.2021.4.6.0"
Getting .1.3.6.1.4.1.2021.4.6.0
2012/09/30 00:33:09 [DEBUG] packet.go:74 (github.com/alouca/gosnmp.Unmarshal) Packet sanity verified, we got all the bytes (45)
2012/09/30 00:33:09 [DEBUG] packet.go:94 (github.com/alouca/gosnmp.Unmarshal) Parsed community public
2012/09/30 00:33:09 [DEBUG] packet.go:97 (github.com/alouca/gosnmp.Unmarshal) SNMP Packet is get response
2012/09/30 00:33:09 [DEBUG] packet.go:108 (github.com/alouca/gosnmp.Unmarshal) Response length: 45
2012/09/30 00:33:09 [DEBUG] packet.go:146 (github.com/alouca/gosnmp.Unmarshal) Request ID: 0 Error: 0 Error Index: 0
2012/09/30 00:33:09 [DEBUG] packet.go:154 (github.com/alouca/gosnmp.Unmarshal) Parsing var bind response (Cursor at 26/45)
2012/09/30 00:33:09 [DEBUG] packet.go:165 (github.com/alouca/gosnmp.Unmarshal) OID ([1 3 6 1 4 1 2021 4 6 0]) Field was 12 bytes
2012/09/30 00:33:09 [DEBUG] packet.go:178 (github.com/alouca/gosnmp.Unmarshal) PDU Value length: 3
.1.3.6.1.4.1.2021.4.6.0 -> Type: 2 - Value: 1
file: decode.go
66 case Counter32:
67 ret, err := parseInt(data)
replace parseInt with parseInt64, cat get value.
s, err := gosnmp.NewGoSNMP(ip, "public", gosnmp.Version2c, 5)
if err != nil {
return nil, fmt.Errorf("new snmp client error: %v", err)
}
klog.V(4).Infof("new snmp client success,ip: %s", ip)
s.SetDebug(true)
s.SetVerbose(true)
resp, err := s.Get(".1.3.6.1.2.1.31.1.1.1.1")
if err != nil {
return nil, fmt.Errorf("get Names error: %v", err)
}
got error:
failed to collect switch info, due to : get NameOID error: Unable to decode packet: Unable to decode value: No such instance
what can i do?
If you send a snmp request which is larger than 127 bytes, then the packet is malformed and you do not get a response.
Here is a request where the data has length 128 bytes:
Frame 4: 172 bytes on wire (1376 bits), 172 bytes captured (1376 bits) on interface 0
Ethernet II, Src: Vmware_c0:00:01 (00:50:56:c0:00:01), Dst: Vmware_cb:42:6a (00:0c:29:cb:42:6a)
Internet Protocol Version 4, Src: 192.168.140.1, Dst: 192.168.140.252
User Datagram Protocol, Src Port: 46844 (46844), Dst Port: 161 (161)
[Malformed Packet: SNMP]
[Expert Info (Error/Malformed): Malformed Packet (Exception occurred)]
[Malformed Packet (Exception occurred)]
[Severity level: Error]
[Group: Malformed]
This has the length field set to 80
, which is binary 1000000
, for snmp this value means that long form length encoding is being used, and the 7 least significant bits should represent the subsequent bytes that will be used to represent the length.
The code currently represents the size of the data as a uint8 and sets the length to this value.
package main
import (
"fmt"
"log"
"github.com/alouca/gosnmp"
)
func main() {
s, err := gosnmp.NewGoSNMP("vmx01", "test123", gosnmp.Version2c, 5)
if err != nil {
log.Print(err)
return
}
resp, err := s.Get(".1.3.6.1.4.1.2636.3.5.2.11.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1")
if err != nil {
log.Print(err)
return
}
for _, v := range resp.Variables {
fmt.Println(v.Name, v.Value)
}
}
$ go run snmp.go
2017/06/05 14:57:46 Error reading from UDP: read udp 192.168.140.1:46844->192.168.141.252:161: i/o timeout
You will not get a response due to the packet being malformed. If you capture the traffic via wireshark you will be able to see the malformed packet.
Hello,
when I'm scanning thousands of ip addresses using your library for an internal discovery tool I receive a panic. I am using your library in a go function with 128 concurrent instances of it, maybe that is the problem? The panic occurs on this line "for _,v := range response1.Variables"
Do you eventually have a workaround?
Thx in advance,
Dirk
Ip: 10.3.122.51
Ip: 10.48.79.206
2016/08/30 15:32:30 [DEBUG] packet.go:51 (github.com/alouca/gosnmp.Unmarshal) Begin SNMP Packet unmarshal
2016/08/30 15:32:30 [DEBUG] packet.go:69 (github.com/alouca/gosnmp.Unmarshal) Packet sanity verified, we got all the bytes (49)
2016/08/30 15:32:30 [DEBUG] packet.go:84 (github.com/alouca/gosnmp.Unmarshal) Parsed Version 1
2016/08/30 15:32:30 [DEBUG] packet.go:95 (github.com/alouca/gosnmp.Unmarshal) Parsed community public
2016/08/30 15:32:30 [DEBUG] packet.go:108 (github.com/alouca/gosnmp.Unmarshal) SNMP Packet is GetResponse
2016/08/30 15:32:30 [DEBUG] packet.go:109 (github.com/alouca/gosnmp.Unmarshal) PDU Size is 36
2016/08/30 15:32:30 [DEBUG] packet.go:125 (github.com/alouca/gosnmp.Unmarshal) Parsed Request ID: 0
2016/08/30 15:32:30 [DEBUG] packet.go:150 (github.com/alouca/gosnmp.Unmarshal) Request ID: 0 Error: 0 Error Index: 0
2016/08/30 15:32:30 [DEBUG] packet.go:161 (github.com/alouca/gosnmp.Unmarshal) Parsing var bind response (Cursor at 26/51)
2016/08/30 15:32:30 [DEBUG] packet.go:170 (github.com/alouca/gosnmp.Unmarshal) Varbind length: 2/23
2016/08/30 15:32:30 [DEBUG] packet.go:172 (github.com/alouca/gosnmp.Unmarshal) Parsing OID (Cursor at 28)
2016/08/30 15:32:30 [DEBUG] packet.go:182 (github.com/alouca/gosnmp.Unmarshal) OID (&{ObjectIdentifier 2 8 [43 6 1 2 1 1 5 0] 0xc821d54f40}) Field was 8 bytes
2016/08/30 15:32:30 [DEBUG] packet.go:191 (github.com/alouca/gosnmp.Unmarshal) Value field was 11 bytes
2016/08/30 15:32:30 [DEBUG] packet.go:193 (github.com/alouca/gosnmp.Unmarshal) Varbind decoding success
2016/08/30 15:32:30 [DEBUG] packet.go:51 (github.com/alouca/gosnmp.Unmarshal) Begin SNMP Packet unmarshal
2016/08/30 15:32:30 [DEBUG] packet.go:69 (github.com/alouca/gosnmp.Unmarshal) Packet sanity verified, we got all the bytes (40)
2016/08/30 15:32:30 [DEBUG] packet.go:84 (github.com/alouca/gosnmp.Unmarshal) Parsed Version 1
2016/08/30 15:32:30 [DEBUG] packet.go:95 (github.com/alouca/gosnmp.Unmarshal) Parsed community SiAmFa�#
2016/08/30 15:32:30 [DEBUG] packet.go:105 (github.com/alouca/gosnmp.Unmarshal) Unsupported SNMP Packet Type Integer
2016/08/30 15:32:30 [DEBUG] packet.go:202 (github.com/alouca/gosnmp.Unmarshal) PDU Size is 4
Ip: 10.48.78.92
2016/08/30 15:32:30 [DEBUG] packet.go:51 (github.com/alouca/gosnmp.Unmarshal) Begin SNMP Packet unmarshal
2016/08/30 15:32:30 [DEBUG] packet.go:69 (github.com/alouca/gosnmp.Unmarshal) Packet sanity verified, we got all the bytes (73)
2016/08/30 15:32:30 [DEBUG] packet.go:84 (github.com/alouca/gosnmp.Unmarshal) Parsed Version 1
2016/08/30 15:32:30 [DEBUG] packet.go:95 (github.com/alouca/gosnmp.Unmarshal) Parsed community public
2016/08/30 15:32:30 [DEBUG] packet.go:108 (github.com/alouca/gosnmp.Unmarshal) SNMP Packet is GetResponse
2016/08/30 15:32:30 [DEBUG] packet.go:109 (github.com/alouca/gosnmp.Unmarshal) PDU Size is 60
2016/08/30 15:32:30 [DEBUG] packet.go:125 (github.com/alouca/gosnmp.Unmarshal) Parsed Request ID: 0
2016/08/30 15:32:30 [DEBUG] packet.go:150 (github.com/alouca/gosnmp.Unmarshal) Request ID: 0 Error: 0 Error Index: 0
2016/08/30 15:32:30 [DEBUG] packet.go:161 (github.com/alouca/gosnmp.Unmarshal) Parsing var bind response (Cursor at 26/75)
2016/08/30 15:32:30 [DEBUG] packet.go:170 (github.com/alouca/gosnmp.Unmarshal) Varbind length: 2/47
2016/08/30 15:32:30 [DEBUG] packet.go:172 (github.com/alouca/gosnmp.Unmarshal) Parsing OID (Cursor at 28)
2016/08/30 15:32:30 [DEBUG] packet.go:182 (github.com/alouca/gosnmp.Unmarshal) OID (&{ObjectIdentifier 2 8 [43 6 1 2 1 1 1 0] 0xc821d55d00}) Field was 8 bytes
2016/08/30 15:32:30 [DEBUG] packet.go:191 (github.com/alouca/gosnmp.Unmarshal) Value field was 35 bytes
2016/08/30 15:32:30 [DEBUG] packet.go:193 (github.com/alouca/gosnmp.Unmarshal) Varbind decoding success
map[ip:10.3.122.51 sysName:PRODSESCARA sysDescr:Avaya SIP Enablement Services (SES) community:public]
********************************************************_184
Ip: 10.49.134.110
Ip: 10.48.18.123
Ip: 10.49.110.149
Ip: 10.48.79.206
Ip: 10.47.12.166
2016/08/30 15:32:30 [DEBUG] packet.go:51 (github.com/alouca/gosnmp.Unmarshal) Begin SNMP Packet unmarshal
2016/08/30 15:32:30 [DEBUG] packet.go:69 (github.com/alouca/gosnmp.Unmarshal) Packet sanity verified, we got all the bytes (40)
2016/08/30 15:32:30 [DEBUG] packet.go:84 (github.com/alouca/gosnmp.Unmarshal) Parsed Version 1
2016/08/30 15:32:30 [DEBUG] packet.go:95 (github.com/alouca/gosnmp.Unmarshal) Parsed community SiAmFaO�
2016/08/30 15:32:30 [DEBUG] packet.go:233 (github.com/alouca/gosnmp.parseField) Field length is padded to 108 bytes
2016/08/30 15:32:30 [DEBUG] packet.go:234 (github.com/alouca/gosnmp.parseField) Decoded final length: 145244228500324865
2016/08/30 15:32:30 [DEBUG] packet.go:98 (github.com/alouca/gosnmp.Unmarshal) Unable to parse _SNMP PDU: Unable to parse BER: provided data length is longer than actual data (145244228500324865 vs 27)
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x47ba38]
goroutine 907 [running]:
panic(0x683300, 0xc82000a0e0)
/usr/local/go/src/runtime/panic.go:464 +0x3e6
github.com/dirk/ref.GetSNMP(0xc8200c2060, 0xc8200c20c0, 0x36b)
/home/id829625/work/src/github.com/dirk/ref/ref.go:358 +0xd88
created by github.com/dirk/ref.SNMPDiscover
/home/id829625/work/src/github.com/dirk/ref/ref.go:304 +0x508
id829625@bbeb0dae6899:~/work/src/github.com/dirk/discovery$
we test some switch machines, and often get "Request ID mismatch" tips. So,i check the packages with wireshark, and find many the same response packages.
I try to fix the bug, in func (x *GoSNMP) sendPacket(packet *SnmpPacket) (*SnmpPacket, error) {...}
i use for {...} replace to once Read. It works well ! (ps: Ignore my poor English)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.