From f83ce9993fbed63da201e8f6cffda1289fcd2fbd Mon Sep 17 00:00:00 2001 From: Jackson Sabey Date: Sat, 31 Aug 2024 14:52:39 -0700 Subject: [PATCH] better debugging --- watchdog/alerting.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/watchdog/alerting.go b/watchdog/alerting.go index 243ce914..c57a0f7b 100644 --- a/watchdog/alerting.go +++ b/watchdog/alerting.go @@ -34,12 +34,16 @@ func handleAlertsToTrigger(ep *endpoint.Endpoint, result *endpoint.Result, alert // Determine if an initial alert should be sent sendInitialAlert := !endpointAlert.Triggered // Determine if a reminder should be sent - sendReminder := endpointAlert.Triggered && endpointAlert.RepeatInterval > 0 && - (ep.LastReminderSent.IsZero() || time.Since(ep.LastReminderSent) >= endpointAlert.RepeatInterval) + var lastReminder time.Duration + if !ep.LastReminderSent.IsZero() { + lastReminder = time.Since(ep.LastReminderSent) + } + sendReminder := endpointAlert.Triggered && endpointAlert.RepeatInterval > 0 && lastReminder >= endpointAlert.RepeatInterval // If neither initial alert nor reminder needs to be sent, skip to the next alert if !sendInitialAlert && !sendReminder { if debug { - log.Printf("[watchdog.handleAlertsToTrigger] Alert for endpoint=%s with description='%s' is not due for triggering or reminding, skipping", ep.Name, endpointAlert.GetDescription()) + log.Printf("[watchdog.handleAlertsToTrigger] Alert for endpoint=%s with description='%s' is not due for triggering or reminding (interval: %s last: %s), skipping", + ep.Name, endpointAlert.GetDescription(), endpointAlert.RepeatInterval, lastReminder) } continue }