summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2023-04-17 23:12:04 +0300
committerPaul Buetow <paul@buetow.org>2023-04-17 23:12:04 +0300
commit204c0c88104ce130bdeabfd73c735b7ef33e2f57 (patch)
tree3ff643babafedee47d40fbe6645fe2ab93d32799 /main.go
parent6b5ed019b50fdec4ab91922708390cb12c9a814e (diff)
only send one report
Diffstat (limited to 'main.go')
-rw-r--r--main.go13
1 files changed, 5 insertions, 8 deletions
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)
+ }
}