summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-05-28 22:46:27 +0300
committerPaul Buetow <paul@buetow.org>2025-05-28 22:46:27 +0300
commit8b43dff3070d869fbb28c50d8c24d608c608d629 (patch)
tree6f6a3fca361d4808fea32b327272f4861d0c1d14
parent952cbe5d486926821c9e507bf833268eda70a299 (diff)
add epoch to check status
-rw-r--r--internal/check.go8
-rw-r--r--internal/state.go3
2 files changed, 7 insertions, 4 deletions
diff --git a/internal/check.go b/internal/check.go
index 189f417..55b740a 100644
--- a/internal/check.go
+++ b/internal/check.go
@@ -5,6 +5,7 @@ import (
"context"
"os/exec"
"strings"
+ "time"
)
type check struct {
@@ -23,6 +24,7 @@ type namedCheck struct {
type checkResult struct {
name string
output string
+ epoch int64
status nagiosCode
}
@@ -35,7 +37,7 @@ func (c check) run(ctx context.Context, name string) checkResult {
if err := cmd.Run(); err != nil {
if ctx.Err() == context.DeadlineExceeded {
- return checkResult{name, "Check command timed out", nagiosCritical}
+ return checkResult{name, "Check command timed out", time.Now().Unix(), nagiosCritical}
}
}
@@ -49,11 +51,11 @@ func (c check) run(ctx context.Context, name string) checkResult {
ec = int(nagiosUnknown)
}
- return checkResult{name, output, nagiosCode(ec)}
+ return checkResult{name, output, time.Now().Unix(), nagiosCode(ec)}
}
func (c check) skip(name, output string) checkResult {
- return checkResult{name, output, nagiosUnknown}
+ return checkResult{name, output, time.Now().Unix(), nagiosUnknown}
}
func (c namedCheck) run(ctx context.Context) checkResult {
diff --git a/internal/state.go b/internal/state.go
index 1f92212..f37a0f6 100644
--- a/internal/state.go
+++ b/internal/state.go
@@ -13,6 +13,7 @@ import (
type checkState struct {
Status nagiosCode
PrevStatus nagiosCode
+ Epoch int64 `json:"Epoch,omitempty"`
output string
}
@@ -73,7 +74,7 @@ func (s state) update(result checkResult) {
prevStatus = prevState.Status
}
- cs := checkState{result.status, prevStatus, result.output}
+ cs := checkState{result.status, prevStatus, result.epoch, result.output}
s.checks[result.name] = cs
log.Println(result.name, cs)
}