2012-06-27 09:27:35 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2013-04-21 06:54:43 +02:00
|
|
|
$|++; # OUTPUT_AUTOFLUSH
|
2013-04-20 22:11:52 +02:00
|
|
|
|
2012-06-30 02:39:44 +02:00
|
|
|
use Cwd;
|
2012-06-27 09:27:35 +02:00
|
|
|
use Data::Dumper;
|
|
|
|
use File::Tail;
|
|
|
|
|
2012-06-30 02:39:44 +02:00
|
|
|
my $dir = get_qp_dir() or die "unable to find QP home dir";
|
|
|
|
my $file = "$dir/log/main/current";
|
2013-04-21 06:54:43 +02:00
|
|
|
my $fh = File::Tail->new(
|
|
|
|
name => $file,
|
|
|
|
interval => 1,
|
|
|
|
maxinterval => 1,
|
|
|
|
debug => 1,
|
|
|
|
tail => 300
|
|
|
|
);
|
|
|
|
|
|
|
|
while (defined(my $line = $fh->read)) {
|
|
|
|
my (undef, $line) = split /\s/, $line, 2; # strip off tai timestamps
|
2012-06-27 09:27:35 +02:00
|
|
|
print $line;
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
|
2012-06-30 02:39:44 +02:00
|
|
|
sub get_qp_dir {
|
2013-04-21 06:54:43 +02:00
|
|
|
foreach my $user (qw/ qpsmtpd smtpd /) {
|
|
|
|
my ($homedir) = (getpwnam($user))[7] or next;
|
2012-06-27 09:27:35 +02:00
|
|
|
|
2013-04-21 06:54:43 +02:00
|
|
|
if (-d "$homedir/plugins") {
|
2012-06-30 02:39:44 +02:00
|
|
|
return "$homedir";
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
|
|
|
foreach my $s (qw/ smtpd qpsmtpd qpsmtpd-dev /) {
|
|
|
|
if (-d "$homedir/$s/plugins") {
|
2012-06-30 02:39:44 +02:00
|
|
|
return "$homedir/$s";
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (-d "./plugins") {
|
2012-06-30 02:39:44 +02:00
|
|
|
return Cwd::getcwd();
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
|
|
|
}
|
2012-06-30 02:39:44 +02:00
|
|
|
|