Imported Upstream version 1.07
This commit is contained in:
parent
87e0216b00
commit
a8f50c0a7c
53 changed files with 15751 additions and 0 deletions
40
docs/Makefile.am
Normal file
40
docs/Makefile.am
Normal file
|
@ -0,0 +1,40 @@
|
|||
##############################################################################
|
||||
# $Id: Makefile.am,v 1.8 2005/05/17 09:53:00 rockyb Exp $
|
||||
# Copyright (C) 2003, 2004 Rocky Bernstein
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
##############################################################################
|
||||
|
||||
# Section 8 is system administration
|
||||
EXT=8
|
||||
man8_MANS = $(PACKAGE).$(EXT)
|
||||
|
||||
MOSTLYCLEANFILES = *~ $(man8_MANS) $(PACKAGE).html
|
||||
EXTRA_DIST = $(man8_MANS) $(PACKAGE).html
|
||||
DISTCLEANFILES = pod2htmi.tmp pod2htmd.tmp
|
||||
|
||||
# The keeps automake from substituting PS_VARS
|
||||
PS_VARS = ''
|
||||
|
||||
# Files making up the documentation part of this package
|
||||
DOCS = $(man_MANS) $(PACKAGE).html
|
||||
|
||||
# THIS SHOULD BE THE FIRST TARGET!
|
||||
all: $(DOCS) Makefile
|
||||
|
||||
$(PACKAGE).html: ../$(PACKAGE).in
|
||||
-pod2html --infile=../$(PACKAGE).in --outfile=$@
|
||||
|
||||
$(man8_MANS): ../$(PACKAGE).in
|
||||
-pod2man --section=$(EXT) --name=$(PACKAGE) ../$(PACKAGE).in >$@
|
394
docs/Makefile.in
Normal file
394
docs/Makefile.in
Normal file
|
@ -0,0 +1,394 @@
|
|||
# Makefile.in generated by automake 1.10.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
##############################################################################
|
||||
# $Id: Makefile.am,v 1.8 2005/05/17 09:53:00 rockyb Exp $
|
||||
# Copyright (C) 2003, 2004 Rocky Bernstein
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
##############################################################################
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = docs
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_CLEAN_FILES =
|
||||
SOURCES =
|
||||
DIST_SOURCES =
|
||||
man8dir = $(mandir)/man8
|
||||
am__installdirs = "$(DESTDIR)$(man8dir)"
|
||||
NROFF = nroff
|
||||
MANS = $(man8_MANS)
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CVS2CL = @CVS2CL@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
PERL = @PERL@
|
||||
PS = @PS@
|
||||
PS_ARGS = @PS_ARGS@
|
||||
PS_ARGS_FMT = @PS_ARGS_FMT@
|
||||
PS_CAN_RETURN_MULTIPLE_LINES = @PS_CAN_RETURN_MULTIPLE_LINES@
|
||||
PS_CUSTOM_HEADER = @PS_CUSTOM_HEADER@
|
||||
PS_FULLCMD_FMT = @PS_FULLCMD_FMT@
|
||||
PS_NO_NULL_HEADER = @PS_NO_NULL_HEADER@
|
||||
PS_PID_OPTS = @PS_PID_OPTS@
|
||||
PS_TIME_VAR = @PS_TIME_VAR@
|
||||
|
||||
# The keeps automake from substituting PS_VARS
|
||||
PS_VARS = ''
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
||||
# Section 8 is system administration
|
||||
EXT = 8
|
||||
man8_MANS = $(PACKAGE).$(EXT)
|
||||
MOSTLYCLEANFILES = *~ $(man8_MANS) $(PACKAGE).html
|
||||
EXTRA_DIST = $(man8_MANS) $(PACKAGE).html
|
||||
DISTCLEANFILES = pod2htmi.tmp pod2htmd.tmp
|
||||
|
||||
# Files making up the documentation part of this package
|
||||
DOCS = $(man_MANS) $(PACKAGE).html
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
|
||||
&& exit 0; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu docs/Makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(AUTOMAKE) --gnu docs/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
install-man8: $(man8_MANS) $(man_MANS)
|
||||
@$(NORMAL_INSTALL)
|
||||
test -z "$(man8dir)" || $(MKDIR_P) "$(DESTDIR)$(man8dir)"
|
||||
@list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \
|
||||
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
|
||||
for i in $$l2; do \
|
||||
case "$$i" in \
|
||||
*.8*) list="$$list $$i" ;; \
|
||||
esac; \
|
||||
done; \
|
||||
for i in $$list; do \
|
||||
if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
|
||||
else file=$$i; fi; \
|
||||
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
|
||||
case "$$ext" in \
|
||||
8*) ;; \
|
||||
*) ext='8' ;; \
|
||||
esac; \
|
||||
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
|
||||
inst=`echo $$inst | sed -e 's/^.*\///'`; \
|
||||
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
|
||||
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man8dir)/$$inst'"; \
|
||||
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man8dir)/$$inst"; \
|
||||
done
|
||||
uninstall-man8:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \
|
||||
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
|
||||
for i in $$l2; do \
|
||||
case "$$i" in \
|
||||
*.8*) list="$$list $$i" ;; \
|
||||
esac; \
|
||||
done; \
|
||||
for i in $$list; do \
|
||||
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
|
||||
case "$$ext" in \
|
||||
8*) ;; \
|
||||
*) ext='8' ;; \
|
||||
esac; \
|
||||
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
|
||||
inst=`echo $$inst | sed -e 's/^.*\///'`; \
|
||||
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
|
||||
echo " rm -f '$(DESTDIR)$(man8dir)/$$inst'"; \
|
||||
rm -f "$(DESTDIR)$(man8dir)/$$inst"; \
|
||||
done
|
||||
tags: TAGS
|
||||
TAGS:
|
||||
|
||||
ctags: CTAGS
|
||||
CTAGS:
|
||||
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
||||
fi; \
|
||||
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(MANS)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(man8dir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
`test -z '$(STRIP)' || \
|
||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||
mostlyclean-generic:
|
||||
-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-generic
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am: install-man
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-man: install-man8
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-generic
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-man
|
||||
|
||||
uninstall-man: uninstall-man8
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: all all-am check check-am clean clean-generic distclean \
|
||||
distclean-generic distdir dvi dvi-am html html-am info info-am \
|
||||
install install-am install-data install-data-am install-dvi \
|
||||
install-dvi-am install-exec install-exec-am install-html \
|
||||
install-html-am install-info install-info-am install-man \
|
||||
install-man8 install-pdf install-pdf-am install-ps \
|
||||
install-ps-am install-strip installcheck installcheck-am \
|
||||
installdirs maintainer-clean maintainer-clean-generic \
|
||||
mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \
|
||||
uninstall-am uninstall-man uninstall-man8
|
||||
|
||||
|
||||
# THIS SHOULD BE THE FIRST TARGET!
|
||||
all: $(DOCS) Makefile
|
||||
|
||||
$(PACKAGE).html: ../$(PACKAGE).in
|
||||
-pod2html --infile=../$(PACKAGE).in --outfile=$@
|
||||
|
||||
$(man8_MANS): ../$(PACKAGE).in
|
||||
-pod2man --section=$(EXT) --name=$(PACKAGE) ../$(PACKAGE).in >$@
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
740
docs/ps-watcher.8
Normal file
740
docs/ps-watcher.8
Normal file
|
@ -0,0 +1,740 @@
|
|||
.\" Automatically generated by Pod::Man 2.17 (Pod::Simple 3.07)
|
||||
.\"
|
||||
.\" Standard preamble:
|
||||
.\" ========================================================================
|
||||
.de Sh \" Subsection heading
|
||||
.br
|
||||
.if t .Sp
|
||||
.ne 5
|
||||
.PP
|
||||
\fB\&\\$1\fR
|
||||
.PP
|
||||
..
|
||||
.de Sp \" Vertical space (when we can't use .PP)
|
||||
.if t .sp .5v
|
||||
.if n .sp
|
||||
..
|
||||
.de Vb \" Begin verbatim text
|
||||
.ft CW
|
||||
.nf
|
||||
.ne \\$1
|
||||
..
|
||||
.de Ve \" End verbatim text
|
||||
.ft R
|
||||
.fi
|
||||
..
|
||||
.\" Set up some character translations and predefined strings. \*(-- will
|
||||
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
|
||||
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
|
||||
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
|
||||
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
|
||||
.\" nothing in troff, for use with C<>.
|
||||
.tr \(*W-
|
||||
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
|
||||
.ie n \{\
|
||||
. ds -- \(*W-
|
||||
. ds PI pi
|
||||
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
||||
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
||||
. ds L" ""
|
||||
. ds R" ""
|
||||
. ds C` ""
|
||||
. ds C' ""
|
||||
'br\}
|
||||
.el\{\
|
||||
. ds -- \|\(em\|
|
||||
. ds PI \(*p
|
||||
. ds L" ``
|
||||
. ds R" ''
|
||||
'br\}
|
||||
.\"
|
||||
.\" Escape single quotes in literal strings from groff's Unicode transform.
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\"
|
||||
.\" If the F register is turned on, we'll generate index entries on stderr for
|
||||
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
|
||||
.\" entries marked with X<> in POD. Of course, you'll have to process the
|
||||
.\" output yourself in some meaningful fashion.
|
||||
.ie \nF \{\
|
||||
. de IX
|
||||
. tm Index:\\$1\t\\n%\t"\\$2"
|
||||
..
|
||||
. nr % 0
|
||||
. rr F
|
||||
.\}
|
||||
.el \{\
|
||||
. de IX
|
||||
..
|
||||
.\}
|
||||
.\"
|
||||
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
|
||||
.\" Fear. Run. Save yourself. No user-serviceable parts.
|
||||
. \" fudge factors for nroff and troff
|
||||
.if n \{\
|
||||
. ds #H 0
|
||||
. ds #V .8m
|
||||
. ds #F .3m
|
||||
. ds #[ \f1
|
||||
. ds #] \fP
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
|
||||
. ds #V .6m
|
||||
. ds #F 0
|
||||
. ds #[ \&
|
||||
. ds #] \&
|
||||
.\}
|
||||
. \" simple accents for nroff and troff
|
||||
.if n \{\
|
||||
. ds ' \&
|
||||
. ds ` \&
|
||||
. ds ^ \&
|
||||
. ds , \&
|
||||
. ds ~ ~
|
||||
. ds /
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
|
||||
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
|
||||
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
|
||||
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
|
||||
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
|
||||
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
|
||||
.\}
|
||||
. \" troff and (daisy-wheel) nroff accents
|
||||
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
|
||||
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
|
||||
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
|
||||
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
|
||||
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
|
||||
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
|
||||
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
|
||||
.ds ae a\h'-(\w'a'u*4/10)'e
|
||||
.ds Ae A\h'-(\w'A'u*4/10)'E
|
||||
. \" corrections for vroff
|
||||
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
|
||||
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
|
||||
. \" for low resolution devices (crt and lpr)
|
||||
.if \n(.H>23 .if \n(.V>19 \
|
||||
\{\
|
||||
. ds : e
|
||||
. ds 8 ss
|
||||
. ds o a
|
||||
. ds d- d\h'-1'\(ga
|
||||
. ds D- D\h'-1'\(hy
|
||||
. ds th \o'bp'
|
||||
. ds Th \o'LP'
|
||||
. ds ae ae
|
||||
. ds Ae AE
|
||||
.\}
|
||||
.rm #[ #] #H #V #F C
|
||||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "ps-watcher 8"
|
||||
.TH ps-watcher 8 "2008-12-25" "perl v5.8.8" "User Contributed Perl Documentation"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
.nh
|
||||
.SH "NAME"
|
||||
ps\-watcher \- monitors various processes based on ps\-like information.
|
||||
.SH "SYNOPSIS"
|
||||
.IX Header "SYNOPSIS"
|
||||
\&\fBps-watcher\fR [\fIoptions\fR...]
|
||||
[\f(CW\*(C`\-\-config\*(C'\fR] \fIconfig-file\fR
|
||||
.SH "DESCRIPTION"
|
||||
.IX Header "DESCRIPTION"
|
||||
Periodically a list of processes obtained via \f(CW\*(C`ps\*(C'\fR. More precisely
|
||||
each item in the list contains the process name (just what's listed in
|
||||
the \*(L"cmd\*(R" field, not the full command and arguments) and its process
|
||||
id (pid). A configuration file specifies a list of Perl
|
||||
regular-expression patterns to match the processes against. For each
|
||||
match, a Perl expression specified for that pattern is evaluated. The
|
||||
evaluated expression can refer to variables which are set by ps and
|
||||
pertain to the matched process(es), for example the amount memory
|
||||
consumed by the process, or the total elapsed time. Some other
|
||||
variables are set by the program, such as the number of times the
|
||||
process is running. If the Perl expression for a matched pattern
|
||||
evaluates true, then an action can be run such as killing the program,
|
||||
restarting it, or mailing an alert, or running some arbitrary Perl
|
||||
code.
|
||||
.PP
|
||||
Some things you might want to watch a daemon or process for:
|
||||
.IP "\(bu" 2
|
||||
check that it is running (hasn't died)
|
||||
.IP "\(bu" 2
|
||||
ensure it is not running too many times
|
||||
.IP "\(bu" 2
|
||||
isn't consuming too much memory (perhaps a memory leak), or I/O
|
||||
.PP
|
||||
Some actions you might want to take:
|
||||
.IP "\(bu" 2
|
||||
restart a process
|
||||
.IP "\(bu" 2
|
||||
kill off rampant processes
|
||||
.IP "\(bu" 2
|
||||
send an alert about any of the conditions listed above
|
||||
.PP
|
||||
Depending on options specfied, this program can be run as a daemon,
|
||||
run once (which is suitable as a \f(CW\*(C`cron\*(C'\fR job), or run not as a daemon
|
||||
but still continuously (which may be handy in testing the program or
|
||||
your configuration).
|
||||
.Sh "\s-1OPTIONS\s0"
|
||||
.IX Subsection "OPTIONS"
|
||||
.IP "\-\-help" 4
|
||||
.IX Item "--help"
|
||||
Print a usage message on standard error and exit with a return code
|
||||
of 100.
|
||||
.Sp
|
||||
|
||||
.IP "\-\-doc" 4
|
||||
.IX Item "--doc"
|
||||
Extact the full documentation that you are reading now, print it and
|
||||
exit with a return code of 101.
|
||||
.Sp
|
||||
|
||||
.IP "\-\-version" 4
|
||||
.IX Item "--version"
|
||||
Print the version release on standard output and exit with a return
|
||||
code of 10.
|
||||
.Sp
|
||||
|
||||
.IP "\-\-debug \fInumber\fR" 4
|
||||
.IX Item "--debug number"
|
||||
Give debugging output. The higher the number, the more the output. The
|
||||
default is 0 = none. 2 is the most debugging output.
|
||||
.IP "[\-\-config] \fIconfiguration file\fR" 4
|
||||
.IX Item "[--config] configuration file"
|
||||
Specify configuration file. .
|
||||
.Sp
|
||||
See \*(L"\s-1CONFIGURATION\s0 \s-1FILE\s0 \s-1FORMAT\s0\*(R" below for information on the format
|
||||
of the configuration file and \*(L"\s-1EXAMPLE\s0 \s-1CONFIGURATION\s0\*(R" for a complete
|
||||
example of a configuration file.
|
||||
.Sp
|
||||
|
||||
.IP "\-\-log [\fIlog file\fR]" 4
|
||||
.IX Item "--log [log file]"
|
||||
Send or don't send error and debugging output to a log file. If option
|
||||
is given but no logfile is specified, then use \s-1STDERR\s0. The default is
|
||||
no error log file. See also \-\-syslog below.
|
||||
.Sp
|
||||
|
||||
.IP "\-\-syslog | \-\-nosyslog" 4
|
||||
.IX Item "--syslog | --nosyslog"
|
||||
Send or don't send error and debugging output to syslog. The default
|
||||
is to syslog error and debug output.
|
||||
.Sp
|
||||
|
||||
.IP "\-\-daemon | \-\-nodaemon" 4
|
||||
.IX Item "--daemon | --nodaemon"
|
||||
Run or don't as a daemon.
|
||||
.Sp
|
||||
|
||||
.IP "\-\-path \fIsearch-path\fR" 4
|
||||
.IX Item "--path search-path"
|
||||
Specify the executable search path used in running commands.
|
||||
.IP "\-\-ps\-prog \fIprogram\fR" 4
|
||||
.IX Item "--ps-prog program"
|
||||
One can specify the command that gives ps information. By default, the
|
||||
command is \fI/bin/ps\fR.
|
||||
.Sp
|
||||
|
||||
.IP "\-\-run | \-\-norun" 4
|
||||
.IX Item "--run | --norun"
|
||||
do/don't run actions go through the motions as though we were going
|
||||
to. This may be useful in debugging.
|
||||
.Sp
|
||||
|
||||
.IP "\-\-sleep \fIinterval in seconds\fR" 4
|
||||
.IX Item "--sleep interval in seconds"
|
||||
It is expected that one might want to run ps-watcher over and over
|
||||
again. In such instances one can specify the amount of time between
|
||||
iterations with this option.
|
||||
.Sp
|
||||
If a negative number is specified the program is run only once.
|
||||
.Sp
|
||||
|
||||
.Sh "\s-1CONFIGURATION\s0 \s-1FILE\s0 \s-1MODIFICATION\s0 \s-1AND\s0 \s-1SIGNAL\s0 \s-1HANDLING\s0"
|
||||
.IX Subsection "CONFIGURATION FILE MODIFICATION AND SIGNAL HANDLING"
|
||||
Periodically ps-watcher checks to see if the configuration file
|
||||
that it was run against has changed. If so, the program rereads the
|
||||
configuration file.
|
||||
.PP
|
||||
More precisely, the checks are done after waking up from a slumber.
|
||||
If the sleep interval is long (or if you are impatient), you can
|
||||
probably force the program to wake up using a \s-1HUP\s0 signal.
|
||||
.PP
|
||||
At any time you can increase the level of debug output by sending a
|
||||
\&\s-1USR1\s0 signal to the ps-watcher process. Similarly you can decrease the
|
||||
level of debug output by sending the process a \s-1USR2\s0 signal.
|
||||
.PP
|
||||
It is recommended that you terminate ps-watcher via an \s-1INT\s0, \s-1TERM\s0, or \s-1QUIT\s0
|
||||
signal.
|
||||
.SH "CONFIGURATION FILE FORMAT"
|
||||
.IX Header "CONFIGURATION FILE FORMAT"
|
||||
The format of a configuration file is a series of fully qualified
|
||||
filenames enclosed in square brackets followed by a number of
|
||||
parameter lines. Each parameter line has a parameter name followed by
|
||||
an \*(L"equal\*(R" sign and finally value. That is:
|
||||
.PP
|
||||
.Vb 5
|
||||
\& # This is a comment line
|
||||
\& ; So is this.
|
||||
\& [process\-pattern1]
|
||||
\& parameter1 = value1
|
||||
\& parameter2 = value2
|
||||
\&
|
||||
\& [process\-pattern2]
|
||||
\& parameter1 = value3
|
||||
\& parameter2 = value4
|
||||
.Ve
|
||||
.PP
|
||||
Comments start with # or ; and take effect to the end of the line.
|
||||
.PP
|
||||
This should be familiar to those who have worked with text-readible
|
||||
Microsoft \f(CW\*(C`.INI\*(C'\fR files.
|
||||
.PP
|
||||
Note process patterns, (\fIprocess\-pattern1\fR and \fIprocess\-pattern2\fR
|
||||
above) must be unique. If there are times when you may want to
|
||||
refer to the same process, one can be creative to make these unique.
|
||||
e.g. \fIcron\fR and \fI[c]ron\fR which refer to the same process even
|
||||
though they \fIappear\fR to be different.
|
||||
.PP
|
||||
As quoted directly from the Config::IniFiles documentation:
|
||||
.PP
|
||||
Multiline or multivalued fields may also be defined ala \s-1UNIX\s0
|
||||
\&\*(L"here document\*(R" syntax:
|
||||
.PP
|
||||
.Vb 4
|
||||
\& Parameter=<<EOT
|
||||
\& value/line 1
|
||||
\& value/line 2
|
||||
\& EOT
|
||||
.Ve
|
||||
.PP
|
||||
You may use any string you want in place of \*(L"\s-1EOT\s0\*(R". Note
|
||||
that what follows the \*(L"<<\*(R" and what appears at the end of
|
||||
the text \fImust\fR match exactly, including any trailing
|
||||
whitespace.
|
||||
.PP
|
||||
There are two special \*(L"process patterns\*(R": \f(CW$PROLOG\fR and \f(CW$EPILOG\fR, the
|
||||
former should appear first and the latter last.
|
||||
.PP
|
||||
You can put perl code to initialize variables here and do cleanup
|
||||
actions in these sections using \*(L"perl-action.\*(R"
|
||||
.PP
|
||||
A description of parameters names, their meanings and potential values
|
||||
follows.
|
||||
.IP "trigger" 4
|
||||
.IX Item "trigger"
|
||||
This parameter specifies the condition on which a process action is
|
||||
fired. The condition is evaluated with Perl \fIeval()\fR and should
|
||||
therefore return something which is equivalent to \*(L"true\*(R" in a Perl
|
||||
expression.
|
||||
.Sp
|
||||
If no trigger is given in a section, true or 1 is assumed and
|
||||
the action is unconditionally triggered.
|
||||
.Sp
|
||||
Example:
|
||||
.Sp
|
||||
.Vb 8
|
||||
\& # Match if httpd has not spawned enough (<4) times. NFS and databases
|
||||
\& # daemons typically spawn child processes. Since the program
|
||||
\& # matches against the command names, not commands and arguments,
|
||||
\& # something like: ps \-ef | grep httpd won\*(Aqt match the below.
|
||||
\& # If you want to match against the command with arguments, see
|
||||
\& # the example with $args below.
|
||||
\& [httpd$]
|
||||
\& trigger = $count <= 4
|
||||
.Ve
|
||||
.IP "occurs" 4
|
||||
.IX Item "occurs"
|
||||
This parameter specifies how many times an action should be performed
|
||||
on processes matching the section trigger. Acceptable values are
|
||||
\&\*(L"every\*(R", \*(L"first\*(R", \*(L"first-trigger\*(R", and \*(L"none\*(R".
|
||||
.Sp
|
||||
Setting the occurs value to \*(L"none\*(R" causes the the trigger to be
|
||||
evaluated when there are no matching processes. Although one might
|
||||
think \*(L"$count == 0\*(R" in the action expression would do the same thing,
|
||||
currently as coded this does not work.
|
||||
.Sp
|
||||
Setting the occurs value to \*(L"first\*(R" causes the process-pattern rule to
|
||||
be finished after handling the first rule that matches, whether or not the
|
||||
trigger evaluated to true.
|
||||
.Sp
|
||||
Setting the occurs value to \*(L"first-trigger\*(R" causes the process-pattern
|
||||
rule to be finished after handling the first rule that matches \fIand\fR
|
||||
the trigger evaluates to true.
|
||||
.Sp
|
||||
If the item parameter is not specified, \*(L"first\*(R" is assumed.
|
||||
.Sp
|
||||
Examples:
|
||||
.Sp
|
||||
.Vb 3
|
||||
\& [.]
|
||||
\& occurs = first
|
||||
\& action = echo "You have $count processes running"
|
||||
\&
|
||||
\& # Note in the above since there is no trigger specified,
|
||||
\& # occurs = first
|
||||
\& # is the same thing as
|
||||
\& # occurs = first\-trigger
|
||||
\&
|
||||
\& [.?]
|
||||
\& trigger = $vsz > 1000
|
||||
\& occurs = every
|
||||
\& action = echo "Large program $command matches $ps_pat: $vsz KB"
|
||||
\&
|
||||
\& # Fire if /usr/sbin/syslogd is not running.
|
||||
\& # Since the program matches against the command names, not commands and
|
||||
\& # arguments, something like:
|
||||
\& # ps \-ef | grep /usr/sbin/syslogd
|
||||
\& # won\*(Aqt match the below.
|
||||
\& [(/usr/sbin/)?syslogd]
|
||||
\& occurs = none
|
||||
\& action = /etc/init.d/syslogd start
|
||||
.Ve
|
||||
.IP "action" 4
|
||||
.IX Item "action"
|
||||
This specifies the action, a command that gets run by the system
|
||||
shell, when the trigger condition is evaluated to be true.
|
||||
.Sp
|
||||
Example:
|
||||
.Sp
|
||||
.Vb 1
|
||||
\& action = /etc/init.d/market_loader.init restart
|
||||
.Ve
|
||||
.IP "perl-action" 4
|
||||
.IX Item "perl-action"
|
||||
This specifies Perl statements to be eval'd. This can be especially
|
||||
useful in conjunction with \f(CW$PROLOG\fR and \f(CW$EPILOG\fR sections to make tests
|
||||
across collections of process and do things which ps-watcher
|
||||
would otherwise not be able to do.
|
||||
.Sp
|
||||
Example:
|
||||
.Sp
|
||||
.Vb 5
|
||||
\& # A Perl variable initialization.
|
||||
\& # Since ps\-watcher runs as a daemon it\*(Aqs a good idea
|
||||
\& # to (re)initialize variables before each run.
|
||||
\& [$PROLOG]
|
||||
\& perl\-action = $root_procs=0;
|
||||
\&
|
||||
\& # Keep track of how many root processes we are running
|
||||
\& [.*]
|
||||
\& perl\-action = $root_procs++ if $uid == 0
|
||||
\& occurs = every
|
||||
\&
|
||||
\& # Show this count.
|
||||
\& [$EPILOG]
|
||||
\& action = echo "I counted $root_procs root processes"
|
||||
.Ve
|
||||
.Sh "\s-1EXPANDED\s0 \s-1VARIABLES\s0 \s-1IN\s0 \s-1TRIGGER/ACTION\s0 \s-1CLAUSES\s0"
|
||||
.IX Subsection "EXPANDED VARIABLES IN TRIGGER/ACTION CLAUSES"
|
||||
Any variables defined in the program can be used in pattern or
|
||||
action parameters. For example, \f(CW$program\fR can be used to refer to
|
||||
the name of this program ps-watcher.
|
||||
.PP
|
||||
The following variables can be used in either the pattern or action
|
||||
fields.
|
||||
.ie n .IP "$action" 4
|
||||
.el .IP "\f(CW$action\fR" 4
|
||||
.IX Item "$action"
|
||||
A string containing the text of the action to run.
|
||||
.Sp
|
||||
|
||||
.ie n .IP "$perl_action" 4
|
||||
.el .IP "\f(CW$perl_action\fR" 4
|
||||
.IX Item "$perl_action"
|
||||
A string containing the text of the perl_action to run.
|
||||
.Sp
|
||||
|
||||
.ie n .IP "$ps_pat" 4
|
||||
.el .IP "\f(CW$ps_pat\fR" 4
|
||||
.IX Item "$ps_pat"
|
||||
The Perl regular expression specified in the beginning of the section.
|
||||
.Sp
|
||||
|
||||
.ie n .IP "$command" 4
|
||||
.el .IP "\f(CW$command\fR" 4
|
||||
.IX Item "$command"
|
||||
The command that matched \f(CW$ps_pat\fR.
|
||||
.Sp
|
||||
The Perl regular expression specified in the beginning of the section.
|
||||
Normally processes will not have funny characters in them. Just in
|
||||
case, backticks in \f(CW$command\fR are escaped.
|
||||
.Sp
|
||||
Example:
|
||||
.Sp
|
||||
.Vb 2
|
||||
\& # List processes other than emacs (which is a known pig) that use lots
|
||||
\& # of virtual memory
|
||||
\&
|
||||
\& [.*]
|
||||
\& trigger = $command !~ /emacs$/ && $vsz > 10
|
||||
\& action = echo \e"Looks like you have a big \e$command program: \e$vsz KB\e"
|
||||
.Ve
|
||||
.Sp
|
||||
|
||||
.ie n .IP "$count" 4
|
||||
.el .IP "\f(CW$count\fR" 4
|
||||
.IX Item "$count"
|
||||
The number of times the pattern matched. Presumably the number of
|
||||
processes of this class running.
|
||||
.Sp
|
||||
|
||||
.ie n .IP "$trigger" 4
|
||||
.el .IP "\f(CW$trigger\fR" 4
|
||||
.IX Item "$trigger"
|
||||
A string containing the text of the trigger.
|
||||
.PP
|
||||
A list of variables specific to this program or fields commonly found in
|
||||
\&\f(CW\*(C`ps\*(C'\fR output is listed below followed by a description of the more
|
||||
common ones. See also \f(CW\*(C`ps\*(C'\fR for a more complete
|
||||
description of the meaning of the field.
|
||||
.PP
|
||||
.Vb 11
|
||||
\& uid euid ruid gid egid rgid alarm blocked bsdtime c caught
|
||||
\&cputime drs dsiz egroup eip esp etime euser f fgid
|
||||
\&fgroup flag flags fname fsgid fsgroup fsuid fsuser fuid fuser
|
||||
\&group ignored intpri lim longtname m_drs m_trs maj_flt majflt
|
||||
\&min_flt minflt ni nice nwchan opri pagein pcpu pending pgid pgrp
|
||||
\&pmem ppid pri rgroup rss rssize rsz ruser s sess session
|
||||
\&sgi_p sgi_rss sgid sgroup sid sig sig_block sig_catch sig_ignore
|
||||
\&sig_pend sigcatch sigignore sigmask stackp start start_stack start_time
|
||||
\&stat state stime suid suser svgid svgroup svuid svuser sz time timeout
|
||||
\&tmout tname tpgid trs trss tsiz tt tty tty4 tty8 uid_hack uname
|
||||
\&user vsize vsz wchan
|
||||
.Ve
|
||||
.PP
|
||||
Beware though, in some situations ps can return multiple lines for a
|
||||
single process and we will use just one of these in the trigger. In
|
||||
particular, Solaris's \f(CW\*(C`ps\*(C'\fR will return a line for each \s-1LWP\s0 (light-weight
|
||||
process). So on Solaris, if a trigger uses variable lwp, it may or may
|
||||
not match depending on which single line of the multiple \f(CW\*(C`ps\*(C'\fR lines is
|
||||
used.
|
||||
.PP
|
||||
|
||||
.ie n .IP "$args" 4
|
||||
.el .IP "\f(CW$args\fR" 4
|
||||
.IX Item "$args"
|
||||
The command along with its command arguments. It is possible that this
|
||||
is might get truncated at certain length (if ps does likewise as is
|
||||
the case on Solaris).
|
||||
.Sp
|
||||
|
||||
.ie n .IP "$ppid" 4
|
||||
.el .IP "\f(CW$ppid\fR" 4
|
||||
.IX Item "$ppid"
|
||||
The parent process id.
|
||||
.Sp
|
||||
|
||||
.ie n .IP "$stime" 4
|
||||
.el .IP "\f(CW$stime\fR" 4
|
||||
.IX Item "$stime"
|
||||
The start time of the process.
|
||||
.Sp
|
||||
|
||||
.ie n .IP "$etime" 4
|
||||
.el .IP "\f(CW$etime\fR" 4
|
||||
.IX Item "$etime"
|
||||
The end time of the process.
|
||||
.Sp
|
||||
|
||||
.ie n .IP "$pmem" 4
|
||||
.el .IP "\f(CW$pmem\fR" 4
|
||||
.IX Item "$pmem"
|
||||
The process memory.
|
||||
.Sp
|
||||
|
||||
.ie n .IP "$pcpu" 4
|
||||
.el .IP "\f(CW$pcpu\fR" 4
|
||||
.IX Item "$pcpu"
|
||||
The percent \s-1CPU\s0 utilization.
|
||||
.Sp
|
||||
|
||||
.ie n .IP "$tty" 4
|
||||
.el .IP "\f(CW$tty\fR" 4
|
||||
.IX Item "$tty"
|
||||
The controlling tty.
|
||||
.Sp
|
||||
|
||||
.ie n .IP "$vsz" 4
|
||||
.el .IP "\f(CW$vsz\fR" 4
|
||||
.IX Item "$vsz"
|
||||
Virtual memory size of the process
|
||||
.Sh "\s-1OTHER\s0 \s-1THINGS\s0 \s-1IN\s0 \s-1TRIGGER\s0 \s-1CLAUSES\s0"
|
||||
.IX Subsection "OTHER THINGS IN TRIGGER CLAUSES"
|
||||
To make testing against elapsed time easier, a function \f(CW\*(C`elapse2sec()\*(C'\fR
|
||||
has been written to parse and convert elapsed time strings in the
|
||||
format \f(CW\*(C`dd\-hh:mm:ss\*(C'\fR and a number of seconds.
|
||||
.PP
|
||||
Some constants for the number of seconds in a minute, hour, or day
|
||||
have also been defined. These are referred to as \f(CW\*(C`MINS\*(C'\fR, \f(CW\*(C`HOURS\*(C'\fR,
|
||||
and \f(CW\*(C`DAYS\*(C'\fR respectively and they have the expected definitions:
|
||||
.PP
|
||||
.Vb 3
|
||||
\& use constant MINS => 60;
|
||||
\& use constant HOURS => 60*60;
|
||||
\& use constant DAYS => HOURS * 24;
|
||||
.Ve
|
||||
.PP
|
||||
Here is an example of the use of \f(CW\*(C`elapsed2sec()\*(C'\fR:
|
||||
.PP
|
||||
.Vb 7
|
||||
\& # Which processes have been running for more than 3 hours?
|
||||
\& # Also note use of builtin\-function elapsed2secs, variable $etime
|
||||
\& # and builtin\-function HOURS
|
||||
\& [.]
|
||||
\& trigger = elapsed2secs(\*(Aq$etime\*(Aq) > 1*DAYS
|
||||
\& action = echo "$command has been running more than 1 day ($etime)"
|
||||
\& occurs = every
|
||||
.Ve
|
||||
.PP
|
||||
Please note the quotes around '$etime'.
|
||||
.SH "EXAMPLE CONFIGURATION"
|
||||
.IX Header "EXAMPLE CONFIGURATION"
|
||||
.Vb 1
|
||||
\& # Comments start with # or ; and go to the end of the line.
|
||||
\&
|
||||
\& # The format for each entry is in Microsoft .INI form:
|
||||
\& # [process\-pattern]
|
||||
\& # trigger = perl\-expression
|
||||
\& # action = program\-and\-arguments\-to\-run
|
||||
\&
|
||||
\& [httpd$]
|
||||
\& trigger = $count < 4
|
||||
\& action = echo "$trigger fired \-\- You have $count httpd sessions."
|
||||
\&
|
||||
\& [.]
|
||||
\& trigger = $vsz > 10
|
||||
\& action = echo "Looks like you have a big $command program: $vsz KB"
|
||||
\&
|
||||
\& # Unfortunately we have use a different pattern below. (Here we use
|
||||
\& # ".?" instead of ".".) In effect the the two patterns mean
|
||||
\& # test every process.
|
||||
\& [.?]
|
||||
\& trigger = elapsed2secs(\*(Aq$etime\*(Aq) > 2*MINS && $pcpu > 40
|
||||
\& occurs = every
|
||||
\& action = <<EOT
|
||||
\& echo "$command used $pcpu% CPU for the last $etime seconds" | /bin/mail root
|
||||
\& kill \-TERM $pid
|
||||
\& EOT
|
||||
\&
|
||||
\& # Scripts don\*(Aqt show as the script name as the command name on some
|
||||
\& # operating systems. Rather the name of the interpreter is listed
|
||||
\& # (e.g. bash or perl) Here\*(Aqs how you can match against a script.
|
||||
\& # BSD/OS is an exception: it does give the script name rather than
|
||||
\& # the interpreter name.
|
||||
\& [/usr/bin/perl]
|
||||
\& trigger = \e$args !~ /ps\-watcher/
|
||||
\& occurs = every
|
||||
\& action = echo "***found perl program ${pid}:\en $args"
|
||||
.Ve
|
||||
.ie n .SH "Using $PROLOG for getting non-ps information"
|
||||
.el .SH "Using \f(CW$PROLOG\fP for getting non-ps information"
|
||||
.IX Header "Using $PROLOG for getting non-ps information"
|
||||
Here is an example to show how to use ps-watcher to do something not
|
||||
really possible from ps: check to see if a \fIport\fR is active. We make
|
||||
use of lsof to check port 3333 and the \f(CW$PROLOG\fR make sure it runs.
|
||||
.PP
|
||||
.Vb 6
|
||||
\& [$PROLOG]
|
||||
\& occurs = first
|
||||
\& trigger = { \e$x=\`lsof \-i :3333 >/dev/null 2>&1\`; \e$? >> 8 }
|
||||
\& action = <<EOT
|
||||
\& put\-your\-favorite\-command\-here arg1 arg2 ...
|
||||
\& EOT
|
||||
.Ve
|
||||
.SH "SECURITY CONSIDERATIONS"
|
||||
.IX Header "SECURITY CONSIDERATIONS"
|
||||
Any daemon such as this one which is sufficiently flexible is a
|
||||
security risk. The configuration file allows arbitrary commands to be
|
||||
run. In particular if this daemon is run as root and the configuration
|
||||
file is not protected so that it can't be modified, a bad person could
|
||||
have their programs run as root.
|
||||
.PP
|
||||
There's nothing in the ps command or ps-watcher, that requires one to
|
||||
run this daemon as root.
|
||||
.PP
|
||||
So as with all daemons, one needs to take usual security precautions
|
||||
that a careful sysadmin/maintainer of a computer would. If you can run
|
||||
any daemon as an unprivileged user (or with no privileges), do it! If
|
||||
not, set the permissions on the configuration file and the directory
|
||||
it lives in.
|
||||
.PP
|
||||
This program can also run chrooted and there is a \f(CW\*(C`\-\-path\*(C'\fR option
|
||||
that is available which can be used to set the executable search path.
|
||||
All commands used by ps-watcher are fully qualified, and I generally
|
||||
give a full execution path in my configuration file, so consider using
|
||||
the option \f(CW\*(C`\-\-path=\*(Aq\*(Aq\*(C'\fR.
|
||||
.PP
|
||||
Commands that need to be run as root you can run via \f(CW\*(C`sudo\*(C'\fR. I often
|
||||
run process accounting which tracks all commands run. Tripwire may be
|
||||
useful to track changed configuration files.
|
||||
.SH "TROUBLESHOOTING"
|
||||
.IX Header "TROUBLESHOOTING"
|
||||
To debug a configuration file the following options are useful:
|
||||
.PP
|
||||
.Vb 1
|
||||
\& ps\-watcher \-\-log \-\-nodaemon \-\-sleep \-1 \-\-debug 2 *config\-file*
|
||||
.Ve
|
||||
.PP
|
||||
For even more information and control try running the above under the
|
||||
perl debugger, e.g.
|
||||
.PP
|
||||
.Vb 1
|
||||
\& perl \-d ps\-watcher \-\-log \-\-nodaemon \-\-sleep \-1 \-\-debug 2 *config\-file*
|
||||
.Ve
|
||||
.SH "BUGS"
|
||||
.IX Header "BUGS"
|
||||
Well, some of these are not so much a bug in ps-watcher so much as a
|
||||
challenge to getting ps-watcher to do what you want it to do.
|
||||
.PP
|
||||
One common problem people run in into is understanding exactly what
|
||||
the process variables mean. The manual page \fIps\fR\|(1) should be of
|
||||
help, but I've found some of the descriptions either a bit vague or
|
||||
just plain lacking.
|
||||
.PP
|
||||
Sometimes one will see this error message when debug tracing is turned on:
|
||||
.PP
|
||||
.Vb 1
|
||||
\& ** debug ** Something wrong getting ps variables
|
||||
.Ve
|
||||
.PP
|
||||
This just means that the process died between the time ps-watcher first
|
||||
saw the existence of the process and the time that it queried
|
||||
variables.
|
||||
.SH "SEE ALSO"
|
||||
.IX Header "SEE ALSO"
|
||||
See also \fIps\fR\|(1) and \fIsyslogd\fR\|(8).
|
||||
.PP
|
||||
Another cool program doing ps-like things is \f(CW\*(C`xps\*(C'\fR. Well okay, it's
|
||||
another program I distributed. It shows the process tree dynamically
|
||||
updated using X Motif and tries to display the output \*(L"attractively\*(R"
|
||||
but fast. You can the find the homepage at
|
||||
<http://motif\-pstree.sourceforge.net> and it download via
|
||||
<http://prdownloads.sourceforge.net/motif\-pstree?sort_by=date&sort=desc>
|
||||
.SH "AUTHOR"
|
||||
.IX Header "AUTHOR"
|
||||
Rocky Bernstein (rocky@gnu.org)
|
||||
.SH "COPYRIGHT"
|
||||
.IX Header "COPYRIGHT"
|
||||
.Vb 6
|
||||
\& Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006, 2008
|
||||
\& Rocky Bernstein, email: rocky@gnu.org.
|
||||
\& This program is free software; you can redistribute it and/or modify
|
||||
\& it under the terms of the GNU General Public License as published by
|
||||
\& the Free Software Foundation; either version 2 of the License, or
|
||||
\& (at your option) any later version.
|
||||
\&
|
||||
\& This program is distributed in the hope that it will be useful,
|
||||
\& but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
\& MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
\& GNU General Public License for more details.
|
||||
\&
|
||||
\& You should have received a copy of the GNU General Public License
|
||||
\& along with this program; if not, write to the Free Software
|
||||
\& Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
.Ve
|
644
docs/ps-watcher.html
Normal file
644
docs/ps-watcher.html
Normal file
|
@ -0,0 +1,644 @@
|
|||
<?xml version="1.0" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>ps-watcher - monitors various processes based on ps-like information.</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rev="made" href="mailto:root@localhost" />
|
||||
</head>
|
||||
|
||||
<body style="background-color: white">
|
||||
|
||||
<p><a name="__index__"></a></p>
|
||||
<!-- INDEX BEGIN -->
|
||||
|
||||
<ul>
|
||||
|
||||
<li><a href="#name">NAME</a></li>
|
||||
<li><a href="#synopsis">SYNOPSIS</a></li>
|
||||
<li><a href="#description">DESCRIPTION</a></li>
|
||||
<ul>
|
||||
|
||||
<li><a href="#options">OPTIONS</a></li>
|
||||
<li><a href="#configuration_file_modification_and_signal_handling">CONFIGURATION FILE MODIFICATION AND SIGNAL HANDLING</a></li>
|
||||
</ul>
|
||||
|
||||
<li><a href="#configuration_file_format">CONFIGURATION FILE FORMAT</a></li>
|
||||
<ul>
|
||||
|
||||
<li><a href="#expanded_variables_in_trigger_action_clauses">EXPANDED VARIABLES IN TRIGGER/ACTION CLAUSES</a></li>
|
||||
<li><a href="#other_things_in_trigger_clauses">OTHER THINGS IN TRIGGER CLAUSES</a></li>
|
||||
</ul>
|
||||
|
||||
<li><a href="#example_configuration">EXAMPLE CONFIGURATION</a></li>
|
||||
<li><a href="#using__prolog_for_getting_nonps_information">Using $PROLOG for getting non-ps information</a></li>
|
||||
<li><a href="#security_considerations">SECURITY CONSIDERATIONS</a></li>
|
||||
<li><a href="#troubleshooting">TROUBLESHOOTING</a></li>
|
||||
<li><a href="#bugs">BUGS</a></li>
|
||||
<li><a href="#see_also">SEE ALSO</a></li>
|
||||
<li><a href="#author">AUTHOR</a></li>
|
||||
<li><a href="#copyright">COPYRIGHT</a></li>
|
||||
</ul>
|
||||
<!-- INDEX END -->
|
||||
|
||||
<hr />
|
||||
<p>
|
||||
</p>
|
||||
<h1><a name="name">NAME</a></h1>
|
||||
<p>ps-watcher - monitors various processes based on ps-like information.</p>
|
||||
<p>
|
||||
</p>
|
||||
<hr />
|
||||
<h1><a name="synopsis">SYNOPSIS</a></h1>
|
||||
<p><strong>ps-watcher</strong> [<em>options</em>...]
|
||||
[<code>--config</code>] <em>config-file</em></p>
|
||||
<p>
|
||||
</p>
|
||||
<hr />
|
||||
<h1><a name="description">DESCRIPTION</a></h1>
|
||||
<p>Periodically a list of processes obtained via <code>ps</code>. More precisely
|
||||
each item in the list contains the process name (just what's listed in
|
||||
the ``cmd'' field, not the full command and arguments) and its process
|
||||
id (pid). A configuration file specifies a list of Perl
|
||||
regular-expression patterns to match the processes against. For each
|
||||
match, a Perl expression specified for that pattern is evaluated. The
|
||||
evaluated expression can refer to variables which are set by ps and
|
||||
pertain to the matched process(es), for example the amount memory
|
||||
consumed by the process, or the total elapsed time. Some other
|
||||
variables are set by the program, such as the number of times the
|
||||
process is running. If the Perl expression for a matched pattern
|
||||
evaluates true, then an action can be run such as killing the program,
|
||||
restarting it, or mailing an alert, or running some arbitrary Perl
|
||||
code.</p>
|
||||
<p>Some things you might want to watch a daemon or process for:</p>
|
||||
<ul>
|
||||
<li>
|
||||
<p>check that it is running (hasn't died)</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>ensure it is not running too many times</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>isn't consuming too much memory (perhaps a memory leak), or I/O</p>
|
||||
</li>
|
||||
</ul>
|
||||
<p>Some actions you might want to take:</p>
|
||||
<ul>
|
||||
<li>
|
||||
<p>restart a process</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>kill off rampant processes</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>send an alert about any of the conditions listed above</p>
|
||||
</li>
|
||||
</ul>
|
||||
<p>Depending on options specfied, this program can be run as a daemon,
|
||||
run once (which is suitable as a <code>cron</code> job), or run not as a daemon
|
||||
but still continuously (which may be handy in testing the program or
|
||||
your configuration).</p>
|
||||
<p>
|
||||
</p>
|
||||
<h2><a name="options">OPTIONS</a></h2>
|
||||
<dl>
|
||||
<dt><strong><a name="item__2d_2dhelp">--help</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>Print a usage message on standard error and exit with a return code
|
||||
of 100.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__2d_2ddoc">--doc</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>Extact the full documentation that you are reading now, print it and
|
||||
exit with a return code of 101.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__2d_2dversion">--version</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>Print the version release on standard output and exit with a return
|
||||
code of 10.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__2d_2ddebug_number">--debug <em>number</em></a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>Give debugging output. The higher the number, the more the output. The
|
||||
default is 0 = none. 2 is the most debugging output.</p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__5b_2d_2dconfig_5d_configuration_file">[--config] <em>configuration file</em></a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>Specify configuration file. .</p>
|
||||
<p>See <a href="#configuration_file_format">CONFIGURATION FILE FORMAT</a> below for information on the format
|
||||
of the configuration file and <a href="#example_configuration">EXAMPLE CONFIGURATION</a> for a complete
|
||||
example of a configuration file.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__2d_2dlog__5blog_file_5d">--log [<em>log file</em>]</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>Send or don't send error and debugging output to a log file. If option
|
||||
is given but no logfile is specified, then use STDERR. The default is
|
||||
no error log file. See also --syslog below.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__2d_2dsyslog__7c__2d_2dnosyslog">--syslog | --nosyslog</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>Send or don't send error and debugging output to syslog. The default
|
||||
is to syslog error and debug output.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__2d_2ddaemon__7c__2d_2dnodaemon">--daemon | --nodaemon</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>Run or don't as a daemon.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__2d_2dpath_search_2dpath">--path <em>search-path</em></a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>Specify the executable search path used in running commands.</p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__2d_2dps_2dprog_program">--ps-prog <em>program</em></a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>One can specify the command that gives ps information. By default, the
|
||||
command is <em>/bin/ps</em>.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__2d_2drun__7c__2d_2dnorun">--run | --norun</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>do/don't run actions go through the motions as though we were going
|
||||
to. This may be useful in debugging.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__2d_2dsleep_interval_in_seconds">--sleep <em>interval in seconds</em></a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>It is expected that one might want to run ps-watcher over and over
|
||||
again. In such instances one can specify the amount of time between
|
||||
iterations with this option.</p>
|
||||
<p>If a negative number is specified the program is run only once.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>
|
||||
</p>
|
||||
<h2><a name="configuration_file_modification_and_signal_handling">CONFIGURATION FILE MODIFICATION AND SIGNAL HANDLING</a></h2>
|
||||
<p>Periodically ps-watcher checks to see if the configuration file
|
||||
that it was run against has changed. If so, the program rereads the
|
||||
configuration file.</p>
|
||||
<p>More precisely, the checks are done after waking up from a slumber.
|
||||
If the sleep interval is long (or if you are impatient), you can
|
||||
probably force the program to wake up using a HUP signal.</p>
|
||||
<p>At any time you can increase the level of debug output by sending a
|
||||
USR1 signal to the ps-watcher process. Similarly you can decrease the
|
||||
level of debug output by sending the process a USR2 signal.</p>
|
||||
<p>It is recommended that you terminate ps-watcher via an INT, TERM, or QUIT
|
||||
signal.</p>
|
||||
<p>
|
||||
</p>
|
||||
<hr />
|
||||
<h1><a name="configuration_file_format">CONFIGURATION FILE FORMAT</a></h1>
|
||||
<p>The format of a configuration file is a series of fully qualified
|
||||
filenames enclosed in square brackets followed by a number of
|
||||
parameter lines. Each parameter line has a parameter name followed by
|
||||
an ``equal'' sign and finally value. That is:</p>
|
||||
<pre>
|
||||
# This is a comment line
|
||||
; So is this.
|
||||
[process-pattern1]
|
||||
parameter1 = value1
|
||||
parameter2 = value2</pre>
|
||||
<pre>
|
||||
[process-pattern2]
|
||||
parameter1 = value3
|
||||
parameter2 = value4</pre>
|
||||
<p>Comments start with # or ; and take effect to the end of the line.</p>
|
||||
<p>This should be familiar to those who have worked with text-readible
|
||||
Microsoft <code>.INI</code> files.</p>
|
||||
<p>Note process patterns, (<em>process-pattern1</em> and <em>process-pattern2</em>
|
||||
above) must be unique. If there are times when you may want to
|
||||
refer to the same process, one can be creative to make these unique.
|
||||
e.g. <em>cron</em> and <em>[c]ron</em> which refer to the same process even
|
||||
though they <em>appear</em> to be different.</p>
|
||||
<p>As quoted directly from the Config::IniFiles documentation:</p>
|
||||
<p>Multiline or multivalued fields may also be defined ala UNIX
|
||||
``here document'' syntax:</p>
|
||||
<pre>
|
||||
Parameter=<<EOT
|
||||
value/line 1
|
||||
value/line 2
|
||||
EOT</pre>
|
||||
<p>You may use any string you want in place of ``EOT''. Note
|
||||
that what follows the ``<<'' and what appears at the end of
|
||||
the text <em>must</em> match exactly, including any trailing
|
||||
whitespace.</p>
|
||||
<p>There are two special ``process patterns'': $PROLOG and $EPILOG, the
|
||||
former should appear first and the latter last.</p>
|
||||
<p>You can put perl code to initialize variables here and do cleanup
|
||||
actions in these sections using ``perl-action.''</p>
|
||||
<p>A description of parameters names, their meanings and potential values
|
||||
follows.</p>
|
||||
<dl>
|
||||
<dt><strong><a name="item_trigger">trigger</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>This parameter specifies the condition on which a process action is
|
||||
fired. The condition is evaluated with Perl <code>eval()</code> and should
|
||||
therefore return something which is equivalent to ``true'' in a Perl
|
||||
expression.</p>
|
||||
<p>If no trigger is given in a section, true or 1 is assumed and
|
||||
the action is unconditionally triggered.</p>
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
# Match if httpd has not spawned enough (<4) times. NFS and databases
|
||||
# daemons typically spawn child processes. Since the program
|
||||
# matches against the command names, not commands and arguments,
|
||||
# something like: ps -ef | grep httpd won't match the below.
|
||||
# If you want to match against the command with arguments, see
|
||||
# the example with $args below.
|
||||
[httpd$]
|
||||
trigger = $count <= 4</pre>
|
||||
</dd>
|
||||
<dt><strong><a name="item_occurs">occurs</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>This parameter specifies how many times an action should be performed
|
||||
on processes matching the section trigger. Acceptable values are
|
||||
``every'', ``first'', ``first-trigger'', and ``none''.</p>
|
||||
<p>Setting the occurs value to ``none'' causes the the trigger to be
|
||||
evaluated when there are no matching processes. Although one might
|
||||
think ``$count == 0'' in the action expression would do the same thing,
|
||||
currently as coded this does not work.</p>
|
||||
<p>Setting the occurs value to ``first'' causes the process-pattern rule to
|
||||
be finished after handling the first rule that matches, whether or not the
|
||||
trigger evaluated to true.</p>
|
||||
<p>Setting the occurs value to ``first-trigger'' causes the process-pattern
|
||||
rule to be finished after handling the first rule that matches <em>and</em>
|
||||
the trigger evaluates to true.</p>
|
||||
<p>If the item parameter is not specified, ``first'' is assumed.</p>
|
||||
<p>Examples:</p>
|
||||
<pre>
|
||||
[.]
|
||||
occurs = first
|
||||
action = echo "You have $count processes running"</pre>
|
||||
<pre>
|
||||
# Note in the above since there is no trigger specified,
|
||||
# occurs = first
|
||||
# is the same thing as
|
||||
# occurs = first-trigger</pre>
|
||||
<pre>
|
||||
[.?]
|
||||
trigger = $vsz > 1000
|
||||
occurs = every
|
||||
action = echo "Large program $command matches $ps_pat: $vsz KB"</pre>
|
||||
<pre>
|
||||
# Fire if /usr/sbin/syslogd is not running.
|
||||
# Since the program matches against the command names, not commands and
|
||||
# arguments, something like:
|
||||
# ps -ef | grep /usr/sbin/syslogd
|
||||
# won't match the below.
|
||||
[(/usr/sbin/)?syslogd]
|
||||
occurs = none
|
||||
action = /etc/init.d/syslogd start</pre>
|
||||
</dd>
|
||||
<dt><strong><a name="item_action">action</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>This specifies the action, a command that gets run by the system
|
||||
shell, when the trigger condition is evaluated to be true.</p>
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
action = /etc/init.d/market_loader.init restart</pre>
|
||||
</dd>
|
||||
<dt><strong><a name="item_perl_2daction">perl-action</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>This specifies Perl statements to be eval'd. This can be especially
|
||||
useful in conjunction with $PROLOG and $EPILOG sections to make tests
|
||||
across collections of process and do things which ps-watcher
|
||||
would otherwise not be able to do.</p>
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
# A Perl variable initialization.
|
||||
# Since ps-watcher runs as a daemon it's a good idea
|
||||
# to (re)initialize variables before each run.
|
||||
[$PROLOG]
|
||||
perl-action = $root_procs=0;</pre>
|
||||
<pre>
|
||||
# Keep track of how many root processes we are running
|
||||
[.*]
|
||||
perl-action = $root_procs++ if $uid == 0
|
||||
occurs = every</pre>
|
||||
<pre>
|
||||
# Show this count.
|
||||
[$EPILOG]
|
||||
action = echo "I counted $root_procs root processes"</pre>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>
|
||||
</p>
|
||||
<h2><a name="expanded_variables_in_trigger_action_clauses">EXPANDED VARIABLES IN TRIGGER/ACTION CLAUSES</a></h2>
|
||||
<p>Any variables defined in the program can be used in pattern or
|
||||
action parameters. For example, <code>$program</code> can be used to refer to
|
||||
the name of this program ps-watcher.</p>
|
||||
<p>The following variables can be used in either the pattern or action
|
||||
fields.</p>
|
||||
<dl>
|
||||
<dt><strong><a name="item__action">$action</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>A string containing the text of the action to run.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__perl_action">$perl_action</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>A string containing the text of the perl_action to run.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__ps_pat">$ps_pat</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>The Perl regular expression specified in the beginning of the section.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__command">$command</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>The command that matched $ps_pat.</p>
|
||||
<p>The Perl regular expression specified in the beginning of the section.
|
||||
Normally processes will not have funny characters in them. Just in
|
||||
case, backticks in $command are escaped.</p>
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
# List processes other than emacs (which is a known pig) that use lots
|
||||
# of virtual memory</pre>
|
||||
<pre>
|
||||
[.*]
|
||||
trigger = $command !~ /emacs$/ && $vsz > 10
|
||||
action = echo \"Looks like you have a big \$command program: \$vsz KB\"</pre>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__count">$count</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>The number of times the pattern matched. Presumably the number of
|
||||
processes of this class running.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__trigger">$trigger</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>A string containing the text of the trigger.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>A list of variables specific to this program or fields commonly found in
|
||||
<code>ps</code> output is listed below followed by a description of the more
|
||||
common ones. See also <code>ps</code> for a more complete
|
||||
description of the meaning of the field.</p>
|
||||
<pre>
|
||||
uid euid ruid gid egid rgid alarm blocked bsdtime c caught
|
||||
cputime drs dsiz egroup eip esp etime euser f fgid
|
||||
fgroup flag flags fname fsgid fsgroup fsuid fsuser fuid fuser
|
||||
group ignored intpri lim longtname m_drs m_trs maj_flt majflt
|
||||
min_flt minflt ni nice nwchan opri pagein pcpu pending pgid pgrp
|
||||
pmem ppid pri rgroup rss rssize rsz ruser s sess session
|
||||
sgi_p sgi_rss sgid sgroup sid sig sig_block sig_catch sig_ignore
|
||||
sig_pend sigcatch sigignore sigmask stackp start start_stack start_time
|
||||
stat state stime suid suser svgid svgroup svuid svuser sz time timeout
|
||||
tmout tname tpgid trs trss tsiz tt tty tty4 tty8 uid_hack uname
|
||||
user vsize vsz wchan</pre>
|
||||
<p>Beware though, in some situations ps can return multiple lines for a
|
||||
single process and we will use just one of these in the trigger. In
|
||||
particular, Solaris's <code>ps</code> will return a line for each LWP (light-weight
|
||||
process). So on Solaris, if a trigger uses variable lwp, it may or may
|
||||
not match depending on which single line of the multiple <code>ps</code> lines is
|
||||
used.</p>
|
||||
<p></p>
|
||||
<dl>
|
||||
<dt><strong><a name="item__args">$args</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>The command along with its command arguments. It is possible that this
|
||||
is might get truncated at certain length (if ps does likewise as is
|
||||
the case on Solaris).</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__ppid">$ppid</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>The parent process id.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__stime">$stime</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>The start time of the process.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__etime">$etime</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>The end time of the process.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__pmem">$pmem</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>The process memory.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__pcpu">$pcpu</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>The percent CPU utilization.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__tty">$tty</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>The controlling tty.</p>
|
||||
<p></p>
|
||||
</dd>
|
||||
<dt><strong><a name="item__vsz">$vsz</a></strong></dt>
|
||||
|
||||
<dd>
|
||||
<p>Virtual memory size of the process</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>
|
||||
</p>
|
||||
<h2><a name="other_things_in_trigger_clauses">OTHER THINGS IN TRIGGER CLAUSES</a></h2>
|
||||
<p>To make testing against elapsed time easier, a function <code>elapse2sec()</code>
|
||||
has been written to parse and convert elapsed time strings in the
|
||||
format <code>dd-hh:mm:ss</code> and a number of seconds.</p>
|
||||
<p>Some constants for the number of seconds in a minute, hour, or day
|
||||
have also been defined. These are referred to as <code>MINS</code>, <code>HOURS</code>,
|
||||
and <code>DAYS</code> respectively and they have the expected definitions:</p>
|
||||
<pre>
|
||||
use constant MINS => 60;
|
||||
use constant HOURS => 60*60;
|
||||
use constant DAYS => HOURS * 24;</pre>
|
||||
<p>Here is an example of the use of <code>elapsed2sec()</code>:</p>
|
||||
<pre>
|
||||
# Which processes have been running for more than 3 hours?
|
||||
# Also note use of builtin-function elapsed2secs, variable $etime
|
||||
# and builtin-function HOURS
|
||||
[.]
|
||||
trigger = elapsed2secs('$etime') > 1*DAYS
|
||||
action = echo "$command has been running more than 1 day ($etime)"
|
||||
occurs = every</pre>
|
||||
<p>Please note the quotes around '$etime'.</p>
|
||||
<p>
|
||||
</p>
|
||||
<hr />
|
||||
<h1><a name="example_configuration">EXAMPLE CONFIGURATION</a></h1>
|
||||
<pre>
|
||||
# Comments start with # or ; and go to the end of the line.</pre>
|
||||
<pre>
|
||||
# The format for each entry is in Microsoft .INI form:
|
||||
# [process-pattern]
|
||||
# trigger = perl-expression
|
||||
# action = program-and-arguments-to-run</pre>
|
||||
<pre>
|
||||
[httpd$]
|
||||
trigger = $count < 4
|
||||
action = echo "$trigger fired -- You have $count httpd sessions."</pre>
|
||||
<pre>
|
||||
[.]
|
||||
trigger = $vsz > 10
|
||||
action = echo "Looks like you have a big $command program: $vsz KB"</pre>
|
||||
<pre>
|
||||
# Unfortunately we have use a different pattern below. (Here we use
|
||||
# ".?" instead of ".".) In effect the the two patterns mean
|
||||
# test every process.
|
||||
[.?]
|
||||
trigger = elapsed2secs('$etime') > 2*MINS && $pcpu > 40
|
||||
occurs = every
|
||||
action = <<EOT
|
||||
echo "$command used $pcpu% CPU for the last $etime seconds" | /bin/mail root
|
||||
kill -TERM $pid
|
||||
EOT</pre>
|
||||
<pre>
|
||||
# Scripts don't show as the script name as the command name on some
|
||||
# operating systems. Rather the name of the interpreter is listed
|
||||
# (e.g. bash or perl) Here's how you can match against a script.
|
||||
# BSD/OS is an exception: it does give the script name rather than
|
||||
# the interpreter name.
|
||||
[/usr/bin/perl]
|
||||
trigger = \$args !~ /ps-watcher/
|
||||
occurs = every
|
||||
action = echo "***found perl program ${pid}:\n $args"</pre>
|
||||
<p>
|
||||
</p>
|
||||
<hr />
|
||||
<h1><a name="using__prolog_for_getting_nonps_information">Using $PROLOG for getting non-ps information</a></h1>
|
||||
<p>Here is an example to show how to use ps-watcher to do something not
|
||||
really possible from ps: check to see if a <em>port</em> is active. We make
|
||||
use of lsof to check port 3333 and the $PROLOG make sure it runs.</p>
|
||||
<pre>
|
||||
[$PROLOG]
|
||||
occurs = first
|
||||
trigger = { \$x=`lsof -i :3333 >/dev/null 2>&1`; \$? >> 8 }
|
||||
action = <<EOT
|
||||
put-your-favorite-command-here arg1 arg2 ...
|
||||
EOT</pre>
|
||||
<p>
|
||||
</p>
|
||||
<hr />
|
||||
<h1><a name="security_considerations">SECURITY CONSIDERATIONS</a></h1>
|
||||
<p>Any daemon such as this one which is sufficiently flexible is a
|
||||
security risk. The configuration file allows arbitrary commands to be
|
||||
run. In particular if this daemon is run as root and the configuration
|
||||
file is not protected so that it can't be modified, a bad person could
|
||||
have their programs run as root.</p>
|
||||
<p>There's nothing in the ps command or ps-watcher, that requires one to
|
||||
run this daemon as root.</p>
|
||||
<p>So as with all daemons, one needs to take usual security precautions
|
||||
that a careful sysadmin/maintainer of a computer would. If you can run
|
||||
any daemon as an unprivileged user (or with no privileges), do it! If
|
||||
not, set the permissions on the configuration file and the directory
|
||||
it lives in.</p>
|
||||
<p>This program can also run chrooted and there is a <code>--path</code> option
|
||||
that is available which can be used to set the executable search path.
|
||||
All commands used by ps-watcher are fully qualified, and I generally
|
||||
give a full execution path in my configuration file, so consider using
|
||||
the option <code>--path=''</code>.</p>
|
||||
<p>Commands that need to be run as root you can run via <code>sudo</code>. I often
|
||||
run process accounting which tracks all commands run. Tripwire may be
|
||||
useful to track changed configuration files.</p>
|
||||
<p>
|
||||
</p>
|
||||
<hr />
|
||||
<h1><a name="troubleshooting">TROUBLESHOOTING</a></h1>
|
||||
<p>To debug a configuration file the following options are useful:</p>
|
||||
<pre>
|
||||
ps-watcher --log --nodaemon --sleep -1 --debug 2 *config-file*</pre>
|
||||
<p>For even more information and control try running the above under the
|
||||
perl debugger, e.g.</p>
|
||||
<pre>
|
||||
perl -d ps-watcher --log --nodaemon --sleep -1 --debug 2 *config-file*</pre>
|
||||
<p>
|
||||
</p>
|
||||
<hr />
|
||||
<h1><a name="bugs">BUGS</a></h1>
|
||||
<p>Well, some of these are not so much a bug in ps-watcher so much as a
|
||||
challenge to getting ps-watcher to do what you want it to do.</p>
|
||||
<p>One common problem people run in into is understanding exactly what
|
||||
the process variables mean. The manual page <em>ps(1)</em> should be of
|
||||
help, but I've found some of the descriptions either a bit vague or
|
||||
just plain lacking.</p>
|
||||
<p>Sometimes one will see this error message when debug tracing is turned on:</p>
|
||||
<pre>
|
||||
** debug ** Something wrong getting ps variables</pre>
|
||||
<p>This just means that the process died between the time ps-watcher first
|
||||
saw the existence of the process and the time that it queried
|
||||
variables.</p>
|
||||
<p>
|
||||
</p>
|
||||
<hr />
|
||||
<h1><a name="see_also">SEE ALSO</a></h1>
|
||||
<p>See also <em>ps(1)</em> and <em>syslogd(8)</em>.</p>
|
||||
<p>Another cool program doing ps-like things is <code>xps</code>. Well okay, it's
|
||||
another program I distributed. It shows the process tree dynamically
|
||||
updated using X Motif and tries to display the output ``attractively''
|
||||
but fast. You can the find the homepage at
|
||||
<a href="http://motif-pstree.sourceforge.net">http://motif-pstree.sourceforge.net</a> and it download via
|
||||
<a href="http://prdownloads.sourceforge.net/motif-pstree?sort_by=date&sort=desc">http://prdownloads.sourceforge.net/motif-pstree</a></p>
|
||||
<p>
|
||||
</p>
|
||||
<hr />
|
||||
<h1><a name="author">AUTHOR</a></h1>
|
||||
<p>Rocky Bernstein (<a href="mailto:rocky@gnu.org">rocky@gnu.org</a>)</p>
|
||||
<p>
|
||||
</p>
|
||||
<hr />
|
||||
<h1><a name="copyright">COPYRIGHT</a></h1>
|
||||
<pre>
|
||||
Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006, 2008
|
||||
Rocky Bernstein, email: rocky@gnu.org.
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.</pre>
|
||||
<pre>
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.</pre>
|
||||
<pre>
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</pre>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue