Where to put local checks for Windows for the Agent Bakery (CMK 2.1)

Hello,
I would like to distribute local checks for Windows systems via Agent Bakery.

If I place the check manually on the server in "C:\ProgramData\checkmk\agent\local" it works as expected.
And for Linux systems, the distribution of local checks via Agent Bakery is working.

But I can’t figure out in which subdirectory I have to place the PowerShell (.ps1) files on the checkmk server. For Linux, there are many examples in the documentation, but not for Windows.

For Linux, I put them on the server in local/share/check_mk/agents/custom/check_name/lib/local/.
Where should I put them for Windows so that they end up in "C:\ProgramData\checkmk\agent\local"?
I have tried:

  • local/share/check_mk/agents/custom/check_name/check.ps1
  • local/share/check_mk/agents/custom/check_name/agent/local/check.ps1
  • local/share/check_mk/agents/custom/check_name/local/check.ps1

and each time I can select the check in “Deploy custom files with agent” but the check is not pat of the new backed .msi file and not deployed to the Windows server.

The CMK server curenlty uses 2.1.0p18.cee on Debian 11 and the monitoring taget Windows Server 2019.

Interesting point. Since 1.6 the Windows directories are split to installation and Program Data but the inline help in 2.1 is still:

Note: When using the windows agent, all logical paths point to the same location - the agent installation dir

I never tested it but it smells like a bug.
Did you tried to search across the filesystem for your file?
I never figured out how to disassemble a MSI file.

Have you tried the same directory for a Windows Local Check?

Thanks, I thought that was the first thing I had checked. But I must have made a mistake there.
For Windows, local/share/check_mk/agents/custom/check_name/lib/local/ works even is there is no lib folder.

2 Likes

Interesting, if you can select the folder then it should work. You would need (I think) execution rights (on the linux file) so the windows agent can run the ps1 file (Dependently on how it does it) - but you should have the file of course in the windows agent.

This should be used as reference - Monitoring Windows - The new agent for Windows in detail

And there the path for local check is defined.

The check needs to be in the right subdirectory to be included in the agent.

If I put for Linux files in check_mk/agents/custom/check_name/lib/plugins/ the file is copped in the plugin’s folder on the target system and makes it possible to replace checkmk build in checks (e.g. with a patched version).

That is why I thought the folder structure needs to represent the folder structure on the target system.

For me, the problem is solved. Maybe the documentation could be improved, but on the other side I thought that I had tested the solution which works now and must have done something wrong in the first test.

Unfortunately this is not quite the case. E.g. if you put an executable into a bin subdirectory for a custom file group it ends up in /usr/bin in the agent package.

1 Like

I agree. Some more examples for the different OSs would save ones time.