It's possible to have honest-to-goodness check_mk scripts execute asynchronously, using the async directive in check_mk.ini. I tried it, it works. However, this is not supported by the agent with classic nagios plugins.
So, I wrote a wrapper named mrpe_async_wrapper that does just that. It's not rocket science; the wrapper is simply a Windows batch file that:
- Creates a scheduled task (on its first run) that executes the check script at 5 minutes intervals;
- The scheduled taks instructs mrpe_async_wrapper to run the check script and save its output in a status file;
- When run directly, mrpe_async_wrapper reports the contents of the status file instead of executing the script. It does it quickly. So, you can run it each minute if you want, but it will only report the status within up to the last 5 minutes.
This lets you run slow or unpredictable NRPE scripts from check_mk without fear. I've been running this for a few days and it seems to do the job for me.
To configure it, simply add a directive to the [mrpe] section of check_mk.ini like this (on the same line)
check = check_gizmo C:\tools\mrpe_async_wrapper.bat check_gizmo C:\tools\check_gizmo.bat
This defines an MRPE check named "check_gizmo", which instructs the wrapper to create a scheduled task named "check_gizmo" that runs c:\tools\check_gizmo.bat asynchrnously.
Here is the code for the wrapper:
mrpe_async_wrapper.bat
Have fun.