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

Commit

Permalink
Add srcAddress feature to send snmp package (prometheus#749)
Browse files Browse the repository at this point in the history
Signed-off-by: Jasper <[email protected]>

Co-authored-by: Ben Kochie <[email protected]>
  • Loading branch information
dmmjy9 and SuperQ authored May 13, 2022
1 parent 6e36e46 commit 8678b60
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ var (
// 64-bit float mantissa: https://en.wikipedia.org/wiki/Double-precision_floating-point_format
float64Mantissa uint64 = 9007199254740992
wrapCounters = kingpin.Flag("snmp.wrap-large-counters", "Wrap 64-bit counters to avoid floating point rounding.").Default("true").Bool()
srcAddress = kingpin.Flag("snmp.source-address", "Source address to send snmp from in the format 'address:port' to use when connecting targets. If the port parameter is empty or '0', as in '127.0.0.1:' or '[::1]:0', a source port number is automatically (random) chosen.").Default("").String()
)

// Types preceded by an enum with their actual type.
Expand Down Expand Up @@ -123,6 +124,7 @@ func ScrapeTarget(ctx context.Context, target string, config *config.Module, log
snmp.Retries = config.WalkParams.Retries
snmp.Timeout = config.WalkParams.Timeout
snmp.UseUnconnectedUDPSocket = config.WalkParams.UseUnconnectedUDPSocket
snmp.LocalAddr = *srcAddress

var sent time.Time
snmp.OnSent = func(x *gosnmp.GoSNMP) {
Expand Down

0 comments on commit 8678b60

Please sign in to comment.