summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-01-18 22:19:11 +0200
committerPaul Buetow <paul@buetow.org>2026-01-18 22:19:11 +0200
commit64c4f058e6f9975effb38e952531458054f512c3 (patch)
tree592b43fad5805e6d1664ba79b58ff1e7b357edfc
parent1f20bed4e77d2238e2b613b060fd05adb58ba116 (diff)
add status page URL to email notifications
Include a configurable link to the HTML status page in email notifications. Defaults to https://gogios.buetow.org but can be customized via the StatusPageURL config option. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
-rw-r--r--internal/config.go7
-rw-r--r--internal/run.go2
-rw-r--r--internal/state.go8
3 files changed, 15 insertions, 2 deletions
diff --git a/internal/config.go b/internal/config.go
index 25a9ddd..5d172d6 100644
--- a/internal/config.go
+++ b/internal/config.go
@@ -16,6 +16,7 @@ type config struct {
StateDir string `json:"StateDir,omitempty"`
HTMLStatusFile string `json:"HTMLStatusFile,omitempty"` // Path to HTML status file
HTMLDisable bool `json:"HTMLDisable,omitempty"` // Disable HTML status page generation
+ StatusPageURL string `json:"StatusPageURL,omitempty"` // URL to the HTML status page for email notifications
CheckTimeoutS int
CheckConcurrency int
StaleThreshold int `json:"StaleThreshold,omitempty"`
@@ -71,6 +72,12 @@ func newConfig(configFile string) (config, error) {
log.Println("Set HTMLStatusFile to " + conf.HTMLStatusFile)
}
+ // Default URL for the status page link in email notifications
+ if conf.StatusPageURL == "" {
+ conf.StatusPageURL = "https://gogios.buetow.org"
+ log.Println("Set StatusPageURL to " + conf.StatusPageURL)
+ }
+
return conf, nil
}
diff --git a/internal/run.go b/internal/run.go
index f45f937..348bdd9 100644
--- a/internal/run.go
+++ b/internal/run.go
@@ -30,7 +30,7 @@ func Run(ctx context.Context, configFile string, renotify, force bool) {
notifyError(conf, err)
}
- subject, body, doNotify := state.report(renotify, force)
+ subject, body, doNotify := state.report(renotify, force, conf.StatusPageURL)
if doNotify {
if err := notify(conf, subject, body); err != nil {
log.Println("error:", err)
diff --git a/internal/state.go b/internal/state.go
index 516e63a..cb2c665 100644
--- a/internal/state.go
+++ b/internal/state.go
@@ -130,7 +130,9 @@ func (s state) persist() error {
return os.WriteFile(s.stateFile, jsonData, os.ModePerm)
}
-func (s state) report(renotify, force bool) (string, string, bool) {
+// report generates the notification email content.
+// statusPageURL is included as a link to the HTML status page.
+func (s state) report(renotify, force bool, statusPageURL string) (string, string, bool) {
var sb strings.Builder
sb.WriteString("This is the recent Gogios report!\n\n")
@@ -154,6 +156,10 @@ func (s state) report(renotify, force bool) (string, string, bool) {
sb.WriteString("There are no stale alerts...\n\n")
}
+ sb.WriteString("# Status page:\n\n")
+ sb.WriteString(statusPageURL)
+ sb.WriteString("\n\n")
+
sb.WriteString("Have a nice day!\n")
subject := fmt.Sprintf("GOGIOS Report [C:%d W:%d U:%d S:%d OK:%d]",