#!/usr/bin/perl -w use strict; use warnings; use diagnostics; use Linux::Inotify2; $|++; my $inotify = new Linux::Inotify2 or die "Unable to create new inotify object: $!"; my $logfile = "/home/ldm/logs/pqinsert_check.log"; my @time = localtime; my $path = "/home/ldm/temp/"; my @site_array = ("ktst1", "ktst2"); my $site_cnt = 0; foreach my $site (@site_array) { my $path_site = $path . $site; $inotify->watch($path_site, IN_ALL_EVENTS, sub { my $event = shift; my $name = $event->fullname; open Wlog, ">>$logfile"; print Wlog "$name = IN_ACCESS\n" if $event->IN_ACCESS; print Wlog "$name = IN_MODIFY\n" if $event->IN_MODIFY; print Wlog "$name = IN_ATTRIB\n" if $event->IN_ATTRIB; print Wlog "$name = IN_CLOSE_WRITE\n" if $event->IN_CLOSE_WRITE; print Wlog "$name = IN_CLOSE_NOWRITE\n" if $event->IN_CLOSE_NOWRITE; print Wlog "$name = IN_OPEN\n" if $event->IN_OPEN; print Wlog "$name = IN_MOVED_FROM\n" if $event->IN_MOVED_FROM; print Wlog "$name = IN_MOVED_TO\n" if $event->IN_MOVED_TO; print Wlog "$name = IN_CREATE\n" if $event->IN_CREATE; print Wlog "$name = IN_DELETE\n" if $event->IN_DELETE; print Wlog "$name = IN_MOVE_SELF\n" if $event->IN_MOVE_SELF; print Wlog "$name = IN_DELETE_SELF\n" if $event->IN_DELETE_SELF; close Wlog; }) or die "Watch creation failed: $!"; if (!($site_cnt)) { open Wlog, ">$logfile"; printf Wlog "%4d-%02d-%02d %02d:%02d:%02d\n", $time[5]+1900, $time[4]+1, $time[3], $time[2], $time[1], $time[0]; } else { open Wlog, ">>$logfile"; } print Wlog "Watch established on: $path_site\n"; close Wlog; $site_cnt++; } 1 while $inotify->poll;