-
Notifications
You must be signed in to change notification settings - Fork 0
/
perl_tail_test.pl
50 lines (39 loc) · 1.05 KB
/
perl_tail_test.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/local/bin/perl
use strict;
use warnings;
use lib qw(/u07/app/prod/apm/perl_file_tail/share/perl5/);
use lib qw(/u07/app/prod/apm/perl_file_tail/lib64/perl5/);
use File::Tail;
use Linux::Inotify2;
print "Made it here\n";
my $name = "/net/xcla9571/u01/export/prod/jvm1/log/server.log";
my $file=File::Tail->new(
name => $name,
interval => 1,
maxinterval => 5,
adjustafter => 10,
resetafter => 5,
maxbuf => 50000 // Bytes
);
my $inotify = new Linux::Inotify2;
my $pauseFile = '/u07/app/prod/apm/streaming_stat_parser/state/PAUSE_TAILS.switch';
#my $paused = 1;
#print "Watching for switch file: $pauseFile\n";
#$inotify->watch ($pauseFile, IN_CREATE | IN_DELETE, sub {
# my $e = shift;
# print "New file or dir: " . $e->fullname . "\n";
# if ($e->IN_ACCESS) {
# print "$e->{w}{name} PAUSE\n";
# $paused = 1;
# }
# if ($e->IN_MODIFY) {
# print "$e->{w}{name} RESUME\n";
# $paused = 0;
# }
#});
while (defined(my $line=$file->read)) {
print ">>>LINE ::: $line";
while (-e $pauseFile) {
sleep 1;
}
}