Convert custom attributes to macros.

This commit is contained in:
Gunnar Beutner 2013-09-13 09:28:32 +02:00
parent 68ec21f13f
commit 6a40fe7a40
1 changed files with 44 additions and 0 deletions

View File

@ -475,6 +475,17 @@ sub dump_service_2x {
dump_config_line($icinga2_cfg, "\t\t$custom_key = \"$service_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\","); dump_config_line($icinga2_cfg, "\t\t$custom_key = \"$service_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\",");
} }
dump_config_line($icinga2_cfg, "\t},"); dump_config_line($icinga2_cfg, "\t},");
dump_config_line($icinga2_cfg, "\tmacros += {");
foreach my $custom_key (keys %{$service_2x->{'__I2CONVERT_CUSTOM_ATTR'}}) {
if ($custom_key =~ /^_/) {
next;
}
my $key = substr($custom_key, 1);
dump_config_line($icinga2_cfg, "\t\t_SERVICE$key = \"$service_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\",");
}
dump_config_line($icinga2_cfg, "\t},");
} }
dump_config_line($icinga2_cfg, ""); dump_config_line($icinga2_cfg, "");
@ -609,6 +620,17 @@ sub dump_host_2x {
dump_config_line($icinga2_cfg, "\t\t$custom_key = \"$host_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\","); dump_config_line($icinga2_cfg, "\t\t$custom_key = \"$host_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\",");
} }
dump_config_line($icinga2_cfg, "\t},"); dump_config_line($icinga2_cfg, "\t},");
dump_config_line($icinga2_cfg, "\tmacros += {");
foreach my $custom_key (keys %{$host_2x->{'__I2CONVERT_CUSTOM_ATTR'}}) {
if ($custom_key =~ /^_/) {
next;
}
my $key = substr($custom_key, 1);
dump_config_line($icinga2_cfg, "\t\t_HOST$key = \"$host_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\",");
}
dump_config_line($icinga2_cfg, "\t},");
} }
#################################################### ####################################################
@ -822,6 +844,17 @@ sub dump_host_2x {
dump_config_line($icinga2_cfg, "\t\t\t$custom_key = \"$service_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\","); dump_config_line($icinga2_cfg, "\t\t\t$custom_key = \"$service_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\",");
} }
dump_config_line($icinga2_cfg, "\t\t},"); dump_config_line($icinga2_cfg, "\t\t},");
dump_config_line($icinga2_cfg, "\t\tmacros += {");
foreach my $custom_key (keys %{$service_2x->{'__I2CONVERT_CUSTOM_ATTR'}}) {
if ($custom_key =~ /^_/) {
next;
}
my $key = substr($custom_key, 1);
dump_config_line($icinga2_cfg, "\t\t\t_SERVICE$key = \"$service_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\",");
}
dump_config_line($icinga2_cfg, "\t\t},");
} }
dump_config_line($icinga2_cfg, "\t},"); dump_config_line($icinga2_cfg, "\t},");
@ -916,6 +949,17 @@ sub dump_user_2x {
dump_config_line($icinga2_cfg, "\t\t$custom_key = \"$user_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\","); dump_config_line($icinga2_cfg, "\t\t$custom_key = \"$user_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\",");
} }
dump_config_line($icinga2_cfg, "\t},"); dump_config_line($icinga2_cfg, "\t},");
dump_config_line($icinga2_cfg, "\tmacros += {");
foreach my $custom_key (keys %{$user_2x->{'__I2CONVERT_CUSTOM_ATTR'}}) {
if ($custom_key =~ /^_/) {
next;
}
my $key = substr($custom_key, 1);
dump_config_line($icinga2_cfg, "\t\t_CONTACT$key = \"$user_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\",");
}
dump_config_line($icinga2_cfg, "\t},");
} }
dump_config_line($icinga2_cfg, ""); dump_config_line($icinga2_cfg, "");