fix(inputs.ping): Add option to force ipv4 (#15011)
This commit is contained in:
parent
86aedb4e8e
commit
60adc92014
|
|
@ -80,7 +80,12 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
|||
## etc) will be ignored.
|
||||
# arguments = ["-c", "3"]
|
||||
|
||||
## Use only IPv6 addresses when resolving a hostname.
|
||||
## Use only IPv4 addresses when resolving a hostname. By default, both IPv4
|
||||
## and IPv6 can be used.
|
||||
# ipv4 = false
|
||||
|
||||
## Use only IPv6 addresses when resolving a hostname. By default, both IPv4
|
||||
## and IPv6 can be used.
|
||||
# ipv6 = false
|
||||
|
||||
## Number of data bytes to be sent. Corresponds to the "-s"
|
||||
|
|
|
|||
|
|
@ -73,6 +73,9 @@ type Ping struct {
|
|||
// other options (ping_interval, timeout, etc.) will be ignored
|
||||
Arguments []string
|
||||
|
||||
// Whether to resolve addresses using ipv4 or not.
|
||||
IPv4 bool
|
||||
|
||||
// Whether to resolve addresses using ipv6 or not.
|
||||
IPv6 bool
|
||||
|
||||
|
|
@ -129,7 +132,11 @@ func (p *Ping) nativePing(destination string) (*pingStats, error) {
|
|||
|
||||
pinger.SetPrivileged(true)
|
||||
|
||||
if p.IPv6 {
|
||||
if p.IPv4 && p.IPv6 {
|
||||
pinger.SetNetwork("ip")
|
||||
} else if p.IPv4 {
|
||||
pinger.SetNetwork("ip4")
|
||||
} else if p.IPv6 {
|
||||
pinger.SetNetwork("ip6")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,12 @@
|
|||
## etc) will be ignored.
|
||||
# arguments = ["-c", "3"]
|
||||
|
||||
## Use only IPv6 addresses when resolving a hostname.
|
||||
## Use only IPv4 addresses when resolving a hostname. By default, both IPv4
|
||||
## and IPv6 can be used.
|
||||
# ipv4 = false
|
||||
|
||||
## Use only IPv6 addresses when resolving a hostname. By default, both IPv4
|
||||
## and IPv6 can be used.
|
||||
# ipv6 = false
|
||||
|
||||
## Number of data bytes to be sent. Corresponds to the "-s"
|
||||
|
|
|
|||
Loading…
Reference in New Issue