cauto 2 years ago
parent
commit
51ff67ceca
2 changed files with 4 additions and 4 deletions
  1. 1 1
      internal/task/cmd/cmd.go
  2. 3 3
      internal/task/ping.go

+ 1 - 1
internal/task/cmd/cmd.go

@@ -66,7 +66,7 @@ func StartPingStart(ctx context.Context) error {
 	}
 
 	if nodePing.Int() == 1 {
-		s := fmt.Sprintf("0 0 2 * * *", pingconfig.PingTime)
+		s := fmt.Sprintf("0 */%d * * * *", pingconfig.PingTime)
 		_, err = gcron.AddSingleton(ctx, s, func(ctx context.Context) {
 			go task.Ping(ctx)
 		}, "ping_status")

+ 3 - 3
internal/task/ping.go

@@ -73,7 +73,7 @@ func PingTask(ctx context.Context, t string, wg *sync.WaitGroup, pingType int, h
 
 			if rest.Error() == nil {
 				delay := rest.Result()
-				glog.Debug(ctx, "[func:IcmpPing] Finish Addr:", addr, delay, "ms")
+				glog.Info(ctx, "[func:IcmpPing] Finish Addr:", addr, delay, "ms")
 				stat.AvgDelay = stat.AvgDelay + rest.Result()
 				if stat.MaxDelay < delay {
 					stat.MaxDelay = delay
@@ -83,7 +83,7 @@ func PingTask(ctx context.Context, t string, wg *sync.WaitGroup, pingType int, h
 				}
 				stat.RevcPk = stat.RevcPk + 1
 			} else {
-				glog.Debug(ctx, "[func:StartPing IcmpPing] ID:", i, " IP:", addr, "| err:", rest.Error())
+				glog.Info(ctx, "[func:StartPing IcmpPing] ID:", i, " IP:", addr, "| err:", rest.Error())
 				lossPK = lossPK + 1
 			}
 			stat.SendPk = stat.SendPk + 1
@@ -96,7 +96,7 @@ func PingTask(ctx context.Context, t string, wg *sync.WaitGroup, pingType int, h
 		} else {
 			stat.AvgDelay = 0.0
 		}
-		glog.Debug(ctx, "[func:IcmpPing] Finish Addr:", addr, " MaxDelay:", stat.MaxDelay, " MinDelay:", stat.MinDelay, " AvgDelay:", stat.AvgDelay, " Revc:", stat.RevcPk, " LossPK:", stat.LossPk)
+		glog.Info(ctx, "[func:IcmpPing] Finish Addr:", addr, " MaxDelay:", stat.MaxDelay, " MinDelay:", stat.MinDelay, " AvgDelay:", stat.AvgDelay, " Revc:", stat.RevcPk, " LossPK:", stat.LossPk)
 	} else {
 		stat.AvgDelay = 0.00
 		stat.MinDelay = 0.00