]> granicus.if.org Git - icinga2/commitdiff
Compat: Only dump host address{,6}, alias if set.
authorMichael Friedrich <Michael.Friedrich@netways.de>
Mon, 14 Apr 2014 19:49:39 +0000 (21:49 +0200)
committerMichael Friedrich <Michael.Friedrich@netways.de>
Mon, 14 Apr 2014 19:50:52 +0000 (21:50 +0200)
Fixes #6013

components/compat/statusdatawriter.cpp

index 0d5322d14258e18d7f4bf55c273c5dc25cc5a5e0..38a3c7b190478840076d0c58ed116815880a2960 100644 (file)
@@ -236,13 +236,20 @@ void StatusDataWriter::DumpHostObject(std::ostream& fp, const Host::Ptr& host)
        String icon_image = CompatUtility::GetCustomAttributeConfig(host, "icon_image");
        String icon_image_alt = CompatUtility::GetCustomAttributeConfig(host, "icon_image_alt");
        String statusmap_image = CompatUtility::GetCustomAttributeConfig(host, "statusmap_image");
+       String display_name = host->GetDisplayName();
+       String address = host->GetAddress();
+       String address6 = host->GetAddress6();
 
        fp << "define host {" "\n"
-             "\t" "host_name" "\t" << host->GetName() << "\n"
-             "\t" "display_name" "\t" << host->GetDisplayName() << "\n"
-             "\t" "alias" "\t" << host->GetDisplayName() << "\n"
-             "\t" "address" "\t" << host->GetAddress() << "\n"
-             "\t" "address6" "\t" << host->GetAddress6() << "\n";
+             "\t" "host_name" "\t" << host->GetName() << "\n";
+       if (!display_name.IsEmpty()) {
+             fp << "\t" "display_name" "\t" << host->GetDisplayName() << "\n"
+                   "\t" "alias" "\t" << host->GetDisplayName() << "\n";
+       }
+       if (!address.IsEmpty())
+             fp << "\t" "address" "\t" << address << "\n";
+       if (!address6.IsEmpty())
+             fp << "\t" "address6" "\t" << address6 << "\n";
        if (!notes.IsEmpty())
              fp << "\t" "notes" "\t" << notes << "\n";
        if (!notes_url.IsEmpty())