Hi Michael. AlwaysUp doesn’t have an “idle CPU” monitor built in, but you can use a Sanity Check Plugin to solve your problem.
What is a “Sanity Check Plugin” you ask?
The Sanity Check feature allows AlwaysUp to detect arbitrary problems with your application running as a windows service. At its heart is a special plugin (a script or executable) that informs AlwaysUp when decisive action — such as restarting your application or rebooting the machine — is necessary. Dig into the technical details at the Sanity Check page.
Our pre-configured CheckForCPUActivity plugin will empower AlwaysUp to restart ncrack if it sits idle for too long. Here is how to set it up:
First, make sure that you have AlwaysUp version 10.2 or later on your machine. That release (from June 2017) introduced important enhancements to the Sanity Check feature.
Select Help > About AlwaysUp… to check what version of AlwaysUp you have installed:
Next, download the CheckForCPUActivity utility from our web site. Save it in your AlwaysUp installation folder, usually
C:\Program Files (x86)\AlwaysUp\
Edit your application in AlwaysUp.
Switch to the Monitor tab. Check the Whenever it fails a “sanity check” box and click the triple-dots button:
Working with the “Configure Sanity Check” window that comes up:
In the Run field, enter the following command line:
"C:\Program Files (x86)\AlwaysUp
\CheckForCPUActivity.exe" $ALWAYSUP_PID 60
This will check ncrack for any CPU activity over 60 seconds.
Using the Every controls, specify how often AlwaysUp should inspect ncrack. Every 10 minutes should be sufficient but feel free to tune as you like.
Click the OK button.
And finally, click the Save >> button to record your changes.
With these settings in place, AlwaysUp will launch CheckForCPUActivity every 10 minutes. Each run will watch ncrack for 60 seconds and if no CPU activity is detected over that period, AlwaysUp will restart ncrack.
A note to other customers: This approach will work with any application where minimal CPU usage indicates a failure. The solution presented is not specific to ncrack.
Best of luck with your windows service!