]> granicus.if.org Git - icinga2/commitdiff
Fix: Host notifications should be added to the host check service instead of the...
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 4 Sep 2013 08:43:14 +0000 (10:43 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 4 Sep 2013 08:43:14 +0000 (10:43 +0200)
Fixes #4674

tools/configconvert/Icinga2/ExportIcinga2Cfg.pm

index 7d263cba0fdfa65f4aa91b39f0b751f7b195e58e..5fe8ae97b5d4bb925cda1af1e62e17f9fda36559 100644 (file)
@@ -548,39 +548,6 @@ sub dump_host_2x {
         }
     }
 
-    if(defined($host_2x->{'__I2CONVERT_NOTIFICATIONS'})) {
-        #say Dumper ($host_2x->{'__I2CONVERT_NOTIFICATIONS'});
-        # this is an array of notification objects
-        foreach my $host_notification_hash (@{$host_2x->{'__I2CONVERT_NOTIFICATIONS'}}) {
-
-            #say Dumper($host_notification_hash);
-
-            # this is a hash by unique key of the notification template, but all further attributes are seperatedly available too
-            foreach my $host_notification_key (keys %{$host_notification_hash}) {
-                my $host_notification = $host_notification_hash->{$host_notification_key};
-                #say Dumper($host_notification);
-
-                # skip everything not related to host notifications
-                next if ($host_notification->{'type'} ne 'host');
-
-                dump_config_line($icinga2_cfg, "\tnotifications[\"$host_notification->{'name'}\"] = {");
-
-                if (defined ($host_notification->{'templates'}) && @{$host_notification->{'templates'}} > 0) {
-                    my $host_notification_templates = join '", "', @{$host_notification->{'templates'}};
-                    dump_config_line($icinga2_cfg, "\t\ttemplates = [ \"$host_notification_templates\" ],");
-                }
-
-                if(defined($host_notification->{'users'}) && @{$host_notification->{'users'}} > 0) {
-                    my $host_users = join '", "', @{$host_notification->{'users'}};
-                    dump_config_line($icinga2_cfg, "\t\tusers = [ \"$host_users\" ],");
-                }
-
-                dump_config_line($icinga2_cfg, "\t},");
-            }
-        }
-    }
-
-
     if(defined($host_2x->{'notification_period'})) {
         dump_config_line($icinga2_cfg, "\tnotification_period = \"$host_2x->{'notification_period'}\",");
     }
@@ -762,6 +729,38 @@ sub dump_host_2x {
             }
         }
 
+        if(defined($host_2x->{'__I2CONVERT_NOTIFICATIONS'}) && $host_2x->{'__I2CONVERT_HOSTCHECK'} eq $service_2x->{__I2CONVERT_SERVICEDESCRIPTION}) {
+            #say Dumper ($host_2x->{'__I2CONVERT_NOTIFICATIONS'});
+            # this is an array of notification objects
+            foreach my $host_notification_hash (@{$host_2x->{'__I2CONVERT_NOTIFICATIONS'}}) {
+
+                #say Dumper($host_notification_hash);
+
+                # this is a hash by unique key of the notification template, but all further attributes are seperatedly available too
+                foreach my $host_notification_key (keys %{$host_notification_hash}) {
+                    my $host_notification = $host_notification_hash->{$host_notification_key};
+                    #say Dumper($host_notification);
+
+                    # skip everything not related to host notifications
+                    next if ($host_notification->{'type'} ne 'host');
+
+                    dump_config_line($icinga2_cfg, "\t\tnotifications[\"$host_notification->{'name'}\"] = {");
+
+                    if (defined ($host_notification->{'templates'}) && @{$host_notification->{'templates'}} > 0) {
+                        my $host_notification_templates = join '", "', @{$host_notification->{'templates'}};
+                        dump_config_line($icinga2_cfg, "\t\t\ttemplates = [ \"$host_notification_templates\" ],");
+                    }
+
+                    if(defined($host_notification->{'users'}) && @{$host_notification->{'users'}} > 0) {
+                        my $host_users = join '", "', @{$host_notification->{'users'}};
+                        dump_config_line($icinga2_cfg, "\t\t\tusers = [ \"$host_users\" ],");
+                    }
+
+                    dump_config_line($icinga2_cfg, "\t\t},");
+                }
+            }
+        }
+
         if(defined($service_2x->{'notification_period'})) {
             dump_config_line($icinga2_cfg, "\t\tnotification_period = \"$service_2x->{'notification_period'}\",");
         }