"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "swatch" between
swatch-3.2.3.tar.gz and swatchdog-3.2.4.tar.gz

About: Swatchdog (Simple WATCHdog) activly monitors log files produced by UNIX’s syslog facility (former name "Swatch").

swatch  (swatch-3.2.3):swatch  (swatchdog-3.2.4)
#!/usr/bin/perl #!/usr/bin/perl
eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}' eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
if 0; # not running under some shell if 0; # not running under some shell
# #
# swatch: The Simple WATCHdog # swatchdog: The Simple WATCHdog
# Copyright (C) 1993-2008 E. Todd Atkins # Copyright (C) 1993-2008 E. Todd Atkins
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; either version 2 of the License, or
# any later version. # any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
skipping to change at line 66 skipping to change at line 66
$Restart $Restart
$VERSION $VERSION
$Now $Now
$pid $pid
$thCounter $thCounter
$tail_cmd_args $tail_cmd_args
$tail_cmd_name $tail_cmd_name
$use_cpan_file_tail $use_cpan_file_tail
/; /;
my @Swatch_ARGV = join(' ', $0, @ARGV); # Save just in case we need to restart my @Swatchdog_ARGV = join(' ', $0, @ARGV); # Save just in case we need to restar t
(my $Me = $0) =~ s%.*/%%; # Strip the path off of the program name (my $Me = $0) =~ s%.*/%%; # Strip the path off of the program name
$SIG{'CHLD'} = 'DEFAULT'; $SIG{'CHLD'} = 'DEFAULT';
my $DEF_CONFIG_FILE = "$ENV{'HOME'}/.swatchrc"; my $DEF_CONFIG_FILE = "$ENV{'HOME'}/.swatchdogrc";
my $DEF_INPUT; my $DEF_INPUT;
if ( -f '/var/log/messages' ) { if ( -f '/var/log/messages' ) {
$DEF_INPUT = '/var/log/messages'; $DEF_INPUT = '/var/log/messages';
} elsif ( -f '/var/log/syslog' ) { } elsif ( -f '/var/log/syslog' ) {
$DEF_INPUT = '/var/log/syslog'; $DEF_INPUT = '/var/log/syslog';
} }
my $Config_File = ''; my $Config_File = '';
my $Now = 0; # The current time in Unix seconds. Gets set when set_restart_time is called my $Now = 0; # The current time in Unix seconds. Gets set when set_restart_time is called
my $thCounter = 0; my $thCounter = 0;
my $tail_cmd_name = ''; # We'll try to find it in the PATH later my $tail_cmd_name = ''; # We'll try to find it in the PATH later
my $tail_cmd_args = '-n 0 -F'; my $tail_cmd_args = '-n 0 -F';
$awk_field_syntax = 0; $awk_field_syntax = 0;
my $AUTHOR = "E. Todd Atkins <Todd.Atkins\@StanfordAlumni.ORG>"; my $AUTHOR = "E. Todd Atkins <Todd.Atkins\@StanfordAlumni.ORG>";
$VERSION = "3.2.3"; $VERSION = "3.2.4";
my $BUILD_DATE = "May 7, 2008"; my $BUILD_DATE = "Aug 25, 2008";
my $swID = 0; # Main ID used for threshold functionality within my $swID = 0; # Main ID used for threshold functionality within
# watchfor blocks # watchfor blocks
my $swIDSub = 0; # Secondary ID used for threshold functionality my $swIDSub = 0; # Secondary ID used for threshold functionality
# within individule actions (not implemented yet) # within individule actions (not implemented yet)
my $commandLineString = $0 . ' ' . join(' ', @ARGV); my $commandLineString = $0 . ' ' . join(' ', @ARGV);
sub print_version { sub print_version {
print "This is $Me version $VERSION\n"; print "This is $Me version $VERSION\n";
skipping to change at line 216 skipping to change at line 216
while (<$fh>) { while (<$fh>) {
my($key, $val); my($key, $val);
chomp; chomp;
s/^\s+//; ## strip off leading blank space s/^\s+//; ## strip off leading blank space
s/\s+$//; ## strip off trailing blank space s/\s+$//; ## strip off trailing blank space
### Skip comments and blank lines ### ### Skip comments and blank lines ###
next if (/^\#/ or /^$/); next if (/^\#/ or /^$/);
s/\#.*$//; ## strip trailing comments
### combine lines that end with \ + <cr> ### ### combine lines that end with \ + <cr> ###
while (/\\$/) { while (/\\$/) {
my $line; my $line;
s/\\$//; s/\\$//;
if (defined($line = <$fh>) if (defined($line = <$fh>)
and not $line =~ /^\#/ and not $line =~ /^$/) { and not $line =~ /^\#/ and not $line =~ /^$/) {
chomp($line); chomp($line);
s/^\s+//; ## strip off leading blank space s/^\s+//; ## strip off leading blank space
s/\s+$//; ## strip off trailing blank space s/\s+$//; ## strip off trailing blank space
$_ .= $line; $_ .= $line;
skipping to change at line 239 skipping to change at line 237
} }
if (/\s*=\s*/) { if (/\s*=\s*/) {
$key = (split(/\s*[= ]\s*/))[0]; $key = (split(/\s*[= ]\s*/))[0];
($val = substr($_, length($key))) =~ s/^\s*=\s*//; ($val = substr($_, length($key))) =~ s/^\s*=\s*//;
} else { } else {
$key = (split())[0]; $key = (split())[0];
($val = substr($_, length($key))) =~ s/^\s*//; ($val = substr($_, length($key))) =~ s/^\s*//;
} }
s/\#.*$// if ($key ne 'perlcode'); ## strip trailing comments
if ($key =~ /include/i) { if ($key =~ /include/i) {
@records = read_config($val); @records = read_config($val);
} elsif ($key =~ /^(watchfor|waitfor|ignore)$/i) { } elsif ($key =~ /^(watchfor|waitfor|ignore)$/i) {
$i++; $i++;
if (defined $rec->{pattern}) { if (defined $rec->{pattern}) {
push @records, $rec; push @records, $rec;
$rec = (); $rec = ();
} }
if (not is_valid_pattern($val)) { if (not is_valid_pattern($val)) {
skipping to change at line 337 skipping to change at line 337
my ($key,$val) = split(/\s*=\s*/, $action); my ($key,$val) = split(/\s*=\s*/, $action);
push(@{$rec->{actions}}, { action => $key, value => $val }); push(@{$rec->{actions}}, { action => $key, value => $val });
} }
} }
push(@records, $rec); push(@records, $rec);
} }
return (@records); return (@records);
} }
# #
# make_start_code -- return the start of our swatch generated perl script # make_start_code -- return the start of our swatchdog generated perl script
# #
# usage: $script .= make_start_code; # usage: $script .= make_start_code;
# #
sub make_start_code { sub make_start_code {
my $code = ''; my $code = '';
my $mail_cmd = ''; my $mail_cmd = '';
my $extra_includes = ''; my $extra_includes = '';
my $extra_modules = ''; my $extra_modules = '';
if ($#extra_modules != -1) { if ($#extra_modules != -1) {
skipping to change at line 359 skipping to change at line 359
$extra_modules .= "use $m;\n"; $extra_modules .= "use $m;\n";
} }
} }
if ($#extra_include_dirs != -1) { if ($#extra_include_dirs != -1) {
$extra_includes = join(' ', @extra_include_dirs); $extra_includes = join(' ', @extra_include_dirs);
} }
$code = qq[ $code = qq[
# #
# swatch: The Simple WATCHdog # swatchdog: The Simple WATCHdog
# Copyright (C) 1993-2006 E. Todd Atkins # Copyright (C) 1993-2006 E. Todd Atkins
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; either version 2 of the License, or
# any later version. # any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
skipping to change at line 385 skipping to change at line 385
# #
use strict; use strict;
use FileHandle; use FileHandle;
use POSIX ":sys_wait_h"; use POSIX ":sys_wait_h";
## User supplied modules and their locations ## User supplied modules and their locations
use lib qw($extra_includes); use lib qw($extra_includes);
$extra_modules $extra_modules
use Swatch::Actions; use Swatchdog::Actions;
use Swatch::Throttle; use Swatchdog::Throttle;
use Swatch::Threshold; use Swatchdog::Threshold;
use vars qw/ use vars qw/
%Msg_Rec %Msg_Rec
\$Fh \$Fh
/; /;
\$SIG{'TERM'} = \$SIG{'HUP'} = 'goodbye'; \$SIG{'TERM'} = \$SIG{'HUP'} = 'goodbye';
\$SIG{'CHLD'} = 'DEFAULT'; \$SIG{'CHLD'} = 'DEFAULT';
## Constants ## Constants
(my \$Me = \$0) =~ s%.*/%%; (my \$Me = \$0) =~ s%.*/%%;
my \$BELL = "\007"; my \$BELL = "\007";
\$/ = "$opt_input_record_separator"; \$/ = "$opt_input_record_separator";
my \$swatch_flush_interval = 300; my \$swatchdog_flush_interval = 300;
my \$swatch_last_flush = time; my \$swatchdog_last_flush = time;
my \$tail_pid = -1; my \$tail_pid = -1;
use IO::Handle; use IO::Handle;
STDOUT->autoflush(1); STDOUT->autoflush(1);
sub goodbye { sub goodbye {
\$| = 0; \$| = 0;
if( \$tail_pid != -1 ) { if( \$tail_pid != -1 ) {
kill('TERM', \$tail_pid); kill('TERM', \$tail_pid);
} }
]; ];
if ($opt_read_pipe) { if ($opt_read_pipe) {
$code .= " close(SW_PIPE);\n"; $code .= " close(SW_PIPE);\n";
} elsif ($opt_examine) { } elsif ($opt_examine) {
$code .= " \$Fh->close;\n"; $code .= " \$Fh->close;\n";
} }
$code .= q| $code .= q|
&Swatch::Actions::close_pipe_if_open(); &Swatchdog::Actions::close_pipe_if_open();
exit(0); exit(0);
} }
# #
# write_pid_file(file_name) - writes a one line file that contains # write_pid_file(file_name) - writes a one line file that contains
# the current process id. # the current process id.
# #
sub write_pid_file { sub write_pid_file {
my $name = shift; my $name = shift;
skipping to change at line 451 skipping to change at line 451
} }
|; |;
if ($opt_daemon) { if ($opt_daemon) {
$code .= qq[ $code .= qq[
my \$pid = fork; my \$pid = fork;
exit if \$pid; exit if \$pid;
die "Couldn't fork: \$!" unless defined(\$pid); die "Couldn't fork: \$!" unless defined(\$pid);
# dissociate from the controlling terminal # dissociate from the controlling terminal
POSIX::setsid() or die "Can't start new session: \$!"; POSIX::setsid() or die "Can't start new session: \$!";
# set our named to 'swatch' so that rc scripts can # set our named to 'swatchdog' so that rc scripts can
# figure out who we are. # figure out who we are.
\$0="$commandLineString"; \$0="$commandLineString";
]; ];
} else { } else {
$code .= qq[print \"\\n*** ${Me} version ${VERSION} (pid:$$) started at \" . `/bin/date` . \"\\n\";]; $code .= qq[print \"\\n*** ${Me} version ${VERSION} (pid:$$) started at \" . `/bin/date` . \"\\n\";];
} }
$code .= qq[write_pid_file("$opt_pid_file"); \n] if (defined $opt_pid_file); $code .= qq[write_pid_file("$opt_pid_file"); \n] if (defined $opt_pid_file);
return $code; return $code;
skipping to change at line 558 skipping to change at line 558
} }
sub action_def_to_subroutine_call { sub action_def_to_subroutine_call {
my $key = shift; # converts to subroutine name my $key = shift; # converts to subroutine name
my $optstr = shift; # comma separated option string my $optstr = shift; # comma separated option string
my $pattern = shift; my $pattern = shift;
my $message = shift; my $message = shift;
my $actinfo = { # action subroutine info my $actinfo = { # action subroutine info
"continue" => { 'sub_name' => "continue" }, "continue" => { 'sub_name' => "continue" },
"bell" => { 'sub_name' => "&Swatch::Actions::ring_bell", 'def_ar "bell" => { 'sub_name' => "&Swatchdog::Actions::ring_bell", 'def
g' => 'RINGS' }, _arg' => 'RINGS' },
"echo" => { 'sub_name' => "&Swatch::Actions::echo", 'def_arg' => "echo" => { 'sub_name' => "&Swatchdog::Actions::echo", 'def_arg'
'MODES' }, => 'MODES' },
"exec" => { 'sub_name' => "&Swatch::Actions::exec_command", 'def "exec" => { 'sub_name' => "&Swatchdog::Actions::exec_command", '
_arg' => 'COMMAND' }, def_arg' => 'COMMAND' },
"pipe" => { 'sub_name' => "&Swatch::Actions::send_message_to_pip "pipe" => { 'sub_name' => "&Swatchdog::Actions::send_message_to_
e", 'def_arg' => 'COMMAND' }, pipe", 'def_arg' => 'COMMAND' },
"mail" => { 'sub_name' => "&Swatch::Actions::send_email", 'def_a "mail" => { 'sub_name' => "&Swatchdog::Actions::send_email", 'de
rg' => 'ADDRESSES' }, f_arg' => 'ADDRESSES' },
"quit" => { 'sub_name' => "exit" }, "quit" => { 'sub_name' => "exit" },
"throttle" => { 'sub_name' => '&Swatch::Throttle::throttle', 'de "throttle" => { 'sub_name' => '&Swatchdog::Throttle::throttle',
f_arg' => 'MIN_DELTA' }, 'def_arg' => 'MIN_DELTA' },
"write" => { 'sub_name' => "&Swatch::Actions::write_message", 'd "write" => { 'sub_name' => "&Swatchdog::Actions::write_message",
ef_arg' => 'USERS' }, 'def_arg' => 'USERS' },
}; };
my %options; my %options;
my $have_opts = 0; my $have_opts = 0;
foreach my $v (split(/,/, $optstr)) { foreach my $v (split(/,/, $optstr)) {
if ($v =~ /(\w+)\s*=\s*"?(\S+[^"]*)/) { if ($v =~ /(\w+)\s*=\s*"?(\S+[^"]*)/) {
$options{uc $1} = $2; $options{uc $1} = $2;
} else { } else {
my $opt = $v; my $opt = $v;
skipping to change at line 943 skipping to change at line 943
} }
print DS "### Watcher Script BEGIN ###\n"; print DS "### Watcher Script BEGIN ###\n";
print DS $Watcher_Script; print DS $Watcher_Script;
print DS "### Watcher Script END ###\n"; print DS "### Watcher Script END ###\n";
close(DS); close(DS);
$Done = 1; $Done = 1;
} else { ## Write the script to a file and run it ## } else { ## Write the script to a file and run it ##
## Write the script file ## ## Write the script file ##
my $script_file = defined($opt_script_dir) ? $opt_script_dir : $ENV{'HOME'}; my $script_file = defined($opt_script_dir) ? $opt_script_dir : $ENV{'HOME'};
$script_file .= "/.swatch_script.$$"; $script_file .= "/.swatchdog_script.$$";
my $swatch_fh = new FileHandle $script_file, "w"; my $swatchdog_fh = new FileHandle $script_file, "w";
if (defined $swatch_fh) { if (defined $swatchdog_fh) {
$swatch_fh->print($Watcher_Script); $swatchdog_fh->print($Watcher_Script);
$swatch_fh->close; $swatchdog_fh->close;
## Now fork and start monitoring ## ## Now fork and start monitoring ##
FORK: { FORK: {
if ($pid = fork) { if ($pid = fork) {
dprint(8, "doit(): pid = $pid"); dprint(8, "doit(): pid = $pid");
foreach my $k (sort keys %SIG) { foreach my $k (sort keys %SIG) {
dprint(8, "doit(): a: $k => $SIG{$k}") if defined $SIG{$k}; dprint(8, "doit(): a: $k => $SIG{$k}") if defined $SIG{$k};
} }
$SIG{'INT'} = $SIG{'QUIT'} = $SIG{'TERM'} = 'terminate'; $SIG{'INT'} = $SIG{'QUIT'} = $SIG{'TERM'} = 'terminate';
$SIG{'ALRM'} = $SIG{'HUP'} = 'restart'; $SIG{'ALRM'} = $SIG{'HUP'} = 'restart';
skipping to change at line 1005 skipping to change at line 1005
parse_command_line; parse_command_line;
main::doit(); main::doit();
} }
### ###
### End of main block ### End of main block
### ###
=head1 NAME =head1 NAME
swatch - simple watcher swatchdog - simple watcher
=head1 SYNOPSIS =head1 SYNOPSIS
B<swatch> B<swatchdog>
[ B<--awk-field-syntax> ] [ B<--awk-field-syntax> ]
[ B<--config-file|-c> I<file> ] [ B<--config-file|-c> I<file> ]
[ B<--daemon> ] [ B<--daemon> ]
[ B<--extra-include-dir|-I> I<path> ] [ B<--extra-include-dir|-I> I<path> ]
[ B<--extra-module|-M> I<module_name> ] [ B<--extra-module|-M> I<module_name> ]
[ B<--help|-h> ] [ B<--help|-h> ]
[ B<--input-record-separator> I<regex> ] [ B<--input-record-separator> I<regex> ]
[ B<--old-style-config|-O> ] [ B<--old-style-config|-O> ]
[ B<--pid-file> I<file> ] [ B<--pid-file> I<file> ]
[ B<--restart-time|-r> I<time> ] [ B<--restart-time|-r> I<time> ]
skipping to change at line 1033 skipping to change at line 1033
[ B<--version|-V> ] [ B<--version|-V> ]
[ B<--use-cpan-file-tail> ] [ B<--use-cpan-file-tail> ]
[ [ B<--examine|-f> I<file_to_examine> ] [ [ B<--examine|-f> I<file_to_examine> ]
| [ B<--read-pipe|-p> I<program_to_pipe_from> ] | [ B<--read-pipe|-p> I<program_to_pipe_from> ]
| [ B<--tail-file|-t> I<file_to_tail> ] ] | [ B<--tail-file|-t> I<file_to_tail> ] ]
[ B<--debug> [ I<level> ] ] [ B<--debug> [ I<level> ] ]
[ B<--dump-script> I<filename> ] [ B<--dump-script> I<filename> ]
=head1 DESCRIPTION =head1 DESCRIPTION
B<Swatch> is designed to monitor system activity. B<Swatchdog> is designed to monitor system activity.
In order for B<Swatch> to be useful, it requires a configuration file In order for B<Swatchdog> to be useful, it requires a configuration file
which contains I<pattern(s)> to look for and I<action(s)> which contains I<pattern(s)> to look for and I<action(s)>
to perform when each pattern is found. to perform when each pattern is found.
=head1 COMMAND LINE OPTIONS =head1 COMMAND LINE OPTIONS
=over 4 =over 4
=item B<--awk-field-syntax> =item B<--awk-field-syntax>
Use this option only if you want to overide regular expression backreferencing Use this option only if you want to overide regular expression backreferencing
in favor of B<awk(1)> style field referencing. Included for backward in favor of B<awk(1)> style field referencing. Included for backward
compatability. compatability.
=item B<--config-file|-c> I<filename> =item B<--config-file|-c> I<filename>
Tells B<swatch> where to find its configuration file. The default Tells B<swatchdog> where to find its configuration file. The default
is I<${HOME}/.swatchrc>. is I<${HOME}/.swatchdogrc>.
=item B<--daemon> =item B<--daemon>
This tells B<swatch> to run in the background and disassociate itself from This tells B<swatchdog> to run in the background and disassociate itself from
any terminal. any terminal.
=item B<--extra-include-dir|-I> I<path> =item B<--extra-include-dir|-I> I<path>
This tells B<swatch> where to look for custom I<action> modules. This tells B<swatchdog> where to look for custom I<action> modules.
=item B<--extra-module|-M> I<module_name> =item B<--extra-module|-M> I<module_name>
This tells B<swatch> what custom I<action> modules to load in. This tells B<swatchdog> what custom I<action> modules to load in.
=item B<--help|-h> =item B<--help|-h>
Prints usage information and exits. Prints usage information and exits.
=item B<--input-record-separator>=I<regular_expression> =item B<--input-record-separator>=I<regular_expression>
Tells B<swatch> to use I<regular_expression> to delineate Tells B<swatchdog> to use I<regular_expression> to delineate
the boundary of each input record. The default is a carriage return. the boundary of each input record. The default is a carriage return.
=item B<--old-style-config|-O> =item B<--old-style-config|-O>
This tells B<swatch> that your configuration file is written using the This tells B<swatchdog> that your configuration file is written using the
syntax that was abandoned back in the 1990's. syntax that was abandoned back in the 1990's.
=item B<--pid-file> I<file> =item B<--pid-file> I<file>
Writes the process ID to I<file>. Useful when running in daemon mode. Writes the process ID to I<file>. Useful when running in daemon mode.
=item B<--restart-time>=I<[+]hh:mm[am|pm]> or B<-r> I<[+]hh:mm[am|pm]> =item B<--restart-time>=I<[+]hh:mm[am|pm]> or B<-r> I<[+]hh:mm[am|pm]>
Restart at the specified time where I<hh> is hours and I<mm> is minutes. Restart at the specified time where I<hh> is hours and I<mm> is minutes.
If the am/pm indicator is omitted, then a 24-hour clock is assumed. If the am/pm indicator is omitted, then a 24-hour clock is assumed.
skipping to change at line 1133 skipping to change at line 1133
Examine lines of text as they are added to filename. Examine lines of text as they are added to filename.
=item B<--read-pipe>=I<command> or B<-p> I<command> =item B<--read-pipe>=I<command> or B<-p> I<command>
Examine input piped in from the I<command>. Examine input piped in from the I<command>.
=item B<--examine>=I<filename> or B<-f> I<filename> =item B<--examine>=I<filename> or B<-f> I<filename>
Use I<filename> as the file to examine. Use I<filename> as the file to examine.
B<Swatch> will do a single pass through the named file. B<Swatchdog> will do a single pass through the named file.
=back =back
The following options are purely for debugging purposes, but are The following options are purely for debugging purposes, but are
documented here for completeness: documented here for completeness:
=over 4 =over 4
=item B<--debug>[=I<level>] =item B<--debug>[=I<level>]
Spew out various levels of debugging for swatch developers. Spew out various levels of debugging for swatchdog developers.
=item B<--dump-script>[=I<filename>] =item B<--dump-script>[=I<filename>]
Instead of running the watcher script after it is generated, Instead of running the watcher script after it is generated,
it is written to I<filename> or to STDOUT. it is written to I<filename> or to STDOUT.
=back =back
If swatch is called with no options, it is the same as typing the If swatchdog is called with no options, it is the same as typing the
command line command line
swatch --config-file=~/.swatchrc --tail-file=/var/log/syslog swatchdog --config-file=~/.swatchdogrc --tail-file=/var/log/syslog
or if /var/log/messages exists or if /var/log/messages exists
swatch --config-file=~/.swatchrc --tail-file=/var/log/messages swatchdog --config-file=~/.swatchdogrc --tail-file=/var/log/messages
=head1 THE CONFIGURATION FILE =head1 THE CONFIGURATION FILE
The configuration file is used by the B<swatch(8)> The configuration file is used by the B<swatchdog(8)>
program to determine what types of expression patterns to look for program to determine what types of expression patterns to look for
and what type of action(s) should be taken when a pattern is matched. and what type of action(s) should be taken when a pattern is matched.
Each line should contain a keyword and a, sometimes optional, Each line should contain a keyword and a, sometimes optional,
value for that keyword. The keyword and value are separated by value for that keyword. The keyword and value are separated by
a space or an equal (=) sign. a space or an equal (=) sign.
watchfor regex watchfor regex
ignore regex ignore regex
skipping to change at line 1209 skipping to change at line 1209
=item B<mail [addresses=address:address:...][,subject=your_text_here]> =item B<mail [addresses=address:address:...][,subject=your_text_here]>
Send I<mail> to I<address(es)> containing the matched lines as Send I<mail> to I<address(es)> containing the matched lines as
they appear (default address is the user who is running the program). they appear (default address is the user who is running the program).
=item B<pipe command[,keep_open]> =item B<pipe command[,keep_open]>
Pipe matched lines into I<command>. Use the B<keep_open> option to Pipe matched lines into I<command>. Use the B<keep_open> option to
force the pipe to stay open until a different pipe action is run or force the pipe to stay open until a different pipe action is run or
until swatch exits. until swatchdog exits.
=item B<write [user:user:...]> =item B<write [user:user:...]>
Use B<write(1)> to send matched lines to I<user(s)>. Use B<write(1)> to send matched lines to I<user(s)>.
=item B<throttle hours:minutes:seconds,[key=message|regex|<regexE>]> =item B<throttle hours:minutes:seconds,[key=message|regex|<regexE>]>
This action has been depreciated. Use B<threshold> instead This action has been depreciated. Use B<threshold> instead
For example, For example,
skipping to change at line 1278 skipping to change at line 1278
Perform actions(s) once per time interval after "B<count>" matches occur, Perform actions(s) once per time interval after "B<count>" matches occur,
then ignore additional matches during the time interval then ignore additional matches during the time interval
specified by "B<seconds>" specified by "B<seconds>"
=back =back
=back =back
=item B<continue> =item B<continue>
Use this action to cause B<swatch> to continue to try to match other Use this action to cause B<swatchdog> to continue to try to match other
pattern/action groups after it is done with the current pattern/action pattern/action groups after it is done with the current pattern/action
block. block.
=item B<quit> =item B<quit>
Use this action to cause B<swatch> to clean up and quit immediately. Use this action to cause B<swatchdog> to clean up and quit immediately.
=back =back
=head1 SPECIAL OPTION =head1 SPECIAL OPTION
The following may be used as an option for any of the above actions except for t hrottle and threshold. The following may be used as an option for any of the above actions except for t hrottle and threshold.
=over 4 =over 4
=item B<when=>I<day_of_week:hour_of_day> =item B<when=>I<day_of_week:hour_of_day>
skipping to change at line 1314 skipping to change at line 1314
=back =back
=back =back
=head1 FOR PERL HACKS ONLY =head1 FOR PERL HACKS ONLY
=over 4 =over 4
=item B<perlcode> [I<depth>] arbitrary_Perl_code =item B<perlcode> [I<depth>] arbitrary_Perl_code
This permits you to easily insert random Perl code into your swatchrc file. This permits you to easily insert random Perl code into your swatchdogrc file.
The optional depth value tells swatch how deep into the code to put the perl The optional depth value tells swatchdog how deep into the code to put the perl
code. (0=outside the main loop, 1=inside the main loop (default), 2=just inside the code. (0=outside the main loop, 1=inside the main loop (default), 2=just inside the
conditional used by the current watchfor statement, and 3=inside the throttle conditional used by the current watchfor statement, and 3=inside the throttle
block). block).
Its intended use is to permit variable substitution. For example: Its intended use is to permit variable substitution. For example:
=over 4 =over 4
perlcode $syslog="^\w{3}\s+\d{1,2}\s+\d{2}:\d{2}:\d{2}.*"; perlcode $syslog="^\w{3}\s+\d{1,2}\s+\d{2}:\d{2}:\d{2}.*";
skipping to change at line 1360 skipping to change at line 1360
the message will not be echoed if they appear within a minute of the the message will not be echoed if they appear within a minute of the
first one. Instead the following message will be acted upon after first one. Instead the following message will be acted upon after
the time interval has expired. the time interval has expired.
=head1 SEE ALSO =head1 SEE ALSO
B<signal(3)>, B<perl(1)>, B<perlre(1)> B<signal(3)>, B<perl(1)>, B<perlre(1)>
=head1 NOTES =head1 NOTES
Upon receiving an ALRM or HUP signal swatch will re-read the Upon receiving an ALRM or HUP signal swatchdog will re-read the
configuration file and restart, except when used with the I<--daemon> configuration file and restart, except when used with the I<--daemon>
command line option where it will simply exit. command line option where it will simply exit.
Swatch will terminate gracefully Swatchdog will terminate gracefully
when it receives a QUIT, TERM, or INT signal. when it receives a QUIT, TERM, or INT signal.
=head1 AUTHOR =head1 AUTHOR
E. Todd Atkins E. Todd Atkins
Todd.Atkins@StanfordAlumni.ORG Todd.Atkins@StanfordAlumni.ORG
=head1 AVAILABILITY =head1 AVAILABILITY
Swatch is a SourceForge project whose project page is at Swatchdog is a SourceForge project whose project page is at
http://sourceforge.net/projects/swatch and homepage is at http://sourceforge.net/projects/swatchdog and homepage is at
http://swatch.sourceforge.net http://swatchdog.sourceforge.net
=cut =cut
 End of changes. 37 change blocks. 
62 lines changed or deleted 62 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS