I was wondering if there are any free / open source solutions that will start and stop a windows service based on load? I have some pubsub subscriber services that do background work which is not critical. Ideally i would like tot be able to automate things so that these services could start if memory/cpu/disk i/o was under a certain threshold and stop gracefully if that threshold was met. Do you know of any solutions? Thanks JP
migrated from stackoverflow.com Jun 7 '10 at 8:04
There is software built into windows that does this called Windows System Resource Manager (WSRM) it will do what you want i.e. priorities services based on resources.
Obviously not opensource, but comes with the OS.
I'm not aware of an external tool, but you could monitor relevant performance counters inside your service and do no work (sleep for some time period) if performance counters you think are relevant exceed thresholds. This would not be quite the same as stopping the service (it would still be resident in memory), but should achieve the desired end.
One benefit of this approach is that you don't have to worry about setting up and configuring an external tool, or monitoring that the external tool is still working.
You could setup an alert that could run on fixed threshold (say CPU>=75) To setup an alert on windows here is a link http://support.microsoft.com/kb/324752
So you could setup an alert for the condition CPU Usage >=75% and as the command line you could use
This stops the service called svcName.
You could have another alert defined to the opposite CPU Usage < 70% and as the command line you could use
when you it falls below the thresholds.
I kept 5% margin between on and off, though you could create a batch file to delay starting and stopping the service too often.
Hope this helps