{"id":3487,"date":"2018-01-29T05:38:34","date_gmt":"2018-01-29T13:38:34","guid":{"rendered":"https:\/\/www.coretechnologies.com\/blog\/?p=3487"},"modified":"2022-05-01T22:44:08","modified_gmt":"2022-05-02T05:44:08","slug":"restart-idle-application","status":"publish","type":"post","link":"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/restart-idle-application\/","title":{"rendered":"Q &#038; A: Can AlwaysUp Kill &#038; Restart my Idle Application?"},"content":{"rendered":"<div align=\"center\"><img loading=\"lazy\" decoding=\"async\" class=\"no-lazy-load\" src=\"\/blog\/images\/qa.webp\" title=\"Q &#038; A\" alt=\"Q &#038; A\" width=\"172\" height=\"127\" border=\"0\" \/><\/div>\n<div class=\"blog-qa-question-box\">\n<img loading=\"lazy\" decoding=\"async\" class=\"no-lazy-load\" src=\"https:\/\/cdn.coretechnologies.com\/images\/quotes-transparent-21x21.webp\" width=\"21\" height=\"21\" \/>&nbsp;&nbsp;I&#8217;m using <a href=\"https:\/\/nmap.org\/ncrack\/\" target=\"_blank\" rel=\"noopener noreferrer\">ncrack<\/a> to monitor our network. I recently started running it as a windows service under <a href=\"\/products\/AlwaysUp\/\">AlwaysUp<\/a>. 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. <b>Is there some way to get AlwaysUp to terminate ncrack and start a fresh instance?<\/b><\/p>\n<p align=\"right\">&#8212; Michael<\/p>\n<\/div>\n<p>\nHi Michael. AlwaysUp doesn&#8217;t have an &#8220;idle CPU&#8221; monitor built in, but you can use a <a href=\"\/products\/AlwaysUp\/Plugins\/\">Sanity Check Plugin<\/a> to solve your problem.\n<\/p>\n<p>\nWhat is a &#8220;Sanity Check Plugin&#8221; you ask?\n<\/p>\n<p>\nThe 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 &#8212; such as restarting your application or rebooting the machine &#8212; is necessary. Dig into the technical details at the <a href=\"\/products\/AlwaysUp\/Plugins\/\">Sanity Check page<\/a>.\n<\/p>\n<p>\nOur pre-configured <a href=\"\/products\/AlwaysUp\/Plugins\/#CheckForCPUActivity\">CheckForCPUActivity<\/a> plugin will empower AlwaysUp to restart ncrack if it sits idle for too long. Here is how to set it up:\n<\/p>\n<ol>\n<li>\n<p>\nFirst, 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.\n<\/p>\n<p>\nSelect <b>Help &gt; About AlwaysUp&#8230;<\/b> to check what version of AlwaysUp you have installed:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/alwaysup-version-number-win-2016.png\" class=\"zoomPopup\" rel=\"zoomgroup noopener noreferrer\" title=\"AlwaysUp Version Number\" target=\"_blank\"><br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"\/blog\/images\/alwaysup-version-number-win-2016.png\" width=\"341\" height=\"445\" title=\"AlwaysUp Version Number (click to enlarge)\" alt=\"AlwaysUp Version Number\" border=\"0\" ><\/a><\/div>\n<\/p>\n<\/li>\n<li>\n<p>\nNext, download the <a href=\"\/products\/AlwaysUp\/Plugins\/#CheckForCPUActivity\">CheckForCPUActivity utility<\/a> from our web site. Save it in your AlwaysUp installation folder, usually <b><nobr>C:\\Program Files (x86)\\AlwaysUp\\<\/nobr><\/b>\n<\/p>\n<\/li>\n<li>\n<p>\nEdit your application in AlwaysUp.\n<\/p>\n<\/li>\n<li>\n<p>\nSwitch to the <b>Monitor<\/b> tab. Check the <b>Whenever it fails a &#8220;sanity check&#8221;<\/b> box and click the triple-dots button:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/activate-sanity-check.png\" class=\"zoomPopup\" rel=\"zoomgroup noopener noreferrer\" title=\"Activate Sanity Check\" target=\"_blank\"><br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"\/blog\/images\/activate-sanity-check.png\" width=\"411\" height=\"592\" title=\"Activate Sanity Check (click to enlarge)\" alt=\"Activate Sanity Check\" border=\"0\" ><\/a><\/div>\n<\/p>\n<\/li>\n<li>\n<p>\nWorking with the &#8220;Configure Sanity Check&#8221; window that comes up:\n<\/p>\n<ol type=\"a\">\n<li>\n<p>In the <b>Run<\/b> field, enter the following command line:<\/p>\n<blockquote><p><b>&quot;C:\\Program Files (x86)\\AlwaysUp<br \/>\n\\CheckForCPUActivity.exe&quot; $ALWAYSUP_PID 60<\/b><\/p><\/blockquote>\n<p>\nThis will check ncrack for any CPU activity over 60 seconds.\n<\/p>\n<\/li>\n<li>\n<p>Using the <b>Every<\/b> controls, specify how often AlwaysUp should inspect ncrack. Every 10 minutes should be sufficient but feel free to tune as you like.<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/configure-cpuactivity-sanity-check.png\" class=\"zoomPopup\" rel=\"zoomgroup noopener noreferrer\" title=\"Configure CPU Activity Sanity Check\" target=\"_blank\"><br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"\/blog\/images\/configure-cpuactivity-sanity-check.png\" width=\"388\" height=\"222\" title=\"Configure CPU Activity Sanity Check (click to enlarge)\" alt=\"Configure CPU Activity Sanity Check\" border=\"0\" ><\/a><\/div>\n<\/li>\n<li>\n<p>\nClick the <b>OK<\/b> button.\n<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<li>\n<p>\nAnd finally, click the <b>Save &gt;&gt;<\/b> button to record your changes.\n<\/p>\n<\/li>\n<\/ol>\n<p><\/p>\n<p>\nWith 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.\n<\/p>\n<p><\/p>\n<p>\nA note to other customers: <b>This approach will work with any application where minimal CPU usage indicates a failure.<\/b> The solution presented is not specific to ncrack.\n<\/p>\n<p><\/p>\n<p>\nBest of luck with your windows service!<\/p>\n<!-- relpost-thumb-wrapper --><div class=\"relpost-thumb-wrapper\"><!-- filter-class --><div class=\"relpost-thumb-container\"><style>.relpost-block-single-image, .relpost-post-image { margin-bottom: 10px; }<\/style><h3>You may also like...<\/h3><div style=\"clear: both\"><\/div><div style=\"clear: both\"><\/div><!-- relpost-block-container --><div class=\"relpost-block-container relpost-block-column-layout\" style=\"--relposth-columns: 3;--relposth-columns_t: 2; --relposth-columns_m: 2\"><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/user-account-feature\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"AlwaysUp Feature Spotlight: Run Your App in a User Account\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/user-login-150x150-1.webp\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">AlwaysUp Feature Spotlight: Run Your App in a User Account<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/windows-services\/interactive-services-removed-windows-10\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Interactive Services Detection Service Removed in Windows 10 (so no more Switching to Session 0)\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/session-0-off-limits-150x150.png\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">Interactive Services Detection Service Removed in Windows 10 (so no more Switching to Session 0)<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/why-application-stopped\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Q&amp;A: Why does AlwaysUp Think my Application Stopped?\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/why-stopped-150x150-1.png\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">Q&amp;A: Why does AlwaysUp Think my Application Stopped?<\/h2><\/div><\/div><\/a><\/div><!-- close relpost-block-container --><div style=\"clear: both\"><\/div><\/div><!-- close filter class --><\/div><!-- close relpost-thumb-wrapper -->","protected":false},"excerpt":{"rendered":"<p>&nbsp;&nbsp;I&#8217;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 &hellip; <a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/restart-idle-application\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":3560,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[26,52,107,127,138],"class_list":["post-3487","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-alwaysup","tag-alwaysup-tag","tag-check-cpu-activity","tag-ncrack","tag-qa","tag-sanity-check"],"_links":{"self":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/3487","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=3487"}],"version-history":[{"count":1,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/3487\/revisions"}],"predecessor-version":[{"id":11300,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/3487\/revisions\/11300"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media\/3560"}],"wp:attachment":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=3487"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=3487"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=3487"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}