github.com/netdata/go.d.plugin@v0.58.1/modules/ping/init.go (about) 1 // SPDX-License-Identifier: GPL-3.0-or-later 2 3 package ping 4 5 import ( 6 "errors" 7 "time" 8 ) 9 10 func (p *Ping) validateConfig() error { 11 if len(p.Hosts) == 0 { 12 return errors.New("'hosts' can't be empty") 13 } 14 if p.SendPackets <= 0 { 15 return errors.New("'send_packets' can't be <= 0") 16 } 17 return nil 18 } 19 20 func (p *Ping) initProber() (prober, error) { 21 mul := 0.9 22 if p.UpdateEvery > 1 { 23 mul = 0.95 24 } 25 deadline := time.Millisecond * time.Duration(float64(p.UpdateEvery)*mul*1000) 26 if deadline.Milliseconds() == 0 { 27 return nil, errors.New("zero ping deadline") 28 } 29 30 conf := pingProberConfig{ 31 privileged: p.Privileged, 32 packets: p.SendPackets, 33 iface: p.Interface, 34 interval: p.Interval.Duration, 35 deadline: deadline, 36 } 37 38 return p.newProber(conf, p.Logger), nil 39 }