summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--halog.go10
-rw-r--r--haminer.go6
2 files changed, 16 insertions, 0 deletions
diff --git a/halog.go b/halog.go
index 4bb7b60..555811f 100644
--- a/halog.go
+++ b/halog.go
@@ -11,6 +11,16 @@ import (
"time"
)
+// heartbeat of haminer, in case we want to monitor deadman from haminer.
+var heartbeat = &Halog{ // nolint: gochecknoglobals
+ Timestamp: time.Now(),
+ FrontendName: "-",
+ BackendName: "-",
+ ServerName: "-",
+ tagHTTPURL: "-",
+ HTTPMethod: "-",
+}
+
//
// Halog contains the mapping of haproxy HTTP log format to Go struct.
//
diff --git a/haminer.go b/haminer.go
index 62a4aa7..d9aa0d7 100644
--- a/haminer.go
+++ b/haminer.go
@@ -137,6 +137,11 @@ func (h *Haminer) consume() {
}
func (h *Haminer) forwards(halogs []*Halog) {
+ // Send heartbeat indicator, if logs is empty.
+ if len(halogs) == 0 {
+ heartbeat.Timestamp = time.Now()
+ halogs = append(halogs, heartbeat)
+ }
for _, fwder := range h.ff {
fwder.Forwards(halogs)
}
@@ -161,6 +166,7 @@ func (h *Haminer) produce() {
halogs = append(halogs, halog)
case <-ticker.C:
h.forwards(halogs)
+ halogs = nil
}
}
}