diff --git a/lib/redis/rediswriter.cpp b/lib/redis/rediswriter.cpp index 6bad770ab..c6248475b 100644 --- a/lib/redis/rediswriter.cpp +++ b/lib/redis/rediswriter.cpp @@ -147,6 +147,7 @@ void RedisWriter::TryToReconnect(void) m_ConfigDumpInProgress = false; } +/* void RedisWriter::UpdateSubscriptionsTimerHandler(void) { m_WorkQueue.Enqueue(boost::bind(&RedisWriter::UpdateSubscriptions, this)); @@ -218,6 +219,7 @@ int RedisWriter::GetSubscriptionTypes(String key, RedisSubscriptionInfo& rsi) << "Invalid Redis subscriber info for subscriber '" << key << "': " << DiagnosticInformation(ex); } } +*/ void RedisWriter::PublishStatsTimerHandler(void) { @@ -270,13 +272,14 @@ void RedisWriter::HandleEvents(void) if (!event) continue; - m_WorkQueue.Enqueue(boost::bind(&RedisWriter::HandleEvent, this, event)); + m_WorkQueue.Enqueue(boost::bind(&RedisWriter::SendEvent, this, event)); } queue->RemoveClient(this); EventQueue::UnregisterIfUnused(queueName, queue); } +/* void RedisWriter::HandleEvent(const Dictionary::Ptr& event) { AssertOnWorkQueue(); @@ -309,6 +312,22 @@ void RedisWriter::HandleEvent(const Dictionary::Ptr& event) ExecuteQuery({ "EXEC" }); } } +*/ + +void RedisWriter::HandleEvent(const Dictionary::Ptr& event) +{ + AssertOnWorkQueue(); + + if (!m_Context) + return; + + String body = JsonEncode(event); + + Log(LogInformation, "RedisWriter") + << "Sending event \"" << body << "\""; + ExecuteQuery({ "PUBLISH", "icinga:event:all", body }); + ExecuteQuery({ "PUBLISH", "icinga:event:" + event->Get("type"), body }); +} void RedisWriter::Stop(bool runtimeRemoved) { diff --git a/lib/redis/rediswriter.hpp b/lib/redis/rediswriter.hpp index 24c47f9dd..f4aec001a 100644 --- a/lib/redis/rediswriter.hpp +++ b/lib/redis/rediswriter.hpp @@ -56,6 +56,7 @@ private: void TryToReconnect(void); void HandleEvents(void); void HandleEvent(const Dictionary::Ptr& event); + void SendEvent(const Dictionary::Ptr& event); void UpdateSubscriptionsTimerHandler(void); void UpdateSubscriptions(void);