[icinga-checkins] icinga.org: icinga2/feature/configconvert-2743: configconvert: add notification_interval|period

git at icinga.org git at icinga.org
Fri May 3 10:47:28 CEST 2013


Module: icinga2
Branch: feature/configconvert-2743
Commit: 06eb61f810d357cf12efc6d901e717f0c08d5a1f
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=06eb61f810d357cf12efc6d901e717f0c08d5a1f

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Fri May  3 10:46:23 2013 +0200

configconvert: add notification_interval|period

and refactor check|retry_interval vs normal|retry_check_interval

refs #4008

---

 contrib/configconvert/Icinga2/Convert.pm          |   46 +++++++++++++++-----
 contrib/configconvert/Icinga2/ExportIcinga2Cfg.pm |   21 +++++++++
 2 files changed, 55 insertions(+), 12 deletions(-)

diff --git a/contrib/configconvert/Icinga2/Convert.pm b/contrib/configconvert/Icinga2/Convert.pm
index f0900e5..af0bb1c 100644
--- a/contrib/configconvert/Icinga2/Convert.pm
+++ b/contrib/configconvert/Icinga2/Convert.pm
@@ -751,12 +751,12 @@ sub convert_2x {
             # check_interval
             ##########################################
             my $service_check_interval = undef;
-            if(defined($obj_1x_service->{'check_interval'})) {
-                $service_check_interval = $obj_1x_service->{'check_interval'};
-            } 
             if(defined($obj_1x_service->{'normal_check_interval'})) {
                 $service_check_interval = $obj_1x_service->{'normal_check_interval'};
             } 
+            if(defined($obj_1x_service->{'check_interval'})) {
+                $service_check_interval = $obj_1x_service->{'check_interval'};
+            } 
             # we assume that 1.x kept 1m default interval, and map it
             if (defined($service_check_interval)) {
                 $cfg_obj_2x->{'service'}->{$service_cnt}->{'check_interval'} = $service_check_interval."m";
@@ -766,17 +766,28 @@ sub convert_2x {
             # retry_interval
             ##########################################
             my $service_retry_interval = undef;
-            if(defined($obj_1x_service->{'retry_interval'})) {
-                $service_retry_interval = $obj_1x_service->{'retry_interval'};
-            } 
             if(defined($obj_1x_service->{'retry_check_interval'})) {
                 $service_retry_interval = $obj_1x_service->{'retry_check_interval'};
             } 
+            if(defined($obj_1x_service->{'retry_interval'})) {
+                $service_retry_interval = $obj_1x_service->{'retry_interval'};
+            } 
             # we assume that 1.x kept 1m default interval, and map it
             if (defined($service_retry_interval)) {
                 $cfg_obj_2x->{'service'}->{$service_cnt}->{'retry_interval'} = $service_retry_interval."m";
             }
 
+            ##########################################
+            # notification_interval
+            ##########################################
+            my $service_notification_interval = undef;
+            if(defined($obj_1x_service->{'notification_interval'})) {
+                $service_notification_interval = $obj_1x_service->{'notification_interval'};
+            }
+            # we assume that 1.x kept 1m default interval, and map it
+            if (defined($service_notification_interval)) {
+                $cfg_obj_2x->{'service'}->{$service_cnt}->{'notification_interval'} = $service_notification_interval."m";
+            }
 
             ##########################################
             # map the service check_command to 2.x
@@ -919,12 +930,12 @@ sub convert_2x {
         # check_interval
         ##########################################
         my $host_check_interval = undef;
-        if(defined($obj_1x_host->{'check_interval'})) {
-            $host_check_interval = $obj_1x_host->{'check_interval'};
-        }
         if(defined($obj_1x_host->{'normal_check_interval'})) {
             $host_check_interval = $obj_1x_host->{'normal_check_interval'};
         }
+        if(defined($obj_1x_host->{'check_interval'})) {
+            $host_check_interval = $obj_1x_host->{'check_interval'};
+        }
         # we assume that 1.x kept 1m default interval, and map it
         if (defined($host_check_interval)) {
             $cfg_obj_2x->{'host'}->{$host_obj_1x_key}->{'check_interval'} = $host_check_interval."m";
@@ -934,17 +945,28 @@ sub convert_2x {
         # retry_interval
         ##########################################
         my $host_retry_interval = undef;
-        if(defined($obj_1x_host->{'retry_interval'})) {
-            $host_retry_interval = $obj_1x_host->{'retry_interval'};
-        }
         if(defined($obj_1x_host->{'retry_check_interval'})) {
             $host_retry_interval = $obj_1x_host->{'retry_check_interval'};
         }
+        if(defined($obj_1x_host->{'retry_interval'})) {
+            $host_retry_interval = $obj_1x_host->{'retry_interval'};
+        }
         # we assume that 1.x kept 1m default interval, and map it
         if (defined($host_retry_interval)) {
             $cfg_obj_2x->{'host'}->{$host_obj_1x_key}->{'retry_interval'} = $host_retry_interval."m";
         }
 
+        ##########################################
+        # notification_interval
+        ##########################################
+        my $host_notification_interval = undef;
+        if(defined($obj_1x_host->{'notification_interval'})) {
+            $host_notification_interval = $obj_1x_host->{'notification_interval'};
+        }
+        # we assume that 1.x kept 1m default interval, and map it
+        if (defined($host_notification_interval)) {
+            $cfg_obj_2x->{'host'}->{$host_obj_1x_key}->{'notification_interval'} = $host_notification_interval."m";
+        }
 
         ####################################################
         # Icinga 2 Hosts don't have a check_command anymore
diff --git a/contrib/configconvert/Icinga2/ExportIcinga2Cfg.pm b/contrib/configconvert/Icinga2/ExportIcinga2Cfg.pm
index 3a9cc53..a9676cc 100644
--- a/contrib/configconvert/Icinga2/ExportIcinga2Cfg.pm
+++ b/contrib/configconvert/Icinga2/ExportIcinga2Cfg.pm
@@ -322,6 +322,13 @@ sub dump_service_2x {
         }
     }
 
+    if(defined($service_2x->{'notification_period'})) {
+        dump_config_line($icinga2_cfg, "\tnotification_period = \"$service_2x->{'notification_period'}\",");
+    }
+    if(defined($service_2x->{'notification_interval'})) {
+        dump_config_line($icinga2_cfg, "\tnotification_interval = $service_2x->{'notification_interval'},");
+    }
+
     ####################################################
     # other service attributes, if set
     ####################################################
@@ -452,6 +459,13 @@ sub dump_host_2x {
         }
     }
 
+
+    if(defined($host_2x->{'notification_period'})) {
+        dump_config_line($icinga2_cfg, "\tnotification_period = \"$host_2x->{'notification_period'}\",");
+    }
+    if(defined($host_2x->{'notification_interval'})) {
+        dump_config_line($icinga2_cfg, "\tnotification_interval = $host_2x->{'notification_interval'},");
+    }
     ####################################################
     # other host attributes, if set
     ####################################################
@@ -585,6 +599,13 @@ sub dump_host_2x {
             }
         }
 
+        if(defined($service_2x->{'notification_period'})) {
+            dump_config_line($icinga2_cfg, "\t\tnotification_period = \"$service_2x->{'notification_period'}\",");
+        }
+        if(defined($service_2x->{'notification_interval'})) {
+            dump_config_line($icinga2_cfg, "\t\tnotification_interval = $service_2x->{'notification_interval'},");
+        }
+
         ####################################################
         # other service attributes, if set
         ####################################################





More information about the icinga-checkins mailing list