diff options
| author | Paul Buetow <paul@buetow.org> | 2023-04-17 23:12:04 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2023-04-17 23:12:04 +0300 |
| commit | 204c0c88104ce130bdeabfd73c735b7ef33e2f57 (patch) | |
| tree | 3ff643babafedee47d40fbe6645fe2ab93d32799 /main.go | |
| parent | 6b5ed019b50fdec4ab91922708390cb12c9a814e (diff) | |
only send one report
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -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) + } } |
