"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/Swatch/Threshold.pm" 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").

Threshold.pm  (swatch-3.2.3):Threshold.pm  (swatchdog-3.2.4)
package Swatch::Threshold; package Swatchdog::Threshold;
require 5.000; require 5.000;
require Exporter; require Exporter;
use strict; use strict;
use Carp; use Carp;
use Date::Calc; use Date::Calc;
use Date::Manip; use Date::Manip;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
@ISA = qw(Exporter); @ISA = qw(Exporter);
@EXPORT = qw/ @EXPORT = qw/
threshold threshold
/; /;
$VERSION = '20060721'; $VERSION = '20060721';
# #
# $thresholds = ( # List of Hashes # $thresholds = ( # List of Hashes
# <swid1> => { # swatch ID generated for each "watchfor" value # <swid1> => { # swatchdog ID generated for each "watchfor" value
# <key1> => { # TRACK_BY value # <key1> => { # TRACK_BY value
# FIRST => seconds # time of first instance of this key # FIRST => seconds # time of first instance of this key
# EVENTS => <int>, # num of logs seen since last report # EVENTS => <int>, # num of logs seen since last report
# }, # },
# <key2> => { # <key2> => {
# ... # ...
# }, # },
# ... # ...
# }, # },
# <swid2> => { # <swid2> => {
skipping to change at line 143 skipping to change at line 143
} }
if ($thresholds->{$opts{SWID}}{$opts{TRACK_BY}}{EVENTS} == $opts{COUNT}) { if ($thresholds->{$opts{SWID}}{$opts{TRACK_BY}}{EVENTS} == $opts{COUNT}) {
return $takeAction; return $takeAction;
} else { } else {
return $doNothing; return $doNothing;
} }
####### TYPE is incorrectly defined ####### ####### TYPE is incorrectly defined #######
} else { } else {
die "Swatch::Threshold - unknown type, $opts{TYPE} given\n"; die "Swatchdog::Threshold - unknown type, $opts{TYPE} given\n";
} }
} }
################################################################ ################################################################
sub add_threshold { sub add_threshold {
my %opts = (@_); my %opts = (@_);
my $rec = {}; my $rec = {};
$rec->{EVENTS} = 1; $rec->{EVENTS} = 1;
$rec->{FIRST} = time(); $rec->{FIRST} = time();
$thresholds->{$opts{SWID}}{$opts{TRACK_BY}} = $rec; $thresholds->{$opts{SWID}}{$opts{TRACK_BY}} = $rec;
} }
################################################################ ################################################################
## The POD ### ## The POD ###
=head1 NAME =head1 NAME
Swatch::Threshold - Perl extension for thresholding in swatch(1) Swatchdog::Threshold - Perl extension for thresholding in swatchdog(1)
=head1 SYNOPSIS =head1 SYNOPSIS
use Swatch::Threshold; use Swatchdog::Threshold;
&Swatch::threshold( SWID => <int>, &Swatchdog::threshold( SWID => <int>,
TYPE => <limit|threshold|both>, TYPE => <limit|threshold|both>,
TRACK_BY => <key>, # like an IP addr TRACK_BY => <key>, # like an IP addr
COUNT => <int>, COUNT => <int>,
SECONDS => <int> SECONDS => <int>
); );
=head1 SWATCH SYNTAX =head1 SWATCH SYNTAX
threshold track_by=<key>, threshold track_by=<key>,
type=<limit|threshold|both>, type=<limit|threshold|both>,
count=<int>, count=<int>,
seconds=<int> seconds=<int>
=head1 DESCRIPTION =head1 DESCRIPTION
SWID is swatch's internal ID number for the watchfor block SWID is swatchdog's internal ID number for the watchfor block
TYPE can be limit, threshold, or both TYPE can be limit, threshold, or both
Limit - Alert on the 1st COUNT events during the time interval, Limit - Alert on the 1st COUNT events during the time interval,
then ignore events for the rest of the time interval. then ignore events for the rest of the time interval.
Threshold - Alert every COUNT times we see this event during the Threshold - Alert every COUNT times we see this event during the
time interval. time interval.
Both Both
skipping to change at line 208 skipping to change at line 208
event, then ignore any additional events during the time interval. event, then ignore any additional events during the time interval.
SECONDS is the time interval SECONDS is the time interval
=head1 AUTHOR =head1 AUTHOR
E. Todd Atkins, todd.atkins@stanfordalumni.org E. Todd Atkins, todd.atkins@stanfordalumni.org
=head1 SEE ALSO =head1 SEE ALSO
perl(1), swatch(1). perl(1), swatchdog(1).
=cut =cut
1; 1;
 End of changes. 8 change blocks. 
8 lines changed or deleted 8 lines changed or added

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