remove configuration deadline of ping plugin

This commit is contained in:
Ulric Qin 2022-04-19 18:52:26 +08:00
parent edd380fabc
commit feb99900a9
2 changed files with 3 additions and 15 deletions

View File

@ -26,11 +26,7 @@ targets = [
## If set, the time to wait for a ping response in seconds. Operates like
## the "-W" option of the ping command.
# timeout = 1.0
## If set, the total ping deadline, in seconds. Operates like the -w option
## of the ping command.
# deadline = 10
timeout = 1.0
## Interface or source address to send ping from. Operates like the -I or -S
## option of the ping command.

View File

@ -29,7 +29,6 @@ type PingInstance struct {
Count int `toml:"count"` // ping -c <COUNT>
PingInterval float64 `toml:"ping_interval"` // ping -i <INTERVAL>
Timeout float64 `toml:"timeout"` // ping -W <TIMEOUT>
Deadline int `toml:"deadline"` // ping -w <DEADLINE>
Interface string `toml:"interface"` // ping -I/-S <INTERFACE/SRC_ADDR>
IPv6 bool `toml:"ipv6"` // Whether to resolve addresses using ipv6 or not.
Size *int `toml:"size"` // Packet size
@ -51,15 +50,11 @@ func (ins *PingInstance) Init() error {
}
if ins.Timeout == 0 {
ins.calcTimeout = time.Duration(5) * time.Second
ins.calcTimeout = time.Duration(3) * time.Second
} else {
ins.calcTimeout = time.Duration(ins.Timeout) * time.Second
}
if ins.Deadline <= 0 {
ins.Deadline = 5
}
if ins.Interface != "" {
if addr := net.ParseIP(ins.Interface); addr != nil {
ins.sourceAddress = ins.Interface
@ -236,10 +231,7 @@ func (ins *PingInstance) ping(destination string) (*pingStats, error) {
pinger.Source = ins.sourceAddress
pinger.Interval = ins.calcInterval
if ins.Deadline > 0 {
pinger.Timeout = time.Duration(ins.Deadline) * time.Second
}
pinger.Timeout = ins.calcTimeout
// Get Time to live (TTL) of first response, matching original implementation
once := &sync.Once{}