mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2026-02-03 12:19:29 -05:00
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.
52 lines
2.9 KiB
Markdown
52 lines
2.9 KiB
Markdown
# 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 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
|
|
Use-Icinga
|
|
```
|
|
|
|
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 -OutDirectory 'C:\Users\myuser\Documents\' -IcingaConfig
|
|
```
|
|
|
|
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 -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.
|
|
|
|
**Note:** Because of a possible configuration error cased by multiple `PowerShell Base` CheckCommands, it is generated separately. You only require this once on your system and is cross-compatible with every single CheckCommand.
|
|
|
|
## Custom File Names
|
|
|
|
You can modify the name of the output `.conf` file by using the `-FileName` argument in combination with the other arguments:
|
|
|
|
```powershell
|
|
Get-IcingaCheckCommandConfig -CheckName Invoke-IcingaCheckBiosSerial, Invoke-IcingaCheckCPU -IcingaConfig -OutDirectory 'C:\Users\myuser\Documents\' -FileName 'IcingaForWindows';
|
|
```
|
|
|
|
This will generate the plugins configuration `C:\Users\myuser\Documents\IcingaForWindows.conf` and `C:\Users\myuser\Documents\PowerShell_Base.conf`
|
|
|
|
The `.conf` ending is not required, as the Cmdlet will take care of that for you.
|
|
|
|
## Developer Note
|
|
|
|
The generated Icinga configuration will benefit from a detailed documentation of the module and each single argument. Descriptions for arguments are parsed into the commands description field, informing users of what the argument actually does. Furthermore arguments are automatically mapped to certain object types. A `switch` argument for example will always be rendered with a `set_if` flag, ensuring you only require to set the corresponding custom variable to true to set this argument.
|
|
In addition `array` arguments use the Icinga DSL to properly build PowerShell arrays based on Icinga arrays.
|
|
|
|
This will increase the entire usability of the module and prevent you from having to document plugins multiple times.
|