From 3262530d138405634f6f229b1631324625400d93 Mon Sep 17 00:00:00 2001 From: Alvar Penning Date: Tue, 10 Oct 2023 09:32:25 +0200 Subject: [PATCH] Get-IcingaCheckCommandConfig: improve -IcingaConfig documentation The old Cmdlet's documentation implied that just by passing the -IcingaConfig switch, an Icinga 2 configuration would be generated. However, the first two examples does not work as intended, as -IcingaConfig only works together with the -OutDirectory parameter. The documentation was updated to reflect as Get-IcingaCheckCommandConfig behaves and how one can generate Icinga 2 configurations. In addition, a note was added to the Cmdlet's API documentation to handle expectations of the switch. --- .../04-Icinga-Config.md | 20 ++++++++----------- .../tools/Get-IcingaCheckCommandConfig.psm1 | 3 ++- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/doc/200-Icinga-Integration/04-Icinga-Config.md b/doc/200-Icinga-Integration/04-Icinga-Config.md index 3d6a806..407f8fd 100644 --- a/doc/200-Icinga-Integration/04-Icinga-Config.md +++ b/doc/200-Icinga-Integration/04-Icinga-Config.md @@ -1,35 +1,31 @@ # Icinga Config Generator -To make the integration as easy as possible, the Framework is shipping with an Icinga 2 configuration generator. Each Check-Plugin available within the Framework is able to auto-generate a Icinga config which can be copied to your Icinga 2 hosts. +To make the integration as easy as possible, the Framework is shipping with an Icinga 2 configuration generator. Each Check-Plugin available within the Framework is able to auto-generate an Icinga config which can be copied to your Icinga 2 hosts. ## Generating Configuration To automatically generate the Icinga configuration, open a PowerShell terminal and type in ```powershell -icinga +Use-Icinga ``` -to load the Icinga PowerShell Framework. +to load the framework Cmdlets. + +Now use the same commands as for the [Icinga Director Basket](01-Director-Baskets.md) but make sure to specify an `-OutDirectory` together with the `-IcingaConfig` switch. The `-IcingaConfig` switch only changes the generated output file format, not the returned resp. printed string. Thus, using `-IcingaConfig` without an `-OutDirectory` does not have an impact. Afterwards use the command ```powershell -Get-IcingaCheckCommandConfig -IcingaConfig; +Get-IcingaCheckCommandConfig -OutDirectory 'C:\Users\myuser\Documents\' -IcingaConfig ``` -to automatically generate the configuration for all found Check-Commands. +to automatically generate the configuration for all found Check-Commands in the given directory. If you wish to specify specific commands only, you can filter them as well: ```powershell -Get-IcingaCheckCommandConfig -CheckName Invoke-IcingaCheckBiosSerial, Invoke-IcingaCheckCPU -IcingaConfig; -``` - -Last but not least you can output the Icinga configuration directly into a file. To do this, simply use the `OutDirectory` argument. You only require to specify a directory here, as the file including a timestamp is generated by the Cmdlet itself - -```powershell -Get-IcingaCheckCommandConfig -OutDirectory 'C:\Users\myuser\Documents\' +Get-IcingaCheckCommandConfig -CheckName Invoke-IcingaCheckBiosSerial, Invoke-IcingaCheckCPU -OutDirectory 'C:\Users\myuser\Documents\' -IcingaConfig ``` Once the file is exported, you can copy the `.conf` files onto your Icinga 2 hosts to use them. diff --git a/lib/core/tools/Get-IcingaCheckCommandConfig.psm1 b/lib/core/tools/Get-IcingaCheckCommandConfig.psm1 index f65f695..8964d8d 100644 --- a/lib/core/tools/Get-IcingaCheckCommandConfig.psm1 +++ b/lib/core/tools/Get-IcingaCheckCommandConfig.psm1 @@ -54,7 +54,8 @@ .PARAMETER IcingaConfig Will switch the configuration generator to write plain Icinga 2 `.conf` - files instead of Icinga Director Basket `.json` files + files instead of Icinga Director Basket `.json` files. + Does only affect the written files, not the Cmdlet's String output. .INPUTS System.Array