mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 21:55:03 +02:00
config conversion: Move notification_interval|period from service to notification.
refs #4741
This commit is contained in:
parent
4c14619521
commit
61e3fcf0a7
@ -1316,7 +1316,10 @@ sub convert_2x {
|
|||||||
my $service_notification_interval = undef;
|
my $service_notification_interval = undef;
|
||||||
if(defined($obj_1x_service->{'notification_interval'})) {
|
if(defined($obj_1x_service->{'notification_interval'})) {
|
||||||
$service_notification_interval = $obj_1x_service->{'notification_interval'};
|
$service_notification_interval = $obj_1x_service->{'notification_interval'};
|
||||||
|
} else {
|
||||||
|
$service_notification_interval = obj_1x_get_service_attr($cfg_obj_1x, $obj_1x_service, $service_host_name, 'notification_interval');
|
||||||
}
|
}
|
||||||
|
|
||||||
# we assume that 1.x kept 1m default interval, and map it
|
# we assume that 1.x kept 1m default interval, and map it
|
||||||
if (defined($service_notification_interval)) {
|
if (defined($service_notification_interval)) {
|
||||||
$cfg_obj_2x->{'service'}->{$service_cnt}->{'notification_interval'} = $service_notification_interval."m";
|
$cfg_obj_2x->{'service'}->{$service_cnt}->{'notification_interval'} = $service_notification_interval."m";
|
||||||
@ -1581,7 +1584,10 @@ sub convert_2x {
|
|||||||
my $host_notification_interval = undef;
|
my $host_notification_interval = undef;
|
||||||
if(defined($obj_1x_host->{'notification_interval'})) {
|
if(defined($obj_1x_host->{'notification_interval'})) {
|
||||||
$host_notification_interval = $obj_1x_host->{'notification_interval'};
|
$host_notification_interval = $obj_1x_host->{'notification_interval'};
|
||||||
|
} else {
|
||||||
|
$host_notification_interval = obj_1x_get_host_attr($cfg_obj_1x, $obj_1x_host, 'notification_interval');
|
||||||
}
|
}
|
||||||
|
|
||||||
# we assume that 1.x kept 1m default interval, and map it
|
# we assume that 1.x kept 1m default interval, and map it
|
||||||
if (defined($host_notification_interval)) {
|
if (defined($host_notification_interval)) {
|
||||||
$cfg_obj_2x->{'host'}->{$host_obj_1x_key}->{'notification_interval'} = $host_notification_interval."m";
|
$cfg_obj_2x->{'host'}->{$host_obj_1x_key}->{'notification_interval'} = $host_notification_interval."m";
|
||||||
@ -2331,12 +2337,14 @@ sub convert_2x {
|
|||||||
# we'll add a reference to all notifications here. decide on dump which object type is given, and dump only those notifications!
|
# we'll add a reference to all notifications here. decide on dump which object type is given, and dump only those notifications!
|
||||||
}
|
}
|
||||||
|
|
||||||
# inherit notification filters from service to all newly created notifications
|
# inherit notification attributes from service to all newly created notifications
|
||||||
foreach my $notification (@{$cfg_obj_2x->{'service'}->{$service_obj_2x_key}->{'__I2CONVERT_NOTIFICATIONS'}}) {
|
foreach my $notification (@{$cfg_obj_2x->{'service'}->{$service_obj_2x_key}->{'__I2CONVERT_NOTIFICATIONS'}}) {
|
||||||
foreach my $notification_key (keys %{$notification}) {
|
foreach my $notification_key (keys %{$notification}) {
|
||||||
next if $notification->{$notification_key}->{'type'} ne 'service';
|
next if $notification->{$notification_key}->{'type'} ne 'service';
|
||||||
|
|
||||||
$notification->{$notification_key}->{'__I2CONVERT_NOTIFICATION_FILTERS'} = $cfg_obj_2x->{'service'}->{$service_obj_2x_key}->{'__I2CONVERT_NOTIFICATION_FILTERS'};
|
$notification->{$notification_key}->{'__I2CONVERT_NOTIFICATION_FILTERS'} = $cfg_obj_2x->{'service'}->{$service_obj_2x_key}->{'__I2CONVERT_NOTIFICATION_FILTERS'};
|
||||||
|
$notification->{$notification_key}->{'__I2CONVERT_NOTIFICATION_INTERVAL'} = $cfg_obj_2x->{'service'}->{$service_obj_2x_key}->{'notification_interval'};
|
||||||
|
$notification->{$notification_key}->{'__I2CONVERT_NOTIFICATION_PERIOD'} = $cfg_obj_2x->{'service'}->{$service_obj_2x_key}->{'notification_period'};
|
||||||
say Dumper($notification);
|
say Dumper($notification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -398,20 +398,28 @@ sub dump_service_2x {
|
|||||||
dump_config_line($icinga2_cfg, "\t\tusers = [ \"$service_users\" ],");
|
dump_config_line($icinga2_cfg, "\t\tusers = [ \"$service_users\" ],");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(defined($service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'})) {
|
if(defined($service_notification->{'__I2CONVERT_NOTIFICATION_FILTERS'})) {
|
||||||
#say Dumper($service_2x);
|
#say Dumper($service_notification);
|
||||||
foreach my $by (keys %{$service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}}) {
|
foreach my $by (keys %{$service_notification->{'__I2CONVERT_NOTIFICATION_FILTERS'}}) {
|
||||||
next if !@{$service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}};
|
next if !@{$service_notification->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}};
|
||||||
my $notification_filter;
|
my $notification_filter;
|
||||||
if (grep /0/, @{$service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}}) {
|
if (grep /0/, @{$service_notification->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}}) {
|
||||||
$notification_filter = 0;
|
$notification_filter = 0;
|
||||||
} else {
|
} else {
|
||||||
$notification_filter = "(". (join ' | ', @{$service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}}) .")";
|
$notification_filter = "(". (join ' | ', @{$service_notification->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}}) .")";
|
||||||
}
|
}
|
||||||
dump_config_line($icinga2_cfg, "\t\tnotification_".$by."_filter = $notification_filter,");
|
dump_config_line($icinga2_cfg, "\t\tnotification_".$by."_filter = $notification_filter,");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(defined($service_notification->{'__I2CONVERT_NOTIFICATION_INTERVAL'})) {
|
||||||
|
dump_config_line($icinga2_cfg, "\t\tnotification_interval = $service_notification->{'__I2CONVERT_NOTIFICATION_INTERVAL'},");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(defined($service_notification->{'__I2CONVERT_NOTIFICATION_PERIOD'})) {
|
||||||
|
dump_config_line($icinga2_cfg, "\t\tnotification_period = \"$service_notification->{'__I2CONVERT_NOTIFICATION_PERIOD'}\",");
|
||||||
|
}
|
||||||
|
|
||||||
# this is set for escalations
|
# this is set for escalations
|
||||||
if(defined($service_notification->{'__I2CONVERT_NOTIFICATION_TIMES'}) && $service_notification->{'__I2CONVERT_NOTIFICATION_TIMES'} != 0) {
|
if(defined($service_notification->{'__I2CONVERT_NOTIFICATION_TIMES'}) && $service_notification->{'__I2CONVERT_NOTIFICATION_TIMES'} != 0) {
|
||||||
dump_config_line($icinga2_cfg, "\t\ttimes = {");
|
dump_config_line($icinga2_cfg, "\t\ttimes = {");
|
||||||
@ -425,12 +433,6 @@ 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'},");
|
|
||||||
}
|
|
||||||
if(defined($service_2x->{'notifications_enabled'})) {
|
if(defined($service_2x->{'notifications_enabled'})) {
|
||||||
dump_config_line($icinga2_cfg, "\tenable_notifications = $service_2x->{'notifications_enabled'},");
|
dump_config_line($icinga2_cfg, "\tenable_notifications = $service_2x->{'notifications_enabled'},");
|
||||||
}
|
}
|
||||||
@ -552,39 +554,6 @@ sub dump_host_2x {
|
|||||||
dump_config_line($icinga2_cfg, "\thostdependencies = [ \"$hostdependency_hosts\" ],");
|
dump_config_line($icinga2_cfg, "\thostdependencies = [ \"$hostdependency_hosts\" ],");
|
||||||
}
|
}
|
||||||
|
|
||||||
####################################################
|
|
||||||
# notifications
|
|
||||||
####################################################
|
|
||||||
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'},");
|
|
||||||
}
|
|
||||||
if(defined($host_2x->{'notifications_enabled'})) {
|
|
||||||
dump_config_line($icinga2_cfg, "\tenable_notifications = $host_2x->{'notifications_enabled'},");
|
|
||||||
}
|
|
||||||
|
|
||||||
####################################################
|
|
||||||
# other host attributes, if set
|
|
||||||
####################################################
|
|
||||||
if(defined($host_2x->{'check_interval'})) {
|
|
||||||
dump_config_line($icinga2_cfg, "\tcheck_interval = $host_2x->{'check_interval'},");
|
|
||||||
}
|
|
||||||
if(defined($host_2x->{'retry_interval'})) {
|
|
||||||
dump_config_line($icinga2_cfg, "\tretry_interval = $host_2x->{'retry_interval'},");
|
|
||||||
}
|
|
||||||
if(defined($host_2x->{'max_check_attempts'})) {
|
|
||||||
dump_config_line($icinga2_cfg, "\tmax_check_attempts = $host_2x->{'max_check_attempts'},");
|
|
||||||
}
|
|
||||||
if(defined($host_2x->{'check_period'})) {
|
|
||||||
dump_config_line($icinga2_cfg, "\tcheck_period = \"$host_2x->{'check_period'}\",");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(defined($host_2x->{'flap_detection_enabled'})) {
|
|
||||||
dump_config_line($icinga2_cfg, "\tenable_flapping = $host_2x->{'flap_detection_enabled'},");
|
|
||||||
}
|
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
# custom attr
|
# custom attr
|
||||||
####################################################
|
####################################################
|
||||||
@ -688,19 +657,6 @@ sub dump_host_2x {
|
|||||||
####################################################
|
####################################################
|
||||||
# notifications
|
# notifications
|
||||||
####################################################
|
####################################################
|
||||||
if(defined($service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'})) {
|
|
||||||
foreach my $by (keys %{$service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}}) {
|
|
||||||
next if !@{$service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}};
|
|
||||||
my $notification_filter;
|
|
||||||
if (grep /0/, @{$service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}}) {
|
|
||||||
$notification_filter = 0;
|
|
||||||
} else {
|
|
||||||
$notification_filter = "(". (join ' | ', @{$service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}}) .")";
|
|
||||||
}
|
|
||||||
dump_config_line($icinga2_cfg, "\tnotification_".$by."_filter = $notification_filter,");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(defined($service_2x->{'__I2CONVERT_NOTIFICATIONS'})) {
|
if(defined($service_2x->{'__I2CONVERT_NOTIFICATIONS'})) {
|
||||||
#say Dumper ($service_2x->{'__I2CONVERT_NOTIFICATIONS'});
|
#say Dumper ($service_2x->{'__I2CONVERT_NOTIFICATIONS'});
|
||||||
# this is an array of notification objects
|
# this is an array of notification objects
|
||||||
@ -773,12 +729,6 @@ 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'},");
|
|
||||||
}
|
|
||||||
if(defined($service_2x->{'notifications_enabled'})) {
|
if(defined($service_2x->{'notifications_enabled'})) {
|
||||||
dump_config_line($icinga2_cfg, "\tenable_notifications = $service_2x->{'notifications_enabled'},");
|
dump_config_line($icinga2_cfg, "\tenable_notifications = $service_2x->{'notifications_enabled'},");
|
||||||
}
|
}
|
||||||
@ -998,6 +948,14 @@ sub dump_notification_2x {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(defined($notification_2x->{'__I2CONVERT_NOTIFICATION_INTERVAL'})) {
|
||||||
|
dump_config_line($icinga2_cfg, "\tnotification_interval = $notification_2x->{'__I2CONVERT_NOTIFICATION_INTERVAL'},");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(defined($notification_2x->{'__I2CONVERT_NOTIFICATION_PERIOD'})) {
|
||||||
|
dump_config_line($icinga2_cfg, "\tnotification_period = $notification_2x->{'__I2CONVERT_NOTIFICATION_PERIOD'},");
|
||||||
|
}
|
||||||
|
|
||||||
# this is set for escalations
|
# this is set for escalations
|
||||||
if(defined($notification_2x->{'__I2CONVERT_NOTIFICATION_TIMES'}) && $notification_2x->{'__I2CONVERT_NOTIFICATION_TIMES'} != 0) {
|
if(defined($notification_2x->{'__I2CONVERT_NOTIFICATION_TIMES'}) && $notification_2x->{'__I2CONVERT_NOTIFICATION_TIMES'} != 0) {
|
||||||
dump_config_line($icinga2_cfg, "\ttimes = {");
|
dump_config_line($icinga2_cfg, "\ttimes = {");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user