The Core Technologies Blog

Professional Software for Windows Services / 24×7 Operation


Q & A: Can AlwaysUp Kill & Restart my Idle Application?

Q & A
  I’m using ncrack to monitor our network. I recently started running it as a windows service under AlwaysUp. Everything is working perfectly except that sometimes ncrack stops capturing traffic. The CPU goes to zero and nothing else is written to the log files. Is there some way to get AlwaysUp to terminate ncrack and start a fresh instance?

— Michael

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:

  1. 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:

  2. Next, download the CheckForCPUActivity utility from our web site. Save it in your AlwaysUp installation folder, usually C:\Program Files (x86)\AlwaysUp\

  3. Edit your application in AlwaysUp.

  4. Switch to the Monitor tab. Check the Whenever it fails a “sanity check” box and click the triple-dots button:

  5. Working with the “Configure Sanity Check” window that comes up:

    1. 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.

    2. 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.

    3. Click the OK button.

  6. 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!

Posted in AlwaysUp | Tagged , , , , | Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *