Postfix Notes
From Federal Burro of Information
Graphingcounts and Delays
cat postfic log to this.
delayovertime.pl
#!/usr/bin/perl -w use strict; use Data::Dumper; use Date::Manip; use Time::Local; use List::Util qw(sum); my %month; $month{'Jan'} = 0; $month{'Feb'} = 1; $month{'Mar'} = 2; $month{'Apr'} = 3; $month{'May'} = 4; $month{'Jun'} = 5; $month{'Jul'} = 6; $month{'Aug'} = 7; $month{'Sep'} = 8; $month{'Oct'} = 9; $month{'Nov'} = 10; $month{'Dec'} = 11; my $y = "2013"; my $data; while (<>){ # print $_; chomp; my $totallines++; # if ( /(\d\d\d\d)-(\d\d)-(\d\d)\s(\d\d):(\d\d):(\d\d),(\d\d\d)(.*)/) { # Apr 4 04:37:05 sms-zimbra-mta-04 postfix/smtpd[5177]: disconnect from localhost.localdomain[127.0.0.1] if ( /(\w+)\s+(\d+)\s+(\d{2}):(\d{2}):(\d{2})\s+(.*)$/ ) { my $m = $month{$1}; my $d = $2; my $h = $3; my $min = $4; my $sec = $5; my $rest = $6; #print "Year $y Month $m Date $d hour $h minute $min second $sec\n"; my $time = timelocal($sec,$min,$h,$d,$m,$y); my $bucket = $time - $time%300; # print "Bucket is $bucket\n"; if ( $rest =~ /\sdelay=(.+),\sdelays=(.*)$/ ) { # print "Found delay $1\n"; push ( @ { $data->{$bucket}->{'arr'} } , $1 ) ; } } } # print Dumper ($data ); foreach my $bucket ( sort {$a <=> $b} keys % { $data } ) { # my $average = sum(@input) / @input; $data->{$bucket}->{'average'} = sum ( @ { $data->{$bucket}->{'arr'} } ) / @ { $data->{$bucket}->{'arr'} }; $data->{$bucket}->{'count'} = scalar ( @ { $data->{$bucket}->{'arr'} } ) ; print $bucket." ".$data->{$bucket}->{'count'}." ".$data->{$bucket}->{'average'}."\n"; }
send the result to gnuplot ( or excel )