inotify で Linux ファイルシステムのイベントを監視する

今日ちょっと知ったので早速^^;


inotify で Linux ファイルシステムのイベントを監視する
http://www.ibm.com/developerworks/jp/linux/library/l-inotify/

iWatch
http://iwatch.sourceforge.net/index.html

iWatchインストール


[root@L2 bozu]# wget http://sourceforge.net/projects/iwatch/files/iwatch/0.2.2/iwatch-0.2.2.
tgz/download
--2011-04-20 01:08:02-- http://sourceforge.net/projects/iwatch/files/iwatch/0.2.2/iwatch-0.2.2.tgz/download
Resolving sourceforge.net... 216.34.181.60
Connecting to sourceforge.net|216.34.181.60|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://downloads.sourceforge.net/project/iwatch/iwatch/0.2.2/iwatch-0.2.2.tgz?r=&ts=1303229330&use_mirror=jaist [following]

Resolving downloads.sourceforge.net... 216.34.181.59
Connecting to downloads.sourceforge.net|216.34.181.59|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://jaist.dl.sourceforge.net/project/iwatch/iwatch/0.2.2/iwatch-0.2.2.tgz [following]

Resolving jaist.dl.sourceforge.net... 150.65.7.130, 2001:200:141:feed::feed
Connecting to jaist.dl.sourceforge.net|150.65.7.130|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 16819 (16K) [application/x-gzip]
Saving to: `iwatch-0.2.2.tgz'

100%[==================================================>] 16,819 --.-K/s in 0.1s

2011-04-20 01:08:04 (156 KB/s) - `iwatch-0.2.2.tgz' saved [16819/16819]

[root@L2 bozu]# tar xvf ./iwatch-0.2.2.tgz
iwatch/
iwatch/iwatch.dtd
iwatch/COPYING
iwatch/README
iwatch/ChangeLog
iwatch/AUTHORS
iwatch/iwatch.xml.example
iwatch/iwatch
iwatch/iwatch.xml

設定ファイル


[root@L2 iwatch]# cat ./iwatch.xml
<?xml version="1.0" ?>
<!DOCTYPE config SYSTEM "/etc/iwatch.dtd" >

<config charset="utf-8">
<guard email="iwatch@localhost" name="IWatch"/>
<watchlist>
<title>Operating System
<contactpoint email="root@localhost" name="Administrator"/>
<path type="single" syslog="on">/bin
<path type="single" syslog="on">/sbin
<path type="single">/etc
<path type="recursive">/lib
<path type="exception">/lib/modules
</watchlist>
</config>

起動


[root@L2 iwatch]# ./iwatch
Can't locate Event.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8) at ./iwatch line 14.
BEGIN failed--compilation aborted at ./iwatch line 14.

エラーorz...


[root@L2 iwatch]# yum install perl-EventLoaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: rsync.atworks.co.jp
* base: rsync.atworks.co.jp
* epel: ftp.kddilabs.jp
* extras: rsync.atworks.co.jp
* updates: rsync.atworks.co.jp
Setting up Install Process
Resolving Dependencies

    • > Running transaction check
      • > Package perl-Event.i386 0:1.13-1.el5 set to be updated
    • > Finished Dependency Resolution

Dependencies Resolved

============================================================================================
Package Arch Version Repository Size
============================================================================================
Installing:
perl-Event i386 1.13-1.el5 epel 303 k

Transaction Summary
============================================================================================
Install 1 Package(s)
Upgrade 0 Package(s)

Total download size: 303 k
Is this ok [y/N]: y
Downloading Packages:
perl-Event-1.13-1.el5.i386.rpm | 303 kB 00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : perl-Event 1/1

Installed:
perl-Event.i386 0:1.13-1.el5

Complete!

再実行


[root@L2 iwatch]# ./iwatchCan't locate Linux/Inotify2.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8) at ./iwatch line 15.
BEGIN failed--compilation aborted at ./iwatch line 15.

だめだー。