Anthony Romano b1d41016b2 vendor: only vendor on emitted binaries | há 8 anos atrás | |
---|---|---|
.. | ||
.gitignore | há 8 anos atrás | |
LICENSE | há 8 anos atrás | |
README.md | há 8 anos atrás | |
prober.go | há 8 anos atrás | |
server.go | há 8 anos atrás | |
status.go | há 8 anos atrás |
We first need to serve the probing HTTP handler.
http.HandleFunc("/health", probing.NewHandler())
err := http.ListenAndServe(":12345", nil)
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
Now we can start to probe the endpoint.
id := "example"
probingInterval = 5 * time.Second
url := "http://example.com:12345/health"
p.AddHTTP(id, probingInterval, url)
time.Sleep(13 * time.Second)
status, err := p.Status(id)
fmt.Printf("Total Probing: %d, Total Loss: %d, Estimated RTT: %v, Estimated Clock Difference: %v\n",
status.Total(), status.Loss(), status.SRTT(), status.ClockDiff())
// Total Probing: 2, Total Loss: 0, Estimated RTT: 320.771µs, Estimated Clock Difference: -35.869µs