aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2021-06-09 17:55:50 -0400
committerMitchell Riedstra <mitch@riedstra.dev>2021-06-09 17:55:50 -0400
commit1d1f6d4fd023e0f9b9851aff259a0b9f022ed13f (patch)
tree068b2bc821ca76cf2fbb371e57e28279d547347a
parent6ec85b96ad4fee6ec1767f6b78f92a38ce658a06 (diff)
downloadcheckup-1d1f6d4fd023e0f9b9851aff259a0b9f022ed13f.tar.gz
checkup-1d1f6d4fd023e0f9b9851aff259a0b9f022ed13f.tar.xz
Add a nag option ( RenotifyInterval )
-rw-r--r--cmd/main/certs.go1
-rw-r--r--cmd/main/http.go2
-rw-r--r--cmd/main/main.go15
-rw-r--r--sample-config.yml4
4 files changed, 22 insertions, 0 deletions
diff --git a/cmd/main/certs.go b/cmd/main/certs.go
index 41ed1a8..d336283 100644
--- a/cmd/main/certs.go
+++ b/cmd/main/certs.go
@@ -22,6 +22,7 @@ func certWorker(jobs <-chan certCheck, msg chan<- *jobResponse) {
Id: cc.Host + ":" + cc.Port,
Message: s,
Err: err,
+ Time: time.Now(),
}
continue
}
diff --git a/cmd/main/http.go b/cmd/main/http.go
index fd6169e..8eb4990 100644
--- a/cmd/main/http.go
+++ b/cmd/main/http.go
@@ -3,6 +3,7 @@ package main
import (
"bytes"
"fmt"
+ "time"
"riedstra.dev/go/checkup"
)
@@ -22,6 +23,7 @@ func httpStatusWorker(jobs <-chan httpCheck, msg chan<- *jobResponse, timeout in
Id: hc.URL + "->" + string(hc.Code),
Message: s,
Err: err,
+ Time: time.Now(),
}
continue
}
diff --git a/cmd/main/main.go b/cmd/main/main.go
index 1b264a3..531b0ab 100644
--- a/cmd/main/main.go
+++ b/cmd/main/main.go
@@ -19,6 +19,7 @@ type jobResponse struct {
Id string
Message string
Err error
+ Time time.Time
}
type Config struct {
@@ -31,6 +32,7 @@ type Config struct {
StatusChecks map[string]*int `yaml:"StatusChecks"`
Workers int `yaml:"Workers"`
Interval int `yaml:"Interval"`
+ RenotifyInterval int `yaml:"RenotifyInterval"`
HTTPTimeout int `yaml:"HTTPTimeout"`
}
@@ -57,6 +59,18 @@ func jobNotifyDedup(conf *Config, prevJobs, newJobs map[string]*jobResponse) {
}
if oldresp.Message == resp.Message {
+ // This isn't new, adjust accordingly
+ newJobs[id] = prevJobs[id]
+
+ if time.Now().After(
+ oldresp.Time.Add(time.Duration(conf.RenotifyInterval) * time.Second)) {
+
+ buf.Write([]byte(
+ "still active --> " + resp.Message,
+ ))
+ buf.Write([]byte{'\n'})
+ }
+
continue
}
@@ -134,6 +148,7 @@ func main() {
CertWindow: 15,
ExpectedStatusCode: 200,
Interval: 60,
+ RenotifyInterval: 900,
}
err := ReadConfig(*confFn, conf)
diff --git a/sample-config.yml b/sample-config.yml
index 0447a3e..cf5421c 100644
--- a/sample-config.yml
+++ b/sample-config.yml
@@ -2,6 +2,10 @@
RocketChatURL: changeme
DiscordURL: changeme
+Interval: 1
+# How often do we ping again if there's an error and no change in status?
+RenotifyInterval: 900
+
# How many concurrent requests do we run?
Workers: 10