diff --git a/components/compat/statusdatawriter.cpp b/components/compat/statusdatawriter.cpp index 632e35b57..f25fec7b8 100644 --- a/components/compat/statusdatawriter.cpp +++ b/components/compat/statusdatawriter.cpp @@ -518,7 +518,7 @@ void StatusDataWriter::DumpCustomAttributes(std::ostream& fp, const DynamicObjec if (!kv.first.IsEmpty()) { fp << "\t"; - if (!CompatUtility::IsLegacyAttribute(kv.first)) + if (!CompatUtility::IsLegacyAttribute(object, kv.first)) fp << "_"; fp << kv.first << "\t" << kv.second << "\n"; diff --git a/lib/icinga/compatutility.cpp b/lib/icinga/compatutility.cpp index ffc12d0f1..130056354 100644 --- a/lib/icinga/compatutility.cpp +++ b/lib/icinga/compatutility.cpp @@ -408,24 +408,33 @@ int CompatUtility::GetCheckableInNotificationPeriod(const Checkable::Ptr& checka /* vars attr */ -bool CompatUtility::IsLegacyAttribute(const String& name) +bool CompatUtility::IsLegacyAttribute(DynamicObject::Ptr const& object, const String& name) { - if (name == "address" || - name == "address1" || + if ((name == "address" || + name == "address6" || + name == "statusmap_image" || + name == "2d_coords") && + object->GetType() == DynamicType::GetByName("Host")) + return true; + + if ((name == "address1" || name == "address2" || name == "address3" || name == "address4" || name == "address5" || - name == "address6" || /* user, host */ + name == "address6" || name == "email" || - name == "pager" || - name == "notes" || + name == "pager") && + object->GetType() == DynamicType::GetByName("User")) + return true; + + if ((name == "notes" || name == "action_url" || name == "notes_url" || name == "icon_image" || - name == "icon_image_alt" || - name == "statusmap_image" || - name == "2d_coords") + name == "icon_image_alt") && + (object->GetType() == DynamicType::GetByName("Host") || + object->GetType() == DynamicType::GetByName("Service"))) return true; return false; @@ -445,7 +454,7 @@ Dictionary::Ptr CompatUtility::GetCustomAttributeConfig(const DynamicObject::Ptr ObjectLock olock(vars); BOOST_FOREACH(const Dictionary::Pair& kv, vars) { if (!kv.first.IsEmpty()) { - if (!IsLegacyAttribute(kv.first)) + if (!IsLegacyAttribute(object, kv.first)) varsvars->Set(kv.first, kv.second); } } diff --git a/lib/icinga/compatutility.h b/lib/icinga/compatutility.h index 936ff58a2..0cb86213b 100644 --- a/lib/icinga/compatutility.h +++ b/lib/icinga/compatutility.h @@ -113,7 +113,7 @@ public: static String GetCommandLine(const Command::Ptr& command); /* custom attribute */ - static bool IsLegacyAttribute(const String& name); + static bool IsLegacyAttribute(const DynamicObject::Ptr& object, const String& name); static String GetCustomAttributeConfig(const DynamicObject::Ptr& object, const String& name); static Dictionary::Ptr GetCustomAttributeConfig(const DynamicObject::Ptr& object);