Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
Added a configugration option that instructs GoSNMP to allow a set of…
Browse files Browse the repository at this point in the history
… OIDs that aren't in a strictly increasing order. (prometheus#759)

Signed-off-by: Matti Saarinen <[email protected]>
  • Loading branch information
mjsaarin authored Jun 21, 2022
1 parent c38cee6 commit f73fb5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ func ScrapeTarget(ctx context.Context, target string, config *config.Module, log
snmp.UseUnconnectedUDPSocket = config.WalkParams.UseUnconnectedUDPSocket
snmp.LocalAddr = *srcAddress

// Allow a set of OIDs that aren't in a strictly increasing order
if config.WalkParams.AllowNonIncreasingOIDs {
snmp.AppOpts = make(map[string]interface{})
snmp.AppOpts["c"] = true
}

var sent time.Time
snmp.OnSent = func(x *gosnmp.GoSNMP) {
sent = time.Now()
Expand Down
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var (
Timeout: time.Second * 5,
Auth: DefaultAuth,
UseUnconnectedUDPSocket: false,
AllowNonIncreasingOIDs: false,
}
DefaultModule = Module{
WalkParams: DefaultWalkParams,
Expand All @@ -69,6 +70,7 @@ type WalkParams struct {
Timeout time.Duration `yaml:"timeout,omitempty"`
Auth Auth `yaml:"auth,omitempty"`
UseUnconnectedUDPSocket bool `yaml:"use_unconnected_udp_socket,omitempty"`
AllowNonIncreasingOIDs bool `yaml:"allow_nonincreasing_oids,omitempty"`
}

type Module struct {
Expand Down

0 comments on commit f73fb5e

Please sign in to comment.