From 204c0c88104ce130bdeabfd73c735b7ef33e2f57 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 17 Apr 2023 23:12:04 +0300 Subject: only send one report --- main.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 6d661d7..bd13680 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,6 @@ package main import ( "context" "flag" - "fmt" "log" "sync" "time" @@ -54,13 +53,7 @@ func main() { defer cancel() output, status := check.execute(ctx) - stateChanged := state.update(name, status) - - if status != ok || stateChanged { - subject := fmt.Sprintf("GOGIOS %s: %s", codeToString(status), name) - notify(config, subject, output) - } - + state.update(name, output, status) }(entry.name, entry.check) } @@ -70,4 +63,8 @@ func main() { if err := state.persist(); err != nil { notifyError(config, err) } + + if subject, body, changed := state.report(); changed { + notify(config, subject, body) + } } -- cgit v1.2.3