This commit is contained in:
insanity 2018-09-18 22:38:20 +09:00
parent aefdb4d724
commit 5f0c3e9fc6
2 changed files with 9 additions and 5 deletions

View File

@ -38,6 +38,7 @@ func processPrepacket(service *omd.Service, pingOption ounp.Option, matchCtx *os
LOOP: LOOP:
for indexR := 0; indexR < pingOption.GetRetry(); indexR++ { for indexR := 0; indexR < pingOption.GetRetry(); indexR++ {
startTime := time.Now()
matchCtx.InitAttribute() matchCtx.InitAttribute()
conn, err := getConnection(service, pingOption) conn, err := getConnection(service, pingOption)
if nil != err { if nil != err {
@ -128,8 +129,9 @@ LOOP:
conn.Close() conn.Close()
if isMatched { if isMatched {
elapsed := time.Since(startTime)
pingResult.Responses[indexR] = &ounp.PingResponse{ pingResult.Responses[indexR] = &ounp.PingResponse{
Time: 0, Time: float32(elapsed),
} }
} }
} }
@ -147,6 +149,7 @@ func processPostpacket(service *omd.Service, pingOption ounp.Option, matchCtx *o
LOOP: LOOP:
for indexR := 0; indexR < pingOption.GetRetry(); indexR++ { for indexR := 0; indexR < pingOption.GetRetry(); indexR++ {
startTime := time.Now()
matchCtx.InitAttribute() matchCtx.InitAttribute()
packetCount := _matcher.PacketCount(matchCtx) packetCount := _matcher.PacketCount(matchCtx)
@ -215,8 +218,9 @@ LOOP:
conn.Close() conn.Close()
if isMatched { if isMatched {
elapsed := time.Since(startTime)
pingResult.Responses[indexR] = &ounp.PingResponse{ pingResult.Responses[indexR] = &ounp.PingResponse{
Time: 0, Time: float32(elapsed),
} }
} }
} }