loadwatch project allows a single child process to run only when the load on a machine is within certain bounds.
The process is only restarted when the machines load drops below the low load mark. The load is checked at a user definable interval. loadwatch is distributed under the GNU GPL.
loadwatch [-d < time>] [-h < load>] [-l < load>] [-n < copies] [-p < pid>] [-- < command>]
-d < int> load sampling interval (10 seconds)
-h < float> high load mark (1.25)
-l < float> low load mark (0.25)
-n < copies> number of children to fork (1)
-u < filename> file that will be used to externally control a
-p < pid> pid of process to control (loadwatch will actually
send signals to the group containing this pid)
NOTE: -p and < command> are mutually exclusive, but one has to be
loadwatch -d 10 -h 1.25 -l .25 -- ./rc5des
which means: check the load every 10 seconds, stop rc5des when the load is
greater than 1.25 and restart rc5des when the load drops to .25.
lw-ctl < filename> < cmd>
< filename> is the control file, this corresponds to a unix domain
< cmd> is the command to send to the loadwatch process.
RUN -> put loadwatch into RUN mode, that is the child process
runs regardless of the load.
STOP -> put loadwatch into STOP mode, that is, the child
process will not run regardless of the load.
WATCH -> WATCH mode, the normal load watching mode.
lw-ctl ./fooey RUN
Causes the loadwatch process (if it was started with "-u ./fooey") to go
into RUN mode. you could put lw-ctl in a cron job that runs in the
morning to put the job in STOP mode and then again in the evening to put
the job back into WATCH mode.
The children which loadwatch forks are all part of the same process group.
loadwatch stops and starts the processes by signalling the process
group with SIGSTOP and SIGCONT respectively.
Send suggestions and bug reports to . if you do anything
interesting with loadwatch, let me know. i use it for controlling the
distributed.net clients, but i figure it'd be good to control thinks like
crack as well.