Hello community,
here is the log from the commit of package iwatch
checked in at Fri Mar 23 01:50:52 CET 2007.
--------
--- iwatch/iwatch.changes 2007-03-08 16:19:40.000000000 +0100
+++ /mounts/work_src_done/NOARCH/iwatch/iwatch.changes 2007-03-22 22:35:34.000000000 +0100
@@ -2 +2 @@
-Thu Mar 8 16:19:09 CET 2007 - dkukawka@suse.de
+Thu Mar 22 22:33:01 CET 2007 - tpatzig@suse.de
@@ -4 +4,5 @@
-- chmod 644 iwatch.spec
+- update to version 0.2.1
+
+ * option -X added (exception with regular expression)
+ * new string formats in command option
+ * send email for all defined events
Old:
----
iwatch-0.2.0.tar.bz2
New:
----
iwatch-0.2.1.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ iwatch.spec ++++++
--- /var/tmp/diff_new_pack.vr8688/_old 2007-03-23 01:50:27.000000000 +0100
+++ /var/tmp/diff_new_pack.vr8688/_new 2007-03-23 01:50:27.000000000 +0100
@@ -1,5 +1,5 @@
#
-# spec file for package iwatch (Version 0.2.0)
+# spec file for package iwatch (Version 0.2.1)
#
# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
@@ -12,8 +12,8 @@
Name: iwatch
Summary: iWatch is a realtime filesystem monitoring program.
-Version: 0.2.0
-Release: 2
+Version: 0.2.1
+Release: 1
License: GNU General Public License (GPL)
Group: Productivity/Security
Requires: perl-Linux-Inotify2 perl-Event perl-Mail-Sendmail perl-XML-LibXML perl-XML-SimpleObject-LibXML
@@ -79,7 +79,10 @@
/usr/bin/iwatch
%changelog
-* Thu Mar 08 2007 - dkukawka@suse.de
-- chmod 644 iwatch.spec
+* Thu Mar 22 2007 - tpatzig@suse.de
+- update to version 0.2.1
+ * option -X added (exception with regular expression)
+ * new string formats in command option
+ * send email for all defined events
* Tue Mar 06 2007 - tpatzig@suse.de
- initial package build
++++++ iwatch-0.2.0.tar.bz2 -> iwatch-0.2.1.tar.bz2 ++++++
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/iwatch-0.2.0/ChangeLog new/iwatch-0.2.1/ChangeLog
--- old/iwatch-0.2.0/ChangeLog 2007-01-25 01:22:49.000000000 +0100
+++ new/iwatch-0.2.1/ChangeLog 2007-03-12 04:00:39.000000000 +0100
@@ -1,5 +1,14 @@
iWatch: Realtime filesystem monitor
+version 0.2.1 (12. March 2007)
+* Changes/New Features:
+ - Option -X was added. It is exception with regex string.
+ - New string format in command option:
+ %c Event cookie number.
+ %e Event name.
+ %F The old filename in case moved_to event.
+ - Fix the problem with email, it send now email for all defined events.
+
version 0.2.0 (25. January 2007):
* Changes/New Features:
- It validates now the xml file using iwatch.dtd file.
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/iwatch-0.2.0/iwatch new/iwatch-0.2.1/iwatch
--- old/iwatch-0.2.0/iwatch 2007-01-28 16:39:53.000000000 +0100
+++ new/iwatch-0.2.1/iwatch 2007-03-12 03:46:58.000000000 +0100
@@ -21,7 +21,7 @@
use Sys::Syslog;
my $PROGRAM = "iWatch";
-my $VERSION = "0.2.0";
+my $VERSION = "0.2.1";
my $VERBOSE = 0;
my $CONFIGFILE = "/etc/iwatch.xml";
my $PIDFILE = "/var/run/iwatch.pid";
@@ -29,7 +29,6 @@
my %WatchList;
my %Mail;
my %Events;
-my $Filename;
sub Usage;
sub wanted;
sub mywatch;
@@ -43,9 +42,16 @@
'p' => sub { "$PROGRAM" },
'v' => sub { "$VERSION" },
'f' => sub {
- $Filename =~ s/([;<>\*\|`&\$!#\(\)\[\]\{\}:'" \\])/\\$1/g;
- "$Filename";
+ $Events{'Filename'} =~ s/([;<>\*\|`&\$!#\(\)\[\]\{\}:'" \\])/\\$1/g;
+ "$Events{'Filename'}";
},
+ 'F' => sub {
+ return if($Events{'Name'} !~ /MOVED_TO/ );
+ $Events{'OldFilename'} =~ s/([;<>\*\|`&\$!#\(\)\[\]\{\}:'" \\])/\\$1/g;
+ "$Events{'OldFilename'}";
+ },
+ 'e' => sub { "$Events{'Name'}"; },
+ 'c' => sub { "$Events{'Cookie'}"; },
);
my %InotifyEvents = (
'access' => IN_ACCESS,
@@ -75,7 +81,7 @@
$InotifyEventNames{$InotifyEvents{$EventName}} = "IN_\U$EventName";
}
-my $opt = getopts("vdf:p:c:e:hm:rst:w:x:",\%options);
+my $opt = getopts("vdf:p:c:e:hm:rst:w:x:X:",\%options);
if(defined $options{h} || $opt == 0) {
Usage();
@@ -96,7 +102,7 @@
if((defined $options{d} || defined $options{f} || defined $options{p}) &&
(-e $ARGV[0] || defined $options{c} || defined $options{e} || defined $options{m}
- || defined $options{r} || defined $options{s} || defined $options{t} || defined $options{w} || defined $options{x})) {
+ || defined $options{r} || defined $options{s} || defined $options{t} || defined $options{w} || defined $options{x} | defined $options{X})) {
print STDERR "Options [d|f|p] and [c|e|m|r|s|w|x] are mutually exlusive, you can't mix it!\n";
Usage();
exit 1;
@@ -121,6 +127,9 @@
if(defined $options{x}) {
$xmlstr .= " $options{x}</path>\n";
}
+ if(defined $options{X}) {
+ $xmlstr .= " $options{X}</path>\n";
+ }
$xmlstr .= " </watchlist>\n";
$xmlstr .= "</config>\n";
#print "XMLstr: \n$xmlstr\n";
@@ -169,7 +178,8 @@
foreach my $watchlist ($xmlobj->child("config")->children("watchlist")) {
foreach my $path ($watchlist->children("path")) {
- next if($path->attribute("type") ne "exception");
+ next if($path->attribute("type") ne "exception" &&
+ $path->attribute("type") ne "regexception");
if(-d $path->value) { $_ = $path->value; s/(.+)\/$/$1/; $path->value($_);}
$WatchList{$path->attribute("type")}{$path->value}{"type"} = $path->attribute("type");
}
@@ -177,7 +187,8 @@
foreach my $watchlist ($xmlobj->child("config")->children("watchlist")) {
foreach my $path ($watchlist->children("path")) {
- next if($path->attribute("type") eq "exception");
+ next if($path->attribute("type") eq "exception" ||
+ $path->attribute("type") eq "regexception");
if(-d $path->value) { $_ = $path->value; s/(.+)\/$/$1/; $path->value($_);}
$WatchList{$path->attribute("type")}{$path->value}{"contactpoint"} =
$watchlist->child("contactpoint")->attribute("email") if(defined($watchlist->child("contactpoint")));
@@ -219,8 +230,16 @@
sub pathwatch {
our $mask;
+ my $key;
my ($mode,$path) = @_;
if(-e "$path") {
+ return if(defined $WatchList{"exception"}{$path});
+ foreach $key (keys %{$WatchList{"exception"}}) {
+ return undef if("$path" =~ /^$key/);
+ }
+ foreach $key (keys %{$WatchList{"regexception"}}) {
+ return if("$path" =~ /$key/);
+ }
if($mode eq "single") {
if($VERBOSE>1) {
print "Watch $path\n";
@@ -237,8 +256,16 @@
sub wanted {
our $mask;
+ my $key;
if(-d $File::Find::name) {
- return if(!defined(getWatchList($File::Find::name)));
+ return if(defined $WatchList{"exception"}{$File::Find::name});
+ foreach $key (keys %{$WatchList{"exception"}}) {
+ return undef if("$File::Find::name" =~ /^$key/);
+ }
+ foreach $key (keys %{$WatchList{"regexception"}}) {
+ return if("$File::Find::name" =~ /$key/);
+ }
+ #return if(!defined(getWatchList($File::Find::name)));
if($VERBOSE>1) {
print "Watch $File::Find::name\n";
syslog("info","Watch $File::Find::name");
@@ -249,41 +276,63 @@
}
sub getWatchList {
- my ($path) = @_;
- return undef if($WatchList{"exception"}{$path});
- foreach my $key (keys %{$WatchList{"exception"}}) {
+ my ($path,$filename) = @_;
+ my $rv;
+ my $key;
+ return undef if(defined $WatchList{"exception"}{$path});
+ foreach $key (keys %{$WatchList{"exception"}}) {
return undef if("$path" =~ /^$key/);
}
- return $WatchList{"single"}{$path} if(defined $WatchList{"single"}{$path});
- return $WatchList{"recursive"}{$path} if(defined $WatchList{"recursive"}{$path});
- foreach my $key (keys %{$WatchList{"recursive"}}) {
- return $WatchList{"recursive"}{$key} if($path =~ /^$key/);
+ foreach $key (keys %{$WatchList{"regexception"}}) {
+ return undef if("$filename" =~ /$key/);
+ }
+ if(defined $WatchList{"single"}{$path}) {
+ $rv = $WatchList{"single"}{$path};
}
- return undef;
+ elsif(defined $WatchList{"recursive"}{$path}) {
+ $rv = $WatchList{"recursive"}{$path};
+ }
+ else {
+ foreach $key (keys %{$WatchList{"recursive"}}) {
+ if($path =~ /^$key/) {
+ $rv = $WatchList{"recursive"}{$key};
+ last;
+ }
+ }
+ }
+ (defined $rv->{"filter"} && "$filename" !~ /$rv->{'filter'}/)?
+ return undef: return $rv;
}
sub mywatch {
my $e = shift;
my $Message;
my $localMessage;
- $Filename = $e->fullname;
+ my $mask;
+ my $Filename = $Events{'Filename'} = $e->fullname;
return if(defined $WatchList{"exception"}{$Filename});
- my $Path = getWatchList($e->{w}->{name});
- return if(!defined($Path) ||
- (defined $Path->{'filter'} && $e->{name} !~ /$Path->{'filter'}/));
+ my $Path = getWatchList($e->{w}->{name},$e->{name});
+ return if(!defined($Path));
my $now = POSIX::strftime "%e/%b/%Y %H:%M:%S", localtime;
+ $Events{'Name'} = "";
+ $mask = $e->mask;
+ if($e->IN_ISDIR) {
+ $mask ^= IN_ISDIR;
+ $Events{'Name'} = "IN_ISDIR,";
+ }
+ if($e->IN_ONESHOT) {
+ $mask ^= IN_ISDIR;
+ $Events{'Name'} = "IN_ONESHOT,";
+ }
+ $Events{'Name'} .= $InotifyEventNames{$mask};
+ $Events{'Cookie'} = $e->{cookie};
+ $Message = "$Events{'Name'} $Filename";
+ $Mail{Subject} = "[$PROGRAM] " . hostname() . ": $Message";
if($VERBOSE>0) {
- my $mask = $e->mask;
- if($e->IN_ISDIR) { $mask = ($e->mask ^ IN_ISDIR); $Message = "IN_ISDIR";}
- if($e->IN_ONESHOT) { $mask = ($e->mask ^ IN_ONESHOT); $Message = "IN_ONESHOT";}
- $Message = (defined $Message) ? "$Message,$InotifyEventNames{$mask} $Filename" :
- "$InotifyEventNames{$mask} $Filename";
- print "[$now] $Message\n";
- syslog("info","$Message") if($Path->{'syslog'});
- $Mail{Subject} = "[$PROGRAM] " . hostname() . ": $InotifyEventNames{$mask} $Filename";
+ print "[$now] $Message\n";
+ syslog("info","$Message") if($Path->{'syslog'});
}
-
if($e->IN_CREATE && -d $Filename && $Path->{'type'} eq "recursive") {
print STDERR "[$now] * Directory $Filename is watched\n" if($VERBOSE>0);
syslog("info","* Directory $Filename is watched") if($Path->{'syslog'});
@@ -291,7 +340,7 @@
if(!$inotify->watch ($Filename, $Path->{'mask'}, \&mywatch));
}
elsif($e->IN_CLOSE_WRITE && -f $Filename) {
- $localMessage = "* $Filename is closed\n";
+ $localMessage = "* $Filename is closed\n";
$Message = "$Message\n$localMessage";
$Mail{Subject} = "[$PROGRAM] " . hostname() . ": $Filename is changed";
print STDERR "[$now] $localMessage" if($VERBOSE>0);
@@ -310,18 +359,17 @@
}
elsif($e->IN_MOVED_TO) {
my $FileMove = $Events{$e->{cookie}} . ":$Filename";
-
$localMessage = "* $Events{$e->{cookie}} is moved to $Filename\n";
$Message = "$Message\n$localMessage";
$Mail{Subject} = "[$PROGRAM] " . hostname() . ": $Events{$e->{cookie}} is moved to $Filename";
print STDERR "[$now] $localMessage" if($VERBOSE>0);
syslog("info","$localMessage") if($Path->{'syslog'});
+ $Events{'OldFilename'} = $Events{$e->{cookie}};
undef $Events{$e->{cookie}};
}
}
elsif($e->IN_DELETE_SELF && -f $Filename && defined $WatchList{$Filename}) {
-
- $localMessage = "* $Filename is replaced but watched again\n";
+ $localMessage = "* $Filename is replaced but watched again\n";
$Message = "$Message\n$localMessage";
$Mail{Subject} = "[$PROGRAM] " . hostname() . ": $Filename is replaced";
print STDERR "[$now] $localMessage" if($VERBOSE>0);
@@ -383,13 +431,17 @@
And in the command line mode:
Usage: iwatch [-c command] [-e event[,event[,..]]] [-h|--help] [-m <email address>]
- [-r] [-s ] [-t <filter string>] [-v] [--version] [-x exception] <target>
+ [-r] [-s ] [-t <filter string>] [-v] [--version] [-x exception]
+ [-X <regex string as exception>] <target>
Target is the directory or file you want to monitor.
-c command
Specify a command to be executed if an event occurs. And you can use
following special string format in the command:
+ %c Event cookie number
+ %e Event name
%f Full path of the filename that gets an event.
+ %F The old filename in case moved_to event.
%p Program name (iWatch)
%v Version number
-e event[,event[,..]]
@@ -428,5 +480,7 @@
Print the version number.
-x exception
Specify the file or directory which should not be watched.
+ -X <regex string as exception>
+ Specify a regex string as exception
ENDOFHELP
}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/iwatch-0.2.0/iwatch.dtd new/iwatch-0.2.1/iwatch.dtd
--- old/iwatch-0.2.0/iwatch.dtd 2007-01-25 00:50:01.000000000 +0100
+++ new/iwatch-0.2.1/iwatch.dtd 2007-03-03 00:20:15.000000000 +0100
@@ -13,7 +13,7 @@
<!ELEMENT path (#PCDATA)>
<!ATTLIST path
- type CDATA #REQUIRED
+ type (single|recursive|exception|regexception) "single"
alert (on|off) "off"
events CDATA #IMPLIED
exec CDATA #IMPLIED
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/iwatch-0.2.0/iwatch.xml.example new/iwatch-0.2.1/iwatch.xml.example
--- old/iwatch-0.2.0/iwatch.xml.example 2007-01-25 01:40:51.000000000 +0100
+++ new/iwatch-0.2.1/iwatch.xml.example 2007-03-12 04:05:14.000000000 +0100
@@ -37,5 +37,7 @@
<path type="single" events="access,close" alert="off" exec="(w;ps)|mail -s %f root@localhost">/tmp/dir2</path>
<path type="single" events="default,access" alert="off" exec="(w;ps)|mail -s '%f is accessed at %{%H:%M:%S}d' root@localhost">/tmp/dir3</path>
<path type="single" events="all_events" alert="off">/tmp/dir4</path>
+ <path type="recursive">/data/projects</path>
+ <path type="regexception">\.svn</path>
</watchlist>
</config>
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/iwatch-0.2.0/README new/iwatch-0.2.1/README
--- old/iwatch-0.2.0/README 2007-01-25 01:36:51.000000000 +0100
+++ new/iwatch-0.2.1/README 2007-03-11 19:06:14.000000000 +0100
@@ -46,12 +46,17 @@
In the command line mode iWatch has following options:
Usage: iwatch [-c command] [-e event[,event[,..]]] [-h|--help] [-m <email address>]
- [-r] [-r] [-s ] [-t filter] [-v] [--version] [-x exception] <target>
+ [-r] [-r] [-s ] [-t filter] [-v] [--version] [-x exception]
+ [-X <regex string as exception>] <target>
+
Target is the directory or file you want to monitor.
-c command
You can specify a command to be executed if an event occurs. And you can use
following special string format in the command:
- %f Full path of the filename that gets an event.
+ %c Event cookie number
+ %e Event name
+ %f Full path of the filename that gets an event
+ %F The old filename in case moved_to event
%p Program name (iWatch)
%v Version number
-e event[,event[,..]]
@@ -99,6 +104,8 @@
Print the version number.
-x exception
Specify the file or directory which should not be watched.
+ -X <regex string as exception>
+ Specify a regex string as exception
example of config file:
@@ -184,3 +191,8 @@
iwatch -r -c "(w;ps -ef)|mail -s '%f was changed' cahya@localhost" /bin
monitor /bin directory recursively and execute the command.
+
+iwatch -r -X '\.svn' ~/projects
+ monitor ~/projects directory recursively, but exclude any .svn directories
+ inside. This can't be done with a normal '-x' option since '-x' can
+ only exclude the defined path.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org