--- loadwatch-1.0+1.1alpha1.orig/Makefile.in +++ loadwatch-1.0+1.1alpha1/Makefile.in @@ -6,23 +6,26 @@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ MKINSTALLDIRS= @srcdir@/mkinstalldirs +DESTDIR= CC=@CC@ LIBS=@LIBS@ +CPPFLAGS=@CPPFLAGS@ CFLAGS=@CFLAGS@ +LDFLAGS=@LDFLAGS@ all: loadwatch lw-ctl loadwatch: loadwatch.o - $(CC) -o $@ $^ $(LIBS) + $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) lw-ctl: lw-ctl.o - $(CC) -o $@ $^ $(LIBS) + $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) install: all - $(MKINSTALLDIRS) $(bindir) - $(INSTALL_PROGRAM) loadwatch $(bindir)/loadwatch - $(INSTALL_PROGRAM) lw-ctl $(bindir)/loadwatch + $(MKINSTALLDIRS) $(DESTDIR)$(bindir) + $(INSTALL_PROGRAM) loadwatch $(DESTDIR)$(bindir)/loadwatch + $(INSTALL_PROGRAM) lw-ctl $(DESTDIR)$(bindir)/lw-ctl clean: -rm -f *.o loadwatch lw-ctl --- loadwatch-1.0+1.1alpha1.orig/configure.in +++ loadwatch-1.0+1.1alpha1/configure.in @@ -8,7 +8,7 @@ dnl Checks for libraries. AC_CHECK_LIB(elf, elf_begin, [LIBS="$LIBS -lelf"]) -AC_CHECK_LIB(kstat, kstat_open, [AC_DEFINE(HAVE_KSTAT) LIBS="$LIBS -lkstat"]) +AC_CHECK_LIB(kstat, kstat_open, [AC_DEFINE([HAVE_KSTAT], [], [Define if kstat library exists.]) LIBS="$LIBS -lkstat"]) dnl Checks for header files. AC_HEADER_STDC --- loadwatch-1.0+1.1alpha1.orig/debian/README.debian +++ loadwatch-1.0+1.1alpha1/debian/README.debian @@ -0,0 +1,19 @@ +loadwatch for DEBIAN +---------------------- + +Loadwatch is essentially a hack originally designed to allow rc5des +processes to run in large compute labs without disturbing the "real" +users. As it has been effective in achieving this goal, the author +(lantz_moore@contigo.com) and I decided that "debianization" was +worthwhile. + +In general, one will want to run it like this: +loadwatch -d 15 -h 1.25 -l 0.25 -- ./rc5des + +"-d" sets the period in seconds between "uptime" samples. +"-h" sets the high load mark where a SIGSTOP should be sent to the child +process. +"-l" sets the low load mark where a SIGCONT should be sent to the child to +continue it. + +Dale E. Martin , Wed, 18 Nov 1998 18:53:02 -0500 --- loadwatch-1.0+1.1alpha1.orig/debian/changelog +++ loadwatch-1.0+1.1alpha1/debian/changelog @@ -0,0 +1,107 @@ +loadwatch (1.0+1.1alpha1-6) unstable; urgency=low + + * Switch to debhelper compat level 9. (Closes: #800256) + * Use CPPFLAGS and LDFLAGS for compilation. + * Use dh_autoreconf, dpkg-architecture and dpkg-buildflags. + * Modify configure.in for dh_autoreconf. + * Add build-arch and build-indep targets. + * Do not ignore failures of the make distclean invocation. + * Remove debian/watch file as the upstream website seems to have + disappeared. (Closes: #450305, #529126) + * Use debhelper’s ${misc:Depends}. + * Bump Standards-Version: to 3.9.6. + + -- Nicolas Boullis Sun, 31 Jan 2016 02:32:08 +0100 + +loadwatch (1.0+1.1alpha1-5) unstable; urgency=low + + * Fixed long description thanks to Colin Watson. + * Fixed manpages thanks to Anthony DeRobertis and Nick Rusnov. + * Bump Standards-Version: to 3.6.1. + + -- Nicolas Boullis Fri, 29 Aug 2003 01:27:13 +0200 + +loadwatch (1.0+1.1alpha1-4) unstable; urgency=low + + * Append '\0' to the command read on the UNIX socket. + - loadwatch + lw-ctl should now work properly. + - valgrind rulez. + * Make the build-dependency on debhelper versionned. + + -- Nicolas Boullis Wed, 12 Feb 2003 22:56:24 +0100 + +loadwatch (1.0+1.1alpha1-3) unstable; urgency=low + + * Fix whatis entries in manpages. + * Bump Standards-Version: to 3.5.8. + * Patch Makefile.in to support DESTDIR. + * Cleaned debian/rules a little more. + * Include in lw-ctl.c for exit(). + + -- Nicolas Boullis Sun, 26 Jan 2003 01:45:50 +0100 + +loadwatch (1.0+1.1alpha1-2) unstable; urgency=low + + * Cleaned debian/rules a little bit. + * Applied patch by Arnaud Giersch. (Closes: #158844) + * Removed obsolete "local variables:" from changelog. + * Bumped Standards-Version to 3.5.7. + * Correctly set optimization options. + + -- Nicolas Boullis Thu, 5 Sep 2002 00:46:09 +0200 + +loadwatch (1.0+1.1alpha1-1) unstable; urgency=low + + * New upstream release. (Closes: #146742) + * Fixed a tiny mistake in upstream's Makefile.in. + * Reapplied previous patches. + * Updated manpage for loadwatch and wrote a new one for lw-ctl. + + -- Nicolas Boullis Wed, 29 May 2002 20:16:59 +0200 + +loadwatch (1.0-6) unstable; urgency=low + + * New maintainer. (Closes: #142414) + * Fixed a spelling error in the description. (Closes: #125091) + * Fixed a "bug" in the manpage. (Closes: #101096) + * Children exit if exec fails. (Closes: #88990) + * Search the command in $PATH. + * Fixed a (probably harmless) buffer overflow with more that 100 + copies. + + -- Nicolas Boullis Fri, 3 May 2002 22:57:10 +0200 + +loadwatch (1.0-5) frozen unstable; urgency=low + + * Orphaning package. + + -- Dale E Martin Thu, 11 Apr 2002 13:53:20 -0400 + +loadwatch (1.0-4) frozen unstable; urgency=low + + * Oops, forgot to sign the last packages. Incrementing for a new upload. + + -- Dale E Martin Thu, 11 Apr 2002 11:56:15 -0400 + +loadwatch (1.0-3) frozen unstable; urgency=low + + * Bringing up to current standards. + + -- Dale E Martin Thu, 11 Apr 2002 11:37:52 -0400 + +loadwatch (1.0-2) frozen unstable; urgency=low + + * Fixed a couple of tiny packaging problems that have been reported. + * Brought package up to latest Debian policy standard. + * Closes #51252. + * Closes #53837. + + -- Dale E Martin Thu, 11 Apr 2002 11:37:07 -0400 + +loadwatch (1.0-1) unstable; urgency=low + + * Initial Release. + + -- Dale E. Martin Tue, 18 Jan 2000 09:01:28 -0500 + + --- loadwatch-1.0+1.1alpha1.orig/debian/compat +++ loadwatch-1.0+1.1alpha1/debian/compat @@ -0,0 +1 @@ +9 --- loadwatch-1.0+1.1alpha1.orig/debian/control +++ loadwatch-1.0+1.1alpha1/debian/control @@ -0,0 +1,17 @@ +Source: loadwatch +Section: utils +Priority: optional +Maintainer: Nicolas Boullis +Build-Depends: debhelper (>= 9), dh-autoreconf +Standards-Version: 3.9.6 + +Package: loadwatch +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Run a program using only idle cycles + loadwatch forks a child process and only allows it to run when the + system load meets user-defined parameters. It allows you to specify + that a program should run only if the load is below a specified + point, and will stop it when that point is reached. When the load + falls below a second specified point, the program will be + continued. The user can also specify the system load sampling period. --- loadwatch-1.0+1.1alpha1.orig/debian/copyright +++ loadwatch-1.0+1.1alpha1/debian/copyright @@ -0,0 +1,14 @@ +This package was debianized by Dale E. Martin dmartin@debian.org on +Wed, 18 Nov 1998 18:53:02 -0500. + +It was downloaded from rplay.doit.org + +Upstream Author: lantz_moore@contigo.com + +Copyright: + +loadwatch is released under the GNU GPL license as free, open source soft- +ware. Hopefully it will seem useful to someone. NO WARRANTY. + +On Debian GNU/Linux systems, the complete text of the GNU General Public +License can be found in /usr/share/common-licenses/GPL. --- loadwatch-1.0+1.1alpha1.orig/debian/dirs +++ loadwatch-1.0+1.1alpha1/debian/dirs @@ -0,0 +1,3 @@ +usr/bin +usr/share/man/man1 + --- loadwatch-1.0+1.1alpha1.orig/debian/docs +++ loadwatch-1.0+1.1alpha1/debian/docs @@ -0,0 +1 @@ +README TODO --- loadwatch-1.0+1.1alpha1.orig/debian/loadwatch.1 +++ loadwatch-1.0+1.1alpha1/debian/loadwatch.1 @@ -0,0 +1,69 @@ +.TH LOADWATCH 1 "July 2003" + +.SH NAME +loadwatch \- run a program when machine is idle + +.SH SYNOPSIS +\fBloadwatch\fR [\fIoptions\fR] \fB\-p\fR \fIpid\fR | [--] +\fIprog\fR [\fIargs\fR] +.br + +.SH DESCRIPTION + +\fBloadwatch\fR either spawns a child process \fIprog\fR with the +arguments \fIargs\fR and controls it with all its process group, or +takes control of an already running process with pid \fIpid\fR with all +its process group. + +\fBloadwatch\fR allows the controlled processes to run while the load +average remains below \fIhigh_limit\fR. Every \fIdelay\fR seconds, +\fBloadwatch\fR checks the load average. If the load is above +\fIhigh_limit\fR, the child is suspended; the child is resumed when the +load falls below \fIlow_limit\fR. + +.SH OPTIONS +A summary of options is included below. +.TP +\fB\-h\fR \fIhigh_limit\fR +A decimal value that sets the system load at which the child process will +be suspended. (Default: 1.25) +.TP +\fB\-l\fR \fIlow_limit\fR +A decimal value that sets the system load at which the child process will +be resumed. (Default: 0.25) +.TP +\fB\-d\fR \fIdelay\fR +An integral number of seconds that sets how often the system load will +be checked. (Default: 10) +.TP +\fB\-n\fR \fIcopies\fR +An integer value that sets the number of copies of \fIprog\fR to +run. (Default: 1) +.TP +\fB\-u\fR \fIfile\fR +Create a UNIX domain socket \fIfile\fR for use by \fBlw-ctl\fR. +.TP +\fB\-p\fR \fIpid\fR +The pid of the program that should be controlled by \fBloadwatch\fR +(with all its process group). + +.SH "SEE ALSO" +lw-ctl(1), nice(1) + +.SH BUGS +You should choose \fIlow_limit\fR and \fIhigh_limit\fR carefully. When +the load drops below \fIlow_limit\fR, the process(es) will be resumed, +and it should not, by itself, cause the load to raise above +\fIhigh_limit\fR, or the whole will oscillate, periodically suspending +and resuming the process(es). + +Similarly, if several instances of loadwatch are running, they may +resume their processes at the same time, leading to oscillations if the +limits are not carefully chosen. Hence, each instance of loadwatch +affects every other instance on the computer, and should not be +considered in isolation. + +.SH AUTHOR +This manual page was written by Dale E. Martin , +for the Debian GNU/Linux system (but may be used by others). It was +then updated by Nicolas Boullis . --- loadwatch-1.0+1.1alpha1.orig/debian/lw-ctl.1 +++ loadwatch-1.0+1.1alpha1/debian/lw-ctl.1 @@ -0,0 +1,46 @@ +.TH LW-CTL 1 "May 2002" + +.SH NAME +lw-ctl \- send commands to a running \fBloadwatch\fR + +.SH SYNOPSIS +\fBlw-ctl\fR \fIfile\fR \fIcommand\fR + +.SH DESCRIPTION + +\fBlw-ctl\fR sends commands to a running \fBloadwatch\fR. You can +instruct \fBloadwatch\fR to enter one of three states, \fBRUN\fR, +\fBSTOP\fR, or \fBWATCH\fR. + +.PP +The parameters are: + +.TP +\fIfile\fR +The UNIX domain socket that \fBloadwatch\fR is listening to. + +.TP +\fIcommand\fR +One of: + +.RS +.TP +\fBRUN\fR +Allow the child process to run regardless of system load. + +.TP +\fBSTOP\fR +Suspend the child process regardless of system load. + +.TP +\fBWATCH\fR +Return to normal mode, where the system load determines if the program +is allowed to run. +.RE + +.SH "SEE ALSO" +loadwatch(1) + +.SH AUTHOR +This manual page was written by Nicolas Boullis , +for the Debian GNU/Linux system (but may be used by others). --- loadwatch-1.0+1.1alpha1.orig/debian/rules +++ loadwatch-1.0+1.1alpha1/debian/rules @@ -0,0 +1,64 @@ +#!/usr/bin/make -f +# MAde with the aid of dh_make, by Craig Small +# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. +# Some lines taken from debmake, by Cristoph Lameter. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# These are used for cross-compiling and for saving the configure script +# from having to guess our platform (since we know it already) +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) + +dpkg_buildflags := dpkg-buildflags +dpkg_buildflags := DEB_CFLAGS_MAINT_PREPEND="-Wall" $(dpkg_buildflags) + +build: build-indep build-arch +build-indep: +build-arch: build-stamp +build-stamp: + dh_testdir + dh_autoreconf + ./configure $(shell $(dpkg_buildflags) --export=configure) --prefix=/usr --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) + $(MAKE) + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp install-stamp + [ ! -f Makefile ] || $(MAKE) distclean + dh_autoreconf_clean + dh_clean + +install: install-stamp +install-stamp: build-stamp + dh_testdir + dh_testroot + dh_installdirs + $(MAKE) install DESTDIR=`pwd`/debian/loadwatch + touch install-stamp + +# Build architecture-independent files here. +binary-indep: build-indep install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build-arch install + dh_testdir + dh_testroot + dh_installdocs + dh_installman debian/loadwatch.1 debian/lw-ctl.1 + dh_installchangelogs + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary --- loadwatch-1.0+1.1alpha1.orig/loadwatch.c +++ loadwatch-1.0+1.1alpha1/loadwatch.c @@ -1,3 +1,6 @@ +/* for getpgid() */ +#define _XOPEN_SOURCE 500 + #include #include #include @@ -20,7 +23,7 @@ pid_t child; pid_t attach = -1; -pid_t children[100]; +pid_t *children; int copies = 1; #define RUNNING 1 #define STOPPED 2 @@ -35,7 +38,7 @@ now = time(0); outline = ctime(&now); - if (p = strchr(outline, '\n')) + if ((p = strchr(outline, '\n'))) *p = 0; return outline; @@ -86,7 +89,7 @@ } tbr = 0; - cmd = malloc(size); + cmd = malloc(size+1); if (cmd) { while (1) @@ -107,6 +110,7 @@ } else if (br == 0) { + cmd[tbr] = '\0'; break; } @@ -143,18 +147,26 @@ if (setpgid(0,0) == -1) { - fprintf(stderr, "%s (%s): cannot set process group (%s)\n", + fprintf(stderr, "%s (%d): cannot set process group (%s)\n", current_time(), getpid(), strerror(errno)); exit(1); } + children = (pid_t *)malloc(copies*sizeof(pid_t)); + if (children == NULL) + { + fprintf(stderr, "%s (%d): cannot allocate memory\n", + current_time(), getpid()); + exit(1); + } + for (i = 0; i < copies; i++) { if ((children[i] = fork()) == 0) { - if (execv(*argv, argv) < 0) + if (execvp(*argv, argv) < 0) { - fprintf(stderr, "%s (%s): error exec'ing command (%s)\n", + fprintf(stderr, "%s (%d): error exec'ing command (%s)\n", current_time(), getpid(), strerror(errno)); exit(1); } @@ -164,8 +176,6 @@ while (1) { pid_t status; - time_t now; - char *p; switch(status = waitpid(0, 0, 0)) { @@ -221,23 +231,17 @@ void usage() { - fprintf(stderr, "loadwatch [-d