Created
July 25, 2024 08:41
-
-
Save Hipska/6c19e707445029cae8abfac098405032 to your computer and use it in GitHub Desktop.
Implement trace route with pro-bing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
probing "github.com/prometheus-community/pro-bing" | |
) | |
func main() { | |
pinger, err := probing.NewPinger("reddit.com") | |
if err != nil { | |
panic(err) | |
} | |
//pinger.Count = 3 | |
pinger.TTL = 2 | |
err = pinger.Run() // Blocks until finished. | |
if err != nil { | |
panic(err) | |
} | |
stats := pinger.Statistics() // get send/receive/duplicate/rtt stats | |
println( | |
stats.PacketsRecv, | |
stats.PacketsSent, | |
stats.PacketsRecvDuplicates, | |
stats.PacketLoss, | |
stats.IPAddr.String(), | |
stats.Addr, | |
stats.MinRtt, | |
stats.MaxRtt, | |
stats.AvgRtt, | |
stats.StdDevRtt) | |
for i, rtt := range stats.Rtts { | |
println(i, rtt) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment