From 9d23bbec2ed3de21dac1bd3bff51c1927ce24ce4 Mon Sep 17 00:00:00 2001 From: Julian Brost Date: Fri, 12 Feb 2021 09:01:55 +0100 Subject: [PATCH] HA: only read new hearbeats from Redis Selecting any heartbeat from the last 15 seconds from Redis makes little sense, just wait for new ones. If Icinga 2 just stopped, there is no point in becoming active for just a few seconds, otherwise the next heartbeat will arrive in a second anyways. --- ha/heartbeat.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ha/heartbeat.go b/ha/heartbeat.go index 56260c7e..db8f933f 100644 --- a/ha/heartbeat.go +++ b/ha/heartbeat.go @@ -5,12 +5,10 @@ package ha import ( "crypto/sha1" "encoding/json" - "fmt" "github.com/Icinga/icingadb/connection" "github.com/Icinga/icingadb/utils" "github.com/go-redis/redis/v7" log "github.com/sirupsen/logrus" - "time" ) type Environment struct { @@ -43,7 +41,7 @@ func IcingaHeartbeatListener(rdb *connection.RDBWrapper, chEnv chan *Environment log.Info("Starting heartbeat listener") xReadArgs := redis.XReadArgs{ - Streams: []string{"icinga:stats", fmt.Sprintf("%d-0", utils.TimeToMillisecs(time.Now().Add(-15*time.Second)))}, + Streams: []string{"icinga:stats", "$"}, Count: 1, Block: 0, }