summaryrefslogtreecommitdiff
path: root/internal/config.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-08 10:57:45 +0200
committerPaul Buetow <paul@buetow.org>2026-02-08 10:57:45 +0200
commit81db39feafdc491658f8a10dc604be851a533ffc (patch)
tree9f84bcaaaef120520ebfc9823f0807abaadcd858 /internal/config.go
parent9c78a3666eddf3a6a3b82581e0353665aa3f6320 (diff)
feat: add peer failover alertingv1.4.0
Introduce peer URL monitoring with active/passive alert suppression, skip checks when passive, and bump version to v1.4.0. Co-authored-by: Cursor <cursoragent@cursor.com>
Diffstat (limited to 'internal/config.go')
-rw-r--r--internal/config.go49
1 files changed, 37 insertions, 12 deletions
diff --git a/internal/config.go b/internal/config.go
index ffc2353..21fbaec 100644
--- a/internal/config.go
+++ b/internal/config.go
@@ -5,22 +5,27 @@ import (
"fmt"
"io"
"log"
+ "net/url"
"os"
)
type config struct {
- EmailTo string
- EmailFrom string
- SMTPServer string `json:"SMTPServer,omitempty"`
- SMTPDisable bool `json:"SMTPDisable,omitempty"` // TODO: Document this option
- 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"`
- Federated []string `json:"Federated,omitempty"` // TODO: Document this option
+ EmailTo string
+ EmailFrom string
+ SMTPServer string `json:"SMTPServer,omitempty"`
+ SMTPDisable bool `json:"SMTPDisable,omitempty"` // TODO: Document this option
+ 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
+ PeerURL string `json:"PeerURL,omitempty"` // Peer Gogios JSON report URL
+ PeerStaleThresholdS int `json:"PeerStaleThresholdS,omitempty"`
+ PeerPrimaryName string `json:"PeerPrimaryName,omitempty"`
+ PeerSecondaryName string `json:"PeerSecondaryName,omitempty"`
+ CheckTimeoutS int
+ CheckConcurrency int
+ StaleThreshold int `json:"StaleThreshold,omitempty"`
+ Federated []string `json:"Federated,omitempty"` // TODO: Document this option
// MinNotifyIntervalS is the minimum interval in seconds between email notifications.
// When set > 0, Gogios batches notifications and only sends an email when:
// 1. The interval has elapsed since the last notification, AND
@@ -71,6 +76,26 @@ func newConfig(configFile string) (config, error) {
conf.StaleThreshold = 3600 // Default to 1 hour
}
+ if conf.PeerURL != "" {
+ if conf.PeerStaleThresholdS == 0 {
+ conf.PeerStaleThresholdS = 600 // Default to 10 minutes
+ }
+
+ if conf.PeerPrimaryName == "" {
+ hostname, err := os.Hostname()
+ if err != nil {
+ log.Fatal(err)
+ }
+ conf.PeerPrimaryName = hostname
+ }
+
+ if conf.PeerSecondaryName == "" {
+ if parsedURL, err := url.Parse(conf.PeerURL); err == nil && parsedURL.Hostname() != "" {
+ conf.PeerSecondaryName = parsedURL.Hostname()
+ }
+ }
+ }
+
if conf.PrometheusTimeoutS == 0 {
conf.PrometheusTimeoutS = 2 // Default to 2 seconds
}