View | Details | Raw Unified | Return to bug 109370
Collapse All | Expand All

(-)swatch.new/Makefile (-2 / +1 lines)
Lines 6-13 Link Here
6
#
6
#
7
7
8
PORTNAME=	swatch
8
PORTNAME=	swatch
9
PORTVERSION=	3.1.1
9
PORTVERSION=	3.2.1
10
PORTREVISION=	1
11
CATEGORIES=	security sysutils
10
CATEGORIES=	security sysutils
12
MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
11
MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
13
MASTER_SITE_SUBDIR=	swatch
12
MASTER_SITE_SUBDIR=	swatch
(-)swatch.new/distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
MD5 (swatch-3.1.1.tar.gz) = fe38cc8d073e692a7426693837c3749d
1
MD5 (swatch-3.2.1.tar.gz) = e55db93ef6250d684a56104fd03b8821
2
SHA256 (swatch-3.1.1.tar.gz) = e6874cc6d8441d0a4c065c625ab04b2d19c7aff7b83ce5f2260d2c2ccea3f903
2
SHA256 (swatch-3.2.1.tar.gz) = 9f05c0f051505d7eafd9170942129ebcec89521c68c1f0e349c43d01a89a9aeb
3
SIZE (swatch-3.1.1.tar.gz) = 29568
3
SIZE (swatch-3.2.1.tar.gz) = 31039
(-)swatch.new/files/patch-swatch-2 (+126 lines)
Line 0 Link Here
1
--- swatch.orig	2006-07-21 14:55:00.000000000 -0600
2
+++ swatch	2006-08-24 17:02:03.000000000 -0600
3
@@ -404,12 +404,16 @@
4
 \$/ = "$opt_input_record_separator";
5
 my \$swatch_flush_interval = 300;
6
 my \$swatch_last_flush = time;
7
+my \$tail_pid = -1;
8
9
 use IO::Handle;
10
 STDOUT->autoflush(1);
11
12
 sub goodbye {
13
   \$| = 0;
14
+  if( \$tail_pid != -1 ) {
15
+    kill('TERM', \$tail_pid);
16
+  }
17
 ];
18
19
   if ($opt_read_pipe) {
20
@@ -517,7 +521,8 @@
21
       }
22
        $code = qq/
23
 my \$filename = '$filename';
24
-if (not open(TAIL, \"$tail_cmd_name $tail_cmd_args \$filename|\")) {
25
+\$tail_pid = open(TAIL, \"$tail_cmd_name $tail_cmd_args \$filename|\");
26
+if (not \$tail_pid) {
27
     die "$0: cannot read run \\"$tail_cmd_name $tail_cmd_args \$filename\\": \$!\\n";
28
 }
29
 
30
@@ -543,6 +548,7 @@
31
     my $code;
32
     $code = q[
33
 }
34
+## TODO: Add close !!!
35
 ];
36
     return $code;
37
 } 
38
--- lib/Swatch/Throttle.pm.orig	2004-07-19 22:14:54.000000000 +0200
39
+++ lib/Swatch/Throttle.pm	2006-01-02 17:06:14.000000000 +0100
40
@@ -95,6 +95,7 @@
41
 	      @_
42
 	     );
43
 
44
+  my @delay = split(/:/, "0:$opts{DELAY}");
45
   my @dmyhms;
46
   my $key;
47
   my $cur_rec;
48
@@ -134,30 +135,61 @@
49
     $rec->{FIRST} = [ @dmyhms ];
50
     $rec->{LAST} = [ @dmyhms ];
51
     $rec->{HOLD_DHMS} = $opts{HOLD_DHMS} if defined $opts{HOLD_DHMS};
52
-    $rec->{COUNT} = 1;
53
+    $rec->{COUNT} = 0;
54
     $LogRecords{$key} = $rec;
55
-    return $msg;
56
-  } else {
57
-    $cur_rec = $LogRecords{$key};
58
-    $cur_rec->{COUNT}++;
59
-    if (defined $opts{THRESHOLD} and $cur_rec->{COUNT} == $opts{THRESHOLD}) {
60
-      ## threshold exceeded ##
61
-      chomp $msg;
62
-      $msg = "$msg (threshold $opts{THRESHOLD} exceeded)";
63
-      $cur_rec->{COUNT} = 0;
64
-    } elsif (defined $opts{HOLD_DHMS} 
65
-	     and past_hold_time($cur_rec->{LAST},
66
-				\@dmyhms, $opts{HOLD_DHMS})) {
67
+  }
68
+ 
69
+  ## Get current record ##
70
+  $cur_rec = $LogRecords{$key};
71
+  $cur_rec->{COUNT}++;
72
+
73
+  ## delay only ##
74
+  if( defined $opts{DELAY} and not defined $opts{THRESHOLD} ) {
75
+    if( past_hold_time($cur_rec->{LAST}, [ @dmyhms ], [ @delay ]) ) {
76
       ## hold time exceeded ##
77
       chomp $msg;
78
       $msg = "$msg (seen $cur_rec->{COUNT} times)";
79
-      $cur_rec->{COUNT} = 0;
80
+      $cur_rec->{COUNT} = 1;
81
       $cur_rec->{LAST} = [ @dmyhms ];
82
     } else {
83
       $msg = '';
84
     }
85
-    $LogRecords{$key} = $cur_rec if exists($LogRecords{$key});  ## save any new values ##
86
+  
87
+  ## threshold only ##
88
+  } elsif( defined $opts{THRESHOLD} and not defined $opts{DELAY} ) {
89
+    if( $cur_rec->{COUNT} == $opts{THRESHOLD}) {
90
+      ## threshold exceeded ##
91
+      chomp $msg;
92
+      $msg = "$msg (threshold $opts{THRESHOLD} exceeded)";
93
+      $cur_rec->{COUNT} = 0;
94
+    } else {
95
+      $msg = '';
96
+    }
97
+
98
+  ## threshold AND delay ##
99
+  } elsif( defined $opts{THRESHOLD} and defined $opts{DELAY} ) {
100
+    if( not past_hold_time($cur_rec->{LAST}, [ @dmyhms ], [ @delay ]) ) {
101
+      if( $cur_rec->{COUNT} == $opts{THRESHOLD} ) {
102
+        ## threshold exceeded during delay ##
103
+	chomp $msg;
104
+	$msg = "$msg (threshold $opts{THRESHOLD} exceeded during delay $opts{DELAY})";
105
+
106
+	## TODO: Tenir compte du parametre repeat ici ##
107
+	$cur_rec->{COUNT} = 0;
108
+	$cur_rec->{LAST} = [ @dmyhms ];
109
+      } else {
110
+        $msg = '';
111
+      }
112
+    } else {
113
+      $cur_rec->{COUNT} = 1;
114
+      $cur_rec->{LAST} = [ @dmyhms ];
115
+      $msg = '';
116
+    }
117
   }
118
+  
119
+  ## save any new values ##
120
+  $LogRecords{$key} = $cur_rec if exists($LogRecords{$key});
121
+  
122
   return $msg;
123
 }
124
 
125
126
 	  	 

Return to bug 109370