RedisWriter: Do not split up comments/downtimes into host/service keys

This commit is contained in:
Noah Hilverling 2019-10-10 13:05:16 +02:00 committed by Michael Friedrich
parent 846f327054
commit 52fb723d91
2 changed files with 15 additions and 35 deletions

View File

@ -140,16 +140,7 @@ void RedisWriter::UpdateAllConfigObjects()
continue;
String lcType(type->GetName().ToLower());
if (lcType == "downtime") {
types.emplace_back(ctype, "hostdowntime");
types.emplace_back(ctype, "servicedowntime");
} else if (lcType == "comment") {
types.emplace_back(ctype, "hostcomment");
types.emplace_back(ctype, "servicecomment");
} else {
types.emplace_back(ctype, lcType);
}
types.emplace_back(ctype, lcType);
}
m_Rcon->FireAndForgetQuery({"EVAL", l_LuaResetDump, "1", "icinga:dump"});
@ -1016,10 +1007,15 @@ bool RedisWriter::PrepareObject(const ConfigObject::Ptr& object, Dictionary::Ptr
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(comment->GetCheckable());
if (service)
if (service) {
attributes->Set("object_type", "service");
attributes->Set("service_id", GetObjectIdentifier(service));
else
attributes->Set("host_id", "00000000000000000000000000000000");
} else {
attributes->Set("object_type", "host");
attributes->Set("host_id", GetObjectIdentifier(host));
attributes->Set("service_id", "00000000000000000000000000000000");
}
return true;
}
@ -1043,9 +1039,14 @@ bool RedisWriter::PrepareObject(const ConfigObject::Ptr& object, Dictionary::Ptr
tie(host, service) = GetHostService(downtime->GetCheckable());
if (service) {
attributes->Set("object_type", "service");
attributes->Set("service_id", GetObjectIdentifier(service));
} else
attributes->Set("host_id", "00000000000000000000000000000000");
} else {
attributes->Set("object_type", "host");
attributes->Set("host_id", GetObjectIdentifier(host));
attributes->Set("service_id", "00000000000000000000000000000000");
}
return true;
}

View File

@ -254,28 +254,7 @@ String RedisWriter::HashValue(const Value& value, const std::set<String>& proper
String RedisWriter::GetLowerCaseTypeNameDB(const ConfigObject::Ptr& obj)
{
String typeName = obj->GetReflectionType()->GetName().ToLower();
if (typeName == "downtime") {
Downtime::Ptr downtime = dynamic_pointer_cast<Downtime>(obj);
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(downtime->GetCheckable());
if (service)
typeName = "servicedowntime";
else
typeName = "hostdowntime";
} else if (typeName == "comment") {
Comment::Ptr comment = dynamic_pointer_cast<Comment>(obj);
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(comment->GetCheckable());
if (service)
typeName = "servicecomment";
else
typeName = "hostcomment";
}
return typeName;
return obj->GetReflectionType()->GetName().ToLower();
}
long long RedisWriter::TimestampToMilliseconds(double timestamp) {