Fix #773
This commit is contained in:
parent
ee7b225272
commit
e5503c56ad
|
@ -44,6 +44,9 @@ type Host struct {
|
||||||
getOids []Data
|
getOids []Data
|
||||||
bulkOids []Data
|
bulkOids []Data
|
||||||
tables []HostTable
|
tables []HostTable
|
||||||
|
// array of processed oids
|
||||||
|
// to skip oid duplication
|
||||||
|
processedOids []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Table struct {
|
type Table struct {
|
||||||
|
@ -714,8 +717,15 @@ func (h *Host) HandleResponse(oids map[string]Data, result *gosnmp.SnmpPacket, a
|
||||||
var lastOid string
|
var lastOid string
|
||||||
for _, variable := range result.Variables {
|
for _, variable := range result.Variables {
|
||||||
lastOid = variable.Name
|
lastOid = variable.Name
|
||||||
// Remove unwanted oid
|
nextresult:
|
||||||
|
// Get only oid wanted
|
||||||
for oid_key, oid := range oids {
|
for oid_key, oid := range oids {
|
||||||
|
// Skip oids already processed
|
||||||
|
for _, processedOid := range h.processedOids {
|
||||||
|
if variable.Name == processedOid {
|
||||||
|
break nextresult
|
||||||
|
}
|
||||||
|
}
|
||||||
if strings.HasPrefix(variable.Name, oid_key) {
|
if strings.HasPrefix(variable.Name, oid_key) {
|
||||||
switch variable.Type {
|
switch variable.Type {
|
||||||
// handle Metrics
|
// handle Metrics
|
||||||
|
@ -767,6 +777,7 @@ func (h *Host) HandleResponse(oids map[string]Data, result *gosnmp.SnmpPacket, a
|
||||||
fields := make(map[string]interface{})
|
fields := make(map[string]interface{})
|
||||||
fields[string(field_name)] = variable.Value
|
fields[string(field_name)] = variable.Value
|
||||||
|
|
||||||
|
h.processedOids = append(h.processedOids, variable.Name)
|
||||||
acc.AddFields(field_name, fields, tags)
|
acc.AddFields(field_name, fields, tags)
|
||||||
case gosnmp.NoSuchObject, gosnmp.NoSuchInstance:
|
case gosnmp.NoSuchObject, gosnmp.NoSuchInstance:
|
||||||
// Oid not found
|
// Oid not found
|
||||||
|
|
Loading…
Reference in New Issue