diff --git a/lib/base/dynamicobject.cpp b/lib/base/dynamicobject.cpp index dcec7be92..d00d7f3df 100644 --- a/lib/base/dynamicobject.cpp +++ b/lib/base/dynamicobject.cpp @@ -120,6 +120,13 @@ void DynamicObject::InternalApplyUpdate(const Dictionary::Ptr& serializedUpdate, Value data = attr->Get("data"); double tx = attr->Get("tx"); + if (!HasAttribute(it->first)) { + DynamicType::Ptr dtype = GetType(); + if (dtype && !dtype->HasAttribute(it->first)) + Logger::Write(LogWarning, "base", "Adding unknown attribute '" + + it->first + "' to object '" + GetName() + "' of type '" + dtype->GetName() + "'"); + } + if (type & Attribute_Config) RegisterAttribute(it->first, Attribute_Config); diff --git a/lib/base/dynamictype.cpp b/lib/base/dynamictype.cpp index 9313a6d7a..083288589 100644 --- a/lib/base/dynamictype.cpp +++ b/lib/base/dynamictype.cpp @@ -111,8 +111,13 @@ void DynamicType::RemoveAttribute(const String& name) m_Attributes.erase(name); } +bool DynamicType::HasAttribute(const String& name) +{ + return (m_Attributes.find(name) != m_Attributes.end()); +} + void DynamicType::AddAttributes(const AttributeDescription *attributes, int attributeCount) { for (int i = 0; i < attributeCount; i++) AddAttribute(attributes[i].Name, attributes[i].Type); -} \ No newline at end of file +} diff --git a/lib/base/dynamictype.h b/lib/base/dynamictype.h index 818223b7b..b2bbd6e6b 100644 --- a/lib/base/dynamictype.h +++ b/lib/base/dynamictype.h @@ -59,6 +59,7 @@ public: void AddAttribute(const String& name, DynamicAttributeType type); void RemoveAttribute(const String& name); + bool HasAttribute(const String& name); void AddAttributes(const AttributeDescription *attributes, int attributeCount); diff --git a/lib/icinga/host.cpp b/lib/icinga/host.cpp index ec0a1daeb..8bf06eb0d 100644 --- a/lib/icinga/host.cpp +++ b/lib/icinga/host.cpp @@ -29,6 +29,8 @@ static AttributeDescription hostAttributes[] = { { "hostgroups", Attribute_Config }, { "dependencies", Attribute_Config }, { "hostchecks", Attribute_Config }, + { "macros", Attribute_Config }, + { "services", Attribute_Config }, { "acknowledgement", Attribute_Replicated }, { "acknowledgement_expiry", Attribute_Replicated }, { "downtimes", Attribute_Replicated },