Interesting, I thought we’ve migrated all howtos. Obviously not, it is now located here: Windows PowerShell Checks with Icinga2
Since the question targets the Director, you’ll need to figure out the command parameters first, e.g. by calling it on the command line. Once you’ve extracted such, you can start with the Commands
tab inside the Director.
Add a new “plugin check command”, give it a name, and set the command to powershell.exe including its path, similar to what https://github.com/NETWAYS/check_exchange_powershell/blob/master/icinga2-commands.conf describes (you of course include this once in your icinga2.conf, restart icinga2, and let the Director treat this as external command - the better way is to integrate it into the Director natively).
Then put that command in the global-templates
cluster zone.
The arguments
tab now appears, and you can start adding the arguments as key-value pairs following the model here: https://github.com/NETWAYS/check_exchange_powershell/blob/master/icinga2-commands.conf#L10
Change into the Fields
tab and make the script parameter mandatory.
That’s the base powershell command, now you’ll need to put in the script actually being executed. You can do so either by setting powershell_script
as data field (needs to be defined first) in your services, or you’ll create a new CheckCommand object which imports this one, and sets this parameter (preferred).
Add a new CheckCommand, import the existing one and set powershell_script
to a default value.
Then hit deploy, to see that the configuration is actually rendered.
Next up, define a new service which uses the powershell plugin (and set the correct path of course).
First, go to “Define data fields” and verify that powershell_script
is defined there.
Second, define a service template which uses the check_command and may override the custom properties for powershell_script
.
The task left for you is to actually create the service apply rule / set then and see this working
Cheers,
Michael
PS: The steps I’ve done here are reproducible with the standalone Vagrant box.