Skip to content

Commit

Permalink
renaming & logging
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFireMike committed Mar 5, 2021
1 parent 45d536b commit 830677f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions core/network/snmp_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ func (s *SNMPClient) SNMPWalk(ctx context.Context, oid string) ([]SNMPResponse,
var err error
if s.client.Version != gosnmp.Version1 {
response, err = s.client.BulkWalkAll(oid)
if err != nil {
log.Ctx(ctx).Trace().Err(err).Msg("bulk walk failed")
}
}
if s.client.Version == gosnmp.Version1 || err != nil {
response, err = s.client.WalkAll(oid)
Expand Down
6 changes: 3 additions & 3 deletions core/request/check_interface_metrics_request_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ out:
}
}

readInterfacesResponse.Interfaces = removeInterface(readInterfacesResponse.Interfaces, filterIndices, 0)
readInterfacesResponse.Interfaces = filterInterfaces(readInterfacesResponse.Interfaces, filterIndices, 0)

return readInterfacesResponse, nil
}

func removeInterface(interfaces []device.Interface, toRemove []int, alreadyRemoved int) []device.Interface {
func filterInterfaces(interfaces []device.Interface, toRemove []int, alreadyRemoved int) []device.Interface {
if len(toRemove) == 0 {
return interfaces
}
return append(interfaces[:toRemove[0]-alreadyRemoved], removeInterface(interfaces[toRemove[0]+1-alreadyRemoved:], toRemove[1:], toRemove[0]+1)...)
return append(interfaces[:toRemove[0]-alreadyRemoved], filterInterfaces(interfaces[toRemove[0]+1-alreadyRemoved:], toRemove[1:], toRemove[0]+1)...)
}

func addCheckInterfacePerformanceData(interfaces []device.Interface, r *monitoringplugin.Response) error {
Expand Down
2 changes: 1 addition & 1 deletion core/request/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestRemoveInterfaces(t *testing.T) {
toRemove = append(toRemove, j)
}
}
interfaces = removeInterface(interfaces, toRemove, 0)
interfaces = filterInterfaces(interfaces, toRemove, 0)
assert.Equal(t, i/2, len(interfaces), "expected removed length and actual length differs")
}
}

0 comments on commit 830677f

Please sign in to comment.