qpsmtpd/log/watch

37 lines
862 B
Plaintext
Raw Normal View History

2012-06-27 09:27:35 +02:00
#!/usr/bin/perl
use strict;
use warnings;
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";
2012-06-27 09:27:35 +02:00
my $fh = File::Tail->new(name=>$file, interval=>1, maxinterval=>1, debug =>1, tail =>100 );
while ( defined (my $line = $fh->read) ) {
my (undef, $line) = split /\s/, $line, 2; # strip off tai timestamps
print $line;
};
2012-06-30 02:39:44 +02:00
sub get_qp_dir {
2012-06-27 09:27:35 +02:00
foreach my $user ( qw/ qpsmtpd smtpd / ) {
my ($homedir) = (getpwnam( $user ))[7] or next;
2012-06-30 02:39:44 +02:00
if ( -d "$homedir/plugins" ) {
return "$homedir";
2012-06-27 09:27:35 +02:00
};
2012-06-30 02:39:44 +02:00
foreach my $s ( qw/ smtpd qpsmtpd qpsmtpd-dev / ) {
if ( -d "$homedir/$s/plugins" ) {
return "$homedir/$s";
};
2012-06-27 09:27:35 +02:00
};
};
2012-06-30 02:39:44 +02:00
if ( -d "./plugins" ) {
return Cwd::getcwd();
};
2012-06-27 09:27:35 +02:00
};
2012-06-30 02:39:44 +02:00