diff --git a/lib/redis/rediswriter-objects.cpp b/lib/redis/rediswriter-objects.cpp index 5949dee95..8e5117010 100644 --- a/lib/redis/rediswriter-objects.cpp +++ b/lib/redis/rediswriter-objects.cpp @@ -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; } diff --git a/lib/redis/rediswriter-utility.cpp b/lib/redis/rediswriter-utility.cpp index 04cd275d9..f2a4a5281 100644 --- a/lib/redis/rediswriter-utility.cpp +++ b/lib/redis/rediswriter-utility.cpp @@ -254,28 +254,7 @@ String RedisWriter::HashValue(const Value& value, const std::set& proper String RedisWriter::GetLowerCaseTypeNameDB(const ConfigObject::Ptr& obj) { - String typeName = obj->GetReflectionType()->GetName().ToLower(); - if (typeName == "downtime") { - Downtime::Ptr downtime = dynamic_pointer_cast(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(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) {