Local check not recognised in checkmk server

My local powershell script is not being picked up as a local check on the checkmk server:
image

However it is being picked up in the rule ‘Deploy…’
image

I’ve made the custom folder downwards with full access also.

I tested the script manually by placing into a windows checkmk local folder and this produced the service successfully.
However I cannot use the local check to push via the agent bakery.

Can anyone help?

You can look into the cached agent output on the CheckMK server in order to determine if the expected output is there at all. It can be found in ~siteuser/tmp/check_mk/cache/<name_of_monitored_host>

I’ve found that host in this location but how do you check this? It says it’s not a directory.
See my original screenshot, shouldn’t it show up as a service though from that command?

1 Like

When debugging you should start from the part that can be the most easily verified and work your way from there to the part that requires that everything else works. In this case the “most easily verified” is running the script on the monitored host & verify that it outputs something. The next step is to verify that the same output is actually transported via the agent to the server & present there — that’s why I said to look at the agent’s cache file on the server. If the output isn’t present there, the command shown in your screenshot has no chance of working as there’s no output to work with.

1 Like

See original post I have already manually tested and ran it on the server by placing it into the local folder there.
Do you mean the agents cache file on the checkmk server or the hosts server? Because on the checkmk linux server it says the host is not a directory.

image
So how do I check the cache of this host on the checkmk server?

Yes, that’s a file, a text file. Just use less <name_of_your_cache_file> or any other text viewer/editor.

Ok thanks, and what would I be looking for here exactly?

The output your PowerShell script produces.

Also verify that the output is actually following the format that a local script must produce: a single line; the first column being the status code (0, 1, 2 or 3 for OK, warning, critical, unknown respectively); the second column being the name (if it contains spaces: quoted with single quotes) ; the third column being the metrics or a simple dash - if there are no metrics; the rest being the status output.

Here’s an example of what you might find in that cache file:

<<<local:sep(0)>>>
0 'Unconfigured packages' - all packages configured

That would be valid content. The <<<local:sep(0)>>> is a section header emitted by the agent itself, the other line is produced by a local plugin I have written myself. It follows the format outlined above.

My format is correct as I’ve tested it successfully from the local folder on the server.
image

However I don’t see the output in that cached file. Also I don’t have the <<local:sep(0)>> because it doesn’t say this is needed in the documentation (unless I’ve missed this?) if the correct directory has been created:
/omd/sites/[mysite]/local/share/check_mk/agents/custom/AzureBackupCheck/lib/local

It isn’t being passed to the agent on the host basically. How can we troubleshoot why this is? I’ve already checked executable permissions etc…
Blue mark here is my site user account.
image

I think you two are talking about different problems here.
I assuem that the problem is, that the powershell file is not being present in the local directory of the monitored server ?

Did you bake the agents after you created the rule ?
Do you use the agent updater plugin to distribute the agent packages or did you download and reinstalled the agent with the new package ?

1 Like

Yes I baked the agent with the ‘Deploy…’ rule and I also manually installed the newly baked agent file.
So running this command as per the documentation screenshot the server doesn’t recognise the script as a new service, which I presume is the initial reason why it won’t be pushed out to the server via the agent.


image

If you search for that Host in the search Filter of the Bakery, do you see the custom Plugin in the Configuration

Yes

And the Script is not being present in c:\programdata\checkmk\agent\local ?

Is that what the bakery is actually doing just pushing the script to this folder like Group Policy would I didn’t realise that.

But yes it’s not there. Is there a way of clearing the cache of having it re-try this maybe?
But still I point back to why the service wasn’t found when running the command on the checkmk server?

Are the permissions of the subfolders below custom correct?
Are those all accessible by the Site User?

The Bakery creates Agent Installation packages based on the Bakery ruleset. With the rules you can bake Plugins and Configuration into the Installation packages.
If you bake a local Plugin into the package and Install it on the monitored server, it should appear in the local directory.

These scripts are then executed every time the checkmk agent is contacted by the checkmk server.

So If you want to test and troubleshoot your Script first, put it into the local folder and we can See, if we get it to work.
If it does, we can then distribute it from the Bakery.