probe/snmp/snmp_test.go

60 lines
890 B
Go
Raw Normal View History

2018-08-15 06:18:40 +00:00
package snmp
import (
"sync"
"testing"
)
type Agent struct {
ip string
port int
community string
}
func TestV2c(t *testing.T) {
oids := map[string]string{
"1.3.6.1.2.1.1.5.0": "sysName",
}
agents := []Agent{
Agent{
ip: "192.168.1.229",
port: 161,
community: "test1252serc",
},
Agent{
ip: "192.168.1.254",
port: 161,
community: "loafle",
},
Agent{
ip: "192.168.1.99",
port: 161,
community: "public",
},
Agent{
ip: "192.168.1.1",
port: 161,
community: "public",
},
Agent{
ip: "192.168.1.2",
port: 161,
community: "public",
},
}
var wg sync.WaitGroup
wg.Add(len(agents))
for _, agent := range agents {
go func(a Agent) {
res, _ := getV2(a.ip, a.port, a.community, oids)
t.Log(res)
defer wg.Done()
}(agent)
}
wg.Wait()
}