Sendmail
From Federal Burro of Information
Logchop
#!/usr/bin/perl -w use strict; my $data; my $debug = 0; while (<>) { chomp; if ( /(\w{3})\s(\d{2})\s(\d{2}:\d{2}:\d{2})\s(\w+)\s(\w+)\[\d+\]:\s\[.*\]\s(.*):\s(.*)/ ) { my $month = $1; my $date = $2; my $time = $3; my $host = $4; my $process = $5; my $msgid = $6; my $rest = $7; if ( $debug ) { print "Match $_\n"; print "\tMonth: $1\n"; print "\tDate: $date\n"; print "\tTime: $time\n"; print "\tHost: $host\n"; print "\tProcess: $process\n"; print "\tMsgid: $msgid\n"; print "\tRest: $rest\n"; } foreach my $tuple ( split ( /,\s/ , $rest ) ) { $debug && print "\tTuple : $tuple\n"; my ( $name , $value ) = split ( /=/ , $tuple ) ; #if ( $name ) { print "\tName: $name\n";} else { print "No Name\n";} #if ( $value ) { print "\tValue: $value\n";} else { print "No Value\n";} if ( $name && $value ) { $data->{"$name"}->{"$value"}++; } } } else { $debug && print "No: ".$_."\n"; } } print "#########################\n# Report \n##################\n"; foreach my $name ( keys( %$data )) { next if $name eq "msgid"; next if $name eq "stat"; next if $name eq "pri"; if ( $name eq "size" ) { print "Size:\n"; foreach my $count ( sort {$data->{$name}->{$b} <=> $data->{$name}->{$a}} keys %{$data->{$name}} ) { print "\t".$count . " " . $data->{$name}->{$count}."\n"; } } elsif ( $name eq "from" || $name eq "to" ) { print $name ."\n"; foreach my $count ( sort {$data->{$name}->{$b} <=> $data->{$name}->{$a}} keys %{$data->{$name}} ) { print "\t".$count . " " . $data->{$name}->{$count}."\n"; } } else { print "$name\n"; foreach my $count ( sort keys %{$data->{$name}} ) { print "\t".$count . " " . $data->{$name}->{$count}."\n"; } } }