my $objs_1x = shift;
my $commands_1x = shift;
my $obj_1x = shift;
- my $user_macros_1x = shift;
+ my $global_macros_1x = shift;
my $command_name_1x;
my @commands = ();
my $notification_commands_2x = ();
# detect $USERn$ macros and replace them too XXX - this should be a global macro?
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 @global_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;
+ push @global_macros, @admin_macros;
- foreach my $macro_name (@user_macros) {
- $notification_commands_2x->{$notification_command_type}->{'command_macros'}->{$macro_name} = Icinga2::Utils::escape_str($user_macros_1x->{$macro_name});
+ foreach my $macro_name (@global_macros) {
+ $notification_commands_2x->{$notification_command_type}->{'command_macros'}->{$macro_name} = Icinga2::Utils::escape_str($global_macros_1x->{$macro_name});
}
}
sub convert_eventhandler {
my $commands_1x = shift;
my $obj_1x = shift;
- my $user_macros_1x = shift;
+ my $global_macros_1x = shift;
my $command_name_1x;
my @commands = ();
my $event_commands_2x = ();
# detect $USERn$ macros and replace them too XXX - this should be a global macro?
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 @global_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;
+ push @global_macros, @admin_macros;
- foreach my $macro_name (@user_macros) {
- $event_commands_2x->{'command_macros'}->{$macro_name} = Icinga2::Utils::escape_str($user_macros_1x->{$macro_name});
+ foreach my $macro_name (@global_macros) {
+ $event_commands_2x->{'command_macros'}->{$macro_name} = Icinga2::Utils::escape_str($global_macros_1x->{$macro_name});
}
}
}
sub convert_checkcommand {
my $commands_1x = shift;
my $obj_1x = shift; #host or service
- my $user_macros_1x = shift;
+ my $global_macros_1x = shift;
my $command_1x;
my $command_2x = {};
# detect $USERn$ macros and replace them too XXX - this should be a global macro?
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 @global_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;
+ push @global_macros, @admin_macros;
- foreach my $macro_name (@user_macros) {
- $command_2x->{'command_macros'}->{$macro_name} = Icinga2::Utils::escape_str($user_macros_1x->{$macro_name});
+ foreach my $macro_name (@global_macros) {
+ $command_2x->{'command_macros'}->{$macro_name} = Icinga2::Utils::escape_str($global_macros_1x->{$macro_name});
}
}
my $icinga2_cfg = shift;
my $cfg_obj_1x = shift;
my $cfg_obj_cache_1x = shift;
- my $user_macros_1x = shift;
+ my $global_macros_1x = shift;
# build a new hashref with the actual 2.x config inside
my $cfg_obj_2x = {};
##########################################
if (defined($obj_1x_service->{'event_handler'})) {
- my $service_event_command_2x = Icinga2::Convert::convert_eventhandler(@$cfg_obj_1x{'command'}, $obj_1x_service, $user_macros_1x);
+ my $service_event_command_2x = Icinga2::Convert::convert_eventhandler(@$cfg_obj_1x{'command'}, $obj_1x_service, $global_macros_1x);
#say Dumper($service_event_command_2x);
# XXX do not add duplicate event commands, they must remain unique by their check_command origin!
##########################################
# map the service check_command to 2.x
##########################################
- my $service_check_command_2x = Icinga2::Convert::convert_checkcommand(@$cfg_obj_1x{'command'}, $obj_1x_service, $user_macros_1x);
+ my $service_check_command_2x = Icinga2::Convert::convert_checkcommand(@$cfg_obj_1x{'command'}, $obj_1x_service, $global_macros_1x);
#say Dumper($service_check_command_2x);
# and link that service
####################################################
- my $host_check_command_2x = Icinga2::Convert::convert_checkcommand(@$cfg_obj_1x{'command'}, $obj_1x_host, $user_macros_1x);
+ my $host_check_command_2x = Icinga2::Convert::convert_checkcommand(@$cfg_obj_1x{'command'}, $obj_1x_host, $global_macros_1x);
#say Dumper($host_check_command_2x);
if(defined($host_check_command_2x->{'check_command_name_1x'})) {
####################################################
# get all notification commands
####################################################
- my $notification_commands_2x = Icinga2::Convert::convert_notificationcommand($cfg_obj_1x, @$cfg_obj_1x{'command'}, $obj_1x_contact, $user_macros_1x);
+ my $notification_commands_2x = Icinga2::Convert::convert_notificationcommand($cfg_obj_1x, @$cfg_obj_1x{'command'}, $obj_1x_contact, $global_macros_1x);
#say Dumper($obj_1x_contact);
#say Dumper($notification_commands_2x);
#say Dumper("======================================");
######################################
# LINK HOST COMMAND WITH SERVICE CHECK
######################################
- my $service_check_command_2x = Icinga2::Convert::convert_checkcommand(@$cfg_obj_1x{'command'}, $obj_2x_service, $user_macros_1x);
- my $host_check_command_2x = Icinga2::Convert::convert_checkcommand(@$cfg_obj_1x{'command'}, $obj_2x_host, $user_macros_1x);
+ my $service_check_command_2x = Icinga2::Convert::convert_checkcommand(@$cfg_obj_1x{'command'}, $obj_2x_service, $global_macros_1x);
+ my $host_check_command_2x = Icinga2::Convert::convert_checkcommand(@$cfg_obj_1x{'command'}, $obj_2x_host, $global_macros_1x);
#say Dumper($host_check_command_2x);
# check if this service check is a possible match for __I2CONVERT_HOST_CHECK?
my @cfg = Icinga2::Utils::slurp($file);
- my $user_macros = {};
+ my $global_macros = {};
foreach my $line (@cfg) {
$line = Icinga2::Utils::strip($line);
$macro_name =~ /\$(.*)\$/;
$macro_name = $1;
- $user_macros->{$macro_name} = $macro_value;
+ $global_macros->{$macro_name} = $macro_value;
}
- return $user_macros;
+ return $global_macros;
}
-sub parse_icinga1_user_macros {
+sub parse_icinga1_global_macros {
my $icinga1_cfg = shift;
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);
+ my $global_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;
+ $global_macros->{'ADMINPAGER'} = $admin_pager;
+ $global_macros->{'ADMINEMAIL'} = $admin_email;
- return $user_macros;
+ return $global_macros;
}
sub parse_icinga1_object_cfg {