mirror of https://github.com/Icinga/icinga2.git
Improve event payload
Adds host/service_id Acknowledgement events. AcknowledgementSet events also send the comment_id. fixes #29
This commit is contained in:
parent
e889de966e
commit
47905a25e8
|
@ -22,10 +22,12 @@
|
||||||
#include "redis/redisconnection.hpp"
|
#include "redis/redisconnection.hpp"
|
||||||
#include "remote/eventqueue.hpp"
|
#include "remote/eventqueue.hpp"
|
||||||
#include "base/json.hpp"
|
#include "base/json.hpp"
|
||||||
#include "rediswriter.hpp"
|
#include "icinga/checkable.hpp"
|
||||||
|
#include "icinga/host.hpp"
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
//TODO Make configurable and figure out a sane default
|
//TODO Make configurable and figure out a sane default
|
||||||
|
@ -304,6 +306,33 @@ void RedisWriter::SendEvent(const Dictionary::Ptr& event)
|
||||||
if (!m_Rcon->IsConnected())
|
if (!m_Rcon->IsConnected())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
String type = event->Get("type");
|
||||||
|
if (type.Contains("Acknowledgement")) {
|
||||||
|
Checkable::Ptr checkable;
|
||||||
|
|
||||||
|
if (event->Contains("service")) {
|
||||||
|
checkable = Service::GetByNamePair(event->Get("host"), event->Get("service"));
|
||||||
|
event->Set("service_id", GetObjectIdentifier(checkable));
|
||||||
|
} else {
|
||||||
|
checkable = Host::GetByName(event->Get("host"));
|
||||||
|
event->Set("host_id", GetObjectIdentifier(checkable));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == "AcknowledgementSet") {
|
||||||
|
Timestamp entry = 0;
|
||||||
|
Comment::Ptr AckComment;
|
||||||
|
for (const Comment::Ptr& c : checkable->GetComments()) {
|
||||||
|
if (c->GetEntryType() == CommentAcknowledgement) {
|
||||||
|
if (c->GetEntryTime() > entry) {
|
||||||
|
entry = c->GetEntryTime();
|
||||||
|
AckComment = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
event->Set("comment_id", GetObjectIdentifier(AckComment));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String body = JsonEncode(event);
|
String body = JsonEncode(event);
|
||||||
|
|
||||||
// Log(LogInformation, "RedisWriter")
|
// Log(LogInformation, "RedisWriter")
|
||||||
|
|
Loading…
Reference in New Issue