Handle empty targets case in Evaluate with StatusUnknown

This commit is contained in:
nemunaire 2026-04-16 04:43:40 +07:00
commit b147fa2f31

View file

@ -67,7 +67,18 @@ const (
)
// Evaluate checks the ping data against the given thresholds.
// StatusUnknown indicates the check could not be performed.
const StatusUnknown = 0
func Evaluate(data *PingData, warningRTT, criticalRTT, warningPacketLoss, criticalPacketLoss float64) EvaluateResult {
if len(data.Targets) == 0 {
return EvaluateResult{
Status: StatusUnknown,
Message: "No targets to ping",
Code: "ping_no_targets",
}
}
overallStatus := StatusOK
var summaryParts []string