"Peter Samuel" <[EMAIL PROTECTED]> writes:
> On Tue, 2 May 2000, Kins Orekhov wrote:
> > ...
> > So, what we have is:
> >
> > 1999-11-24 17:43:07.542160 status: local 0/10 remote 0/20
> >
> > but matchup needs:
> >
> > 957284032.988038 status: local 0/10 remote 0/20
> > ...
> I have a patch for deamontools-0.70 that creates a new executable
> called tai64nunix. It takes TAI64 timestamps and converts them to unix
> epaoch time, suitable for qmailanalog. Russ Allebury has a similar
> patch.
Here is another variation on the theme. It is designed to run on raw
(possibly gzipped) daemontools-0.70 logs, so it is not directly
applicable for Kins.
The script should be run once a day by cron. It mails the results of
'zoverall' to the user 'admin'.
----------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
my $logdir = '/var/log/qmail-send';
chdir $logdir or die "Can't chdir to $logdir: $!\n";
open(OUT, "|matchup 5>.pending.n|zoverall|/var/qmail/bin/mailsubj 'Mail statistics'
admin") or
die("Can't pipe to matchup: $!\n");
opendir(D, '.') or die "Can't open $logdir: $!\n";
my @logs = sort grep /^(?:@|current)/, readdir(D);
closedir(D);
my $tai64n_yesterday = sprintf "\@40000000%08x00000000", $^T - 86400;
while (@logs > 1) {
last if $logs[1] gt $tai64n_yesterday;
shift @logs;
}
unshift @logs, '.pending' if -r '.pending';
foreach my $f (@logs) {
$f =~ s/(.*\.gz)$/gzip -cdq 2>\/dev\/null $1|/;
open(IN, $f) or die "Can't read $f: $!\n";
while (<IN>) {
next unless s/^(\@[0-9a-f]+)// and $1 ge $tai64n_yesterday;
printf OUT "%.6f%s", tai64n($1), $_;
}
close(IN);
}
close(OUT);
rename '.pending.n', '.pending';
# Simplistic tai64n converter. Returns float time_t value or undef.
sub tai64n {
my(@x) = map { unpack "N", pack "H8", $_ }
$_[0] =~ /^\@?([0-9a-f]{8})([0-9a-f]{8})([0-9a-f]{8})/;
return unless @x == 3 and $x[0] == 0x40000000;
$x[1]+$x[2]/1_000_000_000;
}
__END__
--
Frank Cringle, [EMAIL PROTECTED]
voice: (+49 2304) 467101; fax: 943357