remove configuration deadline of ping plugin
This commit is contained in:
parent
edd380fabc
commit
feb99900a9
|
@ -26,11 +26,7 @@ targets = [
|
||||||
|
|
||||||
## If set, the time to wait for a ping response in seconds. Operates like
|
## If set, the time to wait for a ping response in seconds. Operates like
|
||||||
## the "-W" option of the ping command.
|
## the "-W" option of the ping command.
|
||||||
# timeout = 1.0
|
timeout = 1.0
|
||||||
|
|
||||||
## If set, the total ping deadline, in seconds. Operates like the -w option
|
|
||||||
## of the ping command.
|
|
||||||
# deadline = 10
|
|
||||||
|
|
||||||
## Interface or source address to send ping from. Operates like the -I or -S
|
## Interface or source address to send ping from. Operates like the -I or -S
|
||||||
## option of the ping command.
|
## option of the ping command.
|
||||||
|
|
|
@ -29,7 +29,6 @@ type PingInstance struct {
|
||||||
Count int `toml:"count"` // ping -c <COUNT>
|
Count int `toml:"count"` // ping -c <COUNT>
|
||||||
PingInterval float64 `toml:"ping_interval"` // ping -i <INTERVAL>
|
PingInterval float64 `toml:"ping_interval"` // ping -i <INTERVAL>
|
||||||
Timeout float64 `toml:"timeout"` // ping -W <TIMEOUT>
|
Timeout float64 `toml:"timeout"` // ping -W <TIMEOUT>
|
||||||
Deadline int `toml:"deadline"` // ping -w <DEADLINE>
|
|
||||||
Interface string `toml:"interface"` // ping -I/-S <INTERFACE/SRC_ADDR>
|
Interface string `toml:"interface"` // ping -I/-S <INTERFACE/SRC_ADDR>
|
||||||
IPv6 bool `toml:"ipv6"` // Whether to resolve addresses using ipv6 or not.
|
IPv6 bool `toml:"ipv6"` // Whether to resolve addresses using ipv6 or not.
|
||||||
Size *int `toml:"size"` // Packet size
|
Size *int `toml:"size"` // Packet size
|
||||||
|
@ -51,15 +50,11 @@ func (ins *PingInstance) Init() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ins.Timeout == 0 {
|
if ins.Timeout == 0 {
|
||||||
ins.calcTimeout = time.Duration(5) * time.Second
|
ins.calcTimeout = time.Duration(3) * time.Second
|
||||||
} else {
|
} else {
|
||||||
ins.calcTimeout = time.Duration(ins.Timeout) * time.Second
|
ins.calcTimeout = time.Duration(ins.Timeout) * time.Second
|
||||||
}
|
}
|
||||||
|
|
||||||
if ins.Deadline <= 0 {
|
|
||||||
ins.Deadline = 5
|
|
||||||
}
|
|
||||||
|
|
||||||
if ins.Interface != "" {
|
if ins.Interface != "" {
|
||||||
if addr := net.ParseIP(ins.Interface); addr != nil {
|
if addr := net.ParseIP(ins.Interface); addr != nil {
|
||||||
ins.sourceAddress = ins.Interface
|
ins.sourceAddress = ins.Interface
|
||||||
|
@ -236,10 +231,7 @@ func (ins *PingInstance) ping(destination string) (*pingStats, error) {
|
||||||
|
|
||||||
pinger.Source = ins.sourceAddress
|
pinger.Source = ins.sourceAddress
|
||||||
pinger.Interval = ins.calcInterval
|
pinger.Interval = ins.calcInterval
|
||||||
|
pinger.Timeout = ins.calcTimeout
|
||||||
if ins.Deadline > 0 {
|
|
||||||
pinger.Timeout = time.Duration(ins.Deadline) * time.Second
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get Time to live (TTL) of first response, matching original implementation
|
// Get Time to live (TTL) of first response, matching original implementation
|
||||||
once := &sync.Once{}
|
once := &sync.Once{}
|
||||||
|
|
Loading…
Reference in New Issue