From 6a40fe7a404234b1c5b5e48def879e8d76da4069 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 13 Sep 2013 09:28:32 +0200 Subject: [PATCH] Convert custom attributes to macros. --- .../configconvert/Icinga2/ExportIcinga2Cfg.pm | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tools/configconvert/Icinga2/ExportIcinga2Cfg.pm b/tools/configconvert/Icinga2/ExportIcinga2Cfg.pm index af2ce13ed..bddabf161 100644 --- a/tools/configconvert/Icinga2/ExportIcinga2Cfg.pm +++ b/tools/configconvert/Icinga2/ExportIcinga2Cfg.pm @@ -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},"); + + 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, ""); @@ -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},"); + + 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},"); + + 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},"); @@ -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},"); + + 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, ""); -- 2.40.0