Debian Codegraph @

log/watch

raw
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 $|++; # OUTPUT_AUTOFLUSH
7
8 use Cwd;
9 use Data::Dumper;
10 use File::Tail;
11
12 my $dir = get_qp_dir() or die "unable to find QP home dir";
13 my $file = "$dir/log/main/current";
14 my $fh = File::Tail->new(
15 name => $file,
16 interval => 1,
17 maxinterval => 1,
18 debug => 1,
19 tail => 300
20 );
21
22 while (defined(my $line = $fh->read)) {
23 my (undef, $line) = split /\s/, $line, 2; # strip off tai timestamps
24 print $line;
25 }
26
27 sub get_qp_dir {
28 foreach my $user (qw/ qpsmtpd smtpd /) {
29 my ($homedir) = (getpwnam($user))[7] or next;
30
31 if (-d "$homedir/plugins") {
32 return "$homedir";
33 }
34 foreach my $s (qw/ smtpd qpsmtpd qpsmtpd-dev /) {
35 if (-d "$homedir/$s/plugins") {
36 return "$homedir/$s";
37 }
38 }
39 }
40 if (-d "./plugins") {
41 return Cwd::getcwd();
42 }
43 }
44