#!/usr/bin/perl # postfix log analyzer %month_num = ( 'JAN', 1, 'FEB', 2, 'MAR', 3, 'APL', 4, 'MAY', 5, 'JUN', 6, 'JUL', 7, 'AUG', 8, 'SEP', 9, 'OCT', 10, 'NOV', 11, 'DEC', 12 ); while(<>) { chop; s/\r$//; $syslog = $_; @col = split(/\s+/, $syslog, 7); unless ($col[4] =~ /^postfix/) {next} $mon = $month_num{uc($col[0])}; ($day, $time, $host, $qid) = @col[1,2,3,5]; $qid =~ s/:$//; printf("%02d/%02d %s %s %s\n", $mon, $day, $time, $host, $qid); @stack = split(/\s*,\s*/, @col[6]); while (@stack) { $word = shift(@stack); printf(": %s\n", $word); } }