# Understanding (Windows PS) Plugins, Icinga2Agent and Director

**URL:** <https://community.icinga.com/t/understanding-windows-ps-plugins-icinga2agent-and-director/705>\
**Category:** Icinga Director\
**Created:** [March 25, 2019, 12:23pm UTC](https://community.icinga.com/t/understanding-windows-ps-plugins-icinga2agent-and-director/705 "2019-03-25T12:23:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![opendev](https://community.icinga.com/user_avatar/community.icinga.com/opendev/32/415_2.png) [@opendev](https://community.icinga.com/u/opendev)\
**Post date:** [March 25, 2019, 12:23pm UTC](https://community.icinga.com/t/understanding-windows-ps-plugins-icinga2agent-and-director/705/1 "2019-03-25T12:23:28Z")

</div>

Hi,

I am currently taking my first steps in Icinga2 to understand the construct in its entirety and, if necessary, have it fully implemented/implemented in our company at a later date. Essential for this is a) the involvement of the director, because my colleagues can’t find their way around on the basis of comma lines and b) of course external checks using plugins on Windows machines.

While I successfully completed the first part with the installation Icinga2, Icingaweb2 and Director with the help of the Netways webinars and also the construct from commands-\>templates-\>service templates-\>host templates-\>etc. … it still hangs at the second point.  
Since this would be an interesting point at the moment, I have the check\_exchange\_powershell  
([https://github.com/NETWAYS/check\_exchange\_powershell](https://github.com/NETWAYS/check_exchange_powershell)) plugin and would now like to implement it for testing purposes. The Icinga2Agent runs on the Exchange and also memory and disksize are already checked successfully. The problem is that I can’t find any instructions or explanations on how to integrate such external plugin commands into the directory. Maybe I overlooked something, I don’t want to exclude that, but somebody would have to show me this place. But now I’m a bit helpless and can’t reach the point to include checks beyond the standard.  
I would be happy about a small (or big) tip.  
Thanks in advance.

Greetings

---

<div class="post-metadata">

**Author:** ![rsx](https://community.icinga.com/user_avatar/community.icinga.com/rsx/32/2094_2.png) [@rsx](https://community.icinga.com/u/rsx)\
**Post date:** [March 25, 2019, 2:07pm UTC](https://community.icinga.com/t/understanding-windows-ps-plugins-icinga2agent-and-director/705/2 "2019-03-25T14:07:57Z")

</div>

Powershell for the first run is a bit tricky, you might have a look at [Infos at Monitoring Portal](https://monitoring-portal.org/t/windows-powershell-checks-with-icinga2/1010).

First, you need a new CheckCommand that is used for every new service definition. This definition needs to be available on all instances (master/satellite(s)/client(s)), therefore, it’s recommended to create a new global zone e.g. windows-commands. To do so you need to add this zone to every instance’s zone config, create a folder e.g. /etc/icinga2/zones.d/windows-commands and put the CheckCommand conf file there (it will then be distributed by icinga2 to every satellite and client that have that global zone configured).

Second, you need to place check\_exchange\_powershell on the corresponding client (or “misuse” the the icinga config distribution - like I do - and place the check script in the windows-commands folder).

Third, you need a service check definition usally “apply Service” to define a new check object for that check.

---

<div class="post-metadata">

**Author:** ![opendev](https://community.icinga.com/user_avatar/community.icinga.com/opendev/32/415_2.png) [@opendev](https://community.icinga.com/u/opendev)\
**Post date:** [March 25, 2019, 3:05pm UTC](https://community.icinga.com/t/understanding-windows-ps-plugins-icinga2agent-and-director/705/3 "2019-03-25T15:05:18Z")

</div>

Thanks Roland, you’re link helped a lot. Now I understand how to use the icinga2-commands.conf in director (hopefully there is an easier way to implement the commands in the director instead of creating it by hand). I’ll give it a try implementing the command and creating the service, etc. now. Hope it will work. Thank you.

Regards

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [March 25, 2019, 3:25pm UTC](https://community.icinga.com/t/understanding-windows-ps-plugins-icinga2agent-and-director/705/4 "2019-03-25T15:25:53Z")

</div>

Interesting, I thought we’ve migrated all howtos. Obviously not, it is now located here: [Windows PowerShell Checks with Icinga2](https://community.icinga.com/t/windows-powershell-checks-with-icinga2/712)

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](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).

 ![22](https://community.icinga.com/uploads/default/original/1X/e87fc9684ca9205730672a94a1c6aa9356bf18c3.png)

Then put that command in the `global-templates` cluster zone.

 ![32](https://community.icinga.com/uploads/default/original/1X/4c9f5620a34930bdde2acac4194d1101e1a44116.png)

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](https://github.com/NETWAYS/check_exchange_powershell/blob/master/icinga2-commands.conf#L10)

 ![26](https://community.icinga.com/uploads/default/original/1X/35f0ea77f317a705ac7b44056804b5f77b87159d.png)  
 ![03](https://community.icinga.com/uploads/default/original/1X/01b0c74b99b8ee0fa177a01230bd98884d91e235.png)  
 ![29](https://community.icinga.com/uploads/default/original/1X/88c1bd47d262d00e2157cb2b372206181065e567.png)

Change into the `Fields` tab and make the script parameter mandatory.

 ![17](https://community.icinga.com/uploads/default/original/1X/6f49b8cc2c5048c291410fe6a772160d89cd0702.png)

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.

 ![24](https://community.icinga.com/uploads/default/original/1X/fc713fec186c50399a302d4283eeba8de3763235.png)

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.

---

<div class="post-metadata">

**Author:** ![dnsmichi](https://community.icinga.com/user_avatar/community.icinga.com/dnsmichi/32/7721_2.png) [@dnsmichi](https://community.icinga.com/u/dnsmichi)\
**Post date:** [July 9, 2019, 11:15am UTC](https://community.icinga.com/t/understanding-windows-ps-plugins-icinga2agent-and-director/705/5 "2019-07-09T11:15:57Z")

</div>



---

<div class="post-metadata">

**Author:** ![unixe](https://community.icinga.com/user_avatar/community.icinga.com/unixe/32/73_2.png) [@unixe](https://community.icinga.com/u/unixe)\
**Post date:** [March 30, 2020, 9:31am UTC](https://community.icinga.com/t/understanding-windows-ps-plugins-icinga2agent-and-director/705/6 "2020-03-30T09:31:54Z")

</div>


