Config Conversion: Add ADMINPAGER|EMAIL as macros from icinga.cfg

and fix multiple user macros too. and add NotificationFilterCustom by
default.

fixes #4662
This commit is contained in:
Michael Friedrich 2013-08-30 15:58:58 +02:00
parent b4f5ff90b6
commit 1a3ecb04fb
2 changed files with 19 additions and 4 deletions

View File

@ -846,8 +846,9 @@ sub convert_notification_options_to_filter {
return $filter;
}
# always add NotificationFilterProblem
# always add NotificationFilterProblem|Custom
push @{$filter->{'type'}}, 'NotificationFilterProblem';
push @{$filter->{'type'}}, 'NotificationFilterCustom';
if (grep /a/, @options) {
foreach my $by (keys %{$filter_by}) {
@ -997,9 +998,15 @@ sub convert_checkcommand {
#Icinga2::Utils::debug("2x Command: $command_2x->{'check_command'}");
# detect $USERn$ macros and replace them too XXX - this should be a global macro?
if ($commands_1x->{$command_1x_key}->{'command_line'} =~ /\$(USER\d+)\$/) {
$command_2x->{'command_macros'}->{$1} = Icinga2::Utils::escape_str($user_macros_1x->{$1});
#debug("\$$1\$=$command_2x->{'macros'}->{$1}");
if ($commands_1x->{$command_1x_key}->{'command_line'} =~ /\$(USER\d+)\$/ ||
$commands_1x->{$command_1x_key}->{'command_line'} =~ /\$(ADMIN\w+)\$/) {
my @user_macros = ($commands_1x->{$command_1x_key}->{'command_line'} =~ /\$(USER\d+)\$/g);
my @admin_macros = ($commands_1x->{$command_1x_key}->{'command_line'} =~ /\$(ADMIN\w+)\$/g);
push @user_macros, @admin_macros;
foreach my $macro_name (@user_macros) {
$command_2x->{'command_macros'}->{$macro_name} = Icinga2::Utils::escape_str($user_macros_1x->{$macro_name});
}
}
# save all command args as macros (we'll deal later with them in service definitions)

View File

@ -94,8 +94,16 @@ sub parse_icinga1_user_macros {
my ($icinga1_resource_file) = get_key_from_icinga1_main_cfg($icinga1_cfg, "resource_file");
# resource.cfg
my $user_macros = parse_icinga1_resource_cfg($icinga1_resource_file);
# special attributes in icinga.cfg (admin_*)
my ($admin_pager) = get_key_from_icinga1_main_cfg($icinga1_cfg, "admin_pager");
my ($admin_email) = get_key_from_icinga1_main_cfg($icinga1_cfg, "admin_email");
$user_macros->{'ADMINPAGER'} = $admin_pager;
$user_macros->{'ADMINEMAIL'} = $admin_email;
return $user_macros;
}