package probe type SyncAction uint8 const ( // SyncActionReplace indicates a full sync where the provided configs should replace all existing probes for the system. SyncActionReplace SyncAction = iota // SyncActionUpsert indicates an incremental sync where the provided config should be added or updated. SyncActionUpsert // SyncActionDelete indicates an incremental sync where the provided config should be removed. SyncActionDelete ) // Config defines a network probe task sent from hub to agent. type Config struct { // ID is the stable network_probes record ID generated by the hub. ID string `cbor:"0,keyasint"` Target string `cbor:"1,keyasint"` Protocol string `cbor:"2,keyasint"` // "icmp", "tcp", or "http" Port uint16 `cbor:"3,keyasint,omitempty"` Interval uint16 `cbor:"4,keyasint"` // seconds } // SyncRequest defines an incremental or full probe sync request sent to the agent. type SyncRequest struct { Action SyncAction `cbor:"0,keyasint"` Config Config `cbor:"1,keyasint,omitempty"` Configs []Config `cbor:"2,keyasint,omitempty"` RunNow bool `cbor:"3,keyasint,omitempty"` } // SyncResponse returns the immediate result for an upsert when requested. type SyncResponse struct { Result Result `cbor:"0,keyasint,omitempty"` } // Result holds aggregated probe results for a single target. // // 0: avg response in ms // // 1: average response over the last hour in ms // // 2: min response over the last hour in ms // // 3: max response over the last hour in ms // // 4: packet loss percentage over the last hour (0-100) type Result []float64 // Get returns the value at the specified index or 0 if the index is out of range. func (r Result) Get(index int) float64 { if index < len(r) { return r[index] } return 0 }