qpsmtpd/log/watch

45 lines
1.0 KiB
Plaintext
Raw Normal View History

2012-06-27 09:27:35 +02:00
#!/usr/bin/perl
use strict;
use warnings;
$|++; # OUTPUT_AUTOFLUSH
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";
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;
}
2012-06-27 09:27:35 +02:00
2012-06-30 02:39:44 +02:00
sub get_qp_dir {
foreach my $user (qw/ qpsmtpd smtpd /) {
my ($homedir) = (getpwnam($user))[7] or next;
2012-06-27 09:27:35 +02:00
if (-d "$homedir/plugins") {
2012-06-30 02:39:44 +02:00
return "$homedir";
}
foreach my $s (qw/ smtpd qpsmtpd qpsmtpd-dev /) {
if (-d "$homedir/$s/plugins") {
2012-06-30 02:39:44 +02:00
return "$homedir/$s";
}
}
}
if (-d "./plugins") {
2012-06-30 02:39:44 +02:00
return Cwd::getcwd();
}
}
2012-06-30 02:39:44 +02:00