From 077179ccce746bc8fb225e0e4fb044d141a31ce1 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Wed, 27 Jan 2021 15:16:28 +0100 Subject: [PATCH] Fix Icinga 2 .conf file generator Fixes Get-IcingaCheckCommandConfig -IcingaConfig generates invalid configuration file #181 --- doc/31-Changelog.md | 1 + lib/core/tools/Get-IcingaCheckCommandConfig.psm1 | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/31-Changelog.md b/doc/31-Changelog.md index 3f6515c..265bbab 100644 --- a/doc/31-Changelog.md +++ b/doc/31-Changelog.md @@ -20,6 +20,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic * [#189](https://github.com/Icinga/icinga-powershell-framework/pull/189) Fixes wrong documented user group for accessing Performance Counter objects which should be `Performance Monitor Users` * [#192](https://github.com/Icinga/icinga-powershell-framework/pull/192) Fixes code base for `Invoke-IcingaCheckService` by preferring to fetch the startup type of services by using WMI instead of `Get-Services`, as the result of `Get-Services` might be empty in some cases * [#195](https://github.com/Icinga/icinga-powershell-framework/pull/195) Fix Agent installer crash on package lookup with different files in directory +* [#196](https://github.com/Icinga/icinga-powershell-framework/pull/196) Fix Icinga 2 .conf file generator to no longer generate invalid plain configuration files * [#197](https://github.com/Icinga/icinga-powershell-framework/pull/197) Fixes progress bar appearance on check outputs for certain plugins, by disabling the entire PowerShell progress bar during the usage of Icinga for Windows ## 1.3.0 (2020-12-01) diff --git a/lib/core/tools/Get-IcingaCheckCommandConfig.psm1 b/lib/core/tools/Get-IcingaCheckCommandConfig.psm1 index 3f7e4b4..6ef5f7c 100644 --- a/lib/core/tools/Get-IcingaCheckCommandConfig.psm1 +++ b/lib/core/tools/Get-IcingaCheckCommandConfig.psm1 @@ -430,6 +430,10 @@ function Write-IcingaPlainConfigurationFiles() foreach ($argconfig in $CheckArgument.Keys) { $Value = ''; + if ($argconfig -eq 'set_if_format') { + continue; + } + # Order is numeric -> no "" required if ($argconfig -eq 'order') { $StringFormater = ' {0} = {1}{2}'; @@ -467,6 +471,7 @@ function Write-IcingaPlainConfigurationFiles() break; } $Description = $DataField.description.Replace("`r`n", ' '); + $Description = $Description.Replace("\", '\\'); $Description = $Description.Replace("`n", ' '); $Description = $Description.Replace("`r", ' '); $Description = $Description.Replace('"', "'"); @@ -497,8 +502,8 @@ function Write-IcingaPlainConfigurationFiles() $IcingaConfig += New-IcingaNewLine; foreach ($var in $CheckCommand.vars.Keys) { - $Value = $CheckCommand.vars[$var]; - $IcingaConfig += [string]::Format(' vars.{0} = {1}{2}', $var, $Value, (New-IcingaNewLine)); + [string]$Value = $CheckCommand.vars[$var]; + $IcingaConfig += [string]::Format(' vars.{0} = {1}{2}', $var, $Value.ToLower(), (New-IcingaNewLine)); } } else { $IcingaConfig += New-IcingaNewLine;