mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region,host): host health misc fix
Signed-off-by: wanyaoqi <d3lx.yq@gmail.com>
This commit is contained in:
@@ -132,7 +132,11 @@ func pingProbeNetwork(s *mcclient.ClientSession, net sNetwork) ([]influxdb.SMetr
|
||||
addrStr := addr.String()
|
||||
pingAddrs = append(pingAddrs, addrStr)
|
||||
}
|
||||
pingResults, err := Ping(pingAddrs)
|
||||
pingResults, err := Ping(pingAddrs,
|
||||
options.Options.PingProbeOptions.ProbeCount,
|
||||
options.Options.PingProbeOptions.TimeoutSecond,
|
||||
options.Options.PingProbeOptions.Debug,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Ping")
|
||||
}
|
||||
|
||||
@@ -22,8 +22,6 @@ import (
|
||||
"github.com/tatsushid/go-fastping"
|
||||
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudmon/options"
|
||||
)
|
||||
|
||||
type SPingResult struct {
|
||||
@@ -72,13 +70,13 @@ func (pr SPingResult) String() string {
|
||||
return fmt.Sprintf("%d packets transmitted, %d received, %d%% packet loss, rtt min/avg/max = %d/%d/%d ms", pr.count, len(pr.rtt), pr.Loss(), min/time.Millisecond, avg/time.Millisecond, max/time.Millisecond)
|
||||
}
|
||||
|
||||
func Ping(addrList []string) (map[string]*SPingResult, error) {
|
||||
func Ping(addrList []string, probeCount, timeoutSecond int, debug bool) (map[string]*SPingResult, error) {
|
||||
p := fastping.NewPinger()
|
||||
count := options.Options.PingProbeOptions.ProbeCount
|
||||
timeout := time.Second * time.Duration(options.Options.PingProbeOptions.TimeoutSecond)
|
||||
count := probeCount
|
||||
timeout := time.Second * time.Duration(timeoutSecond)
|
||||
p.MaxRTT = timeout
|
||||
p.Size = 64
|
||||
p.Debug = options.Options.PingProbeOptions.Debug
|
||||
p.Debug = debug
|
||||
result := make(map[string]*SPingResult)
|
||||
for _, addr := range addrList {
|
||||
result[addr] = NewPingResult(addr, count)
|
||||
|
||||
Reference in New Issue
Block a user