This commit is contained in:
henrygd
2026-04-28 17:46:56 -04:00
parent b182b699d7
commit 891b03426f
12 changed files with 359 additions and 228 deletions

View File

@@ -38,15 +38,19 @@ type SyncResponse struct {
//
// 0: avg response in microseconds
//
// 1: average response over the last hour in microseconds
// 1: 1h average response in microseconds
//
// 2: min response over the last hour in microseconds
// 2: min response in microseconds
//
// 3: max response over the last hour in microseconds
// 3: 1h min response in microseconds
//
// 4: packet loss percentage (0-100)
// 4: max response in microseconds
//
// 5: packet loss percentage over the last hour (0-100)
// 5: 1h max response in microseconds
//
// 6: packet loss percentage (0-100)
//
// 7: 1h packet loss percentage (0-100)
type Result []float64
// Get returns the value at the specified index or 0 if the index is out of range.
@@ -56,3 +60,23 @@ func (r Result) Get(index int) float64 {
}
return 0
}
// Stats holds only 1m values for a single target, which are used for charts.
//
// 0: avg response in microseconds
//
// 1: min response in microseconds
//
// 2: max response in microseconds
//
// 3: packet loss percentage (0-100)
type Stats []float64
func (s Stats) FromResult(result Result) Stats {
return Stats{
result.Get(0), // avg response
result.Get(2), // min response
result.Get(4), // max response
result.Get(6), // packet loss
}
}