From: Dobrica Pavlinusic Date: Fri, 23 Sep 2016 17:24:34 +0000 (+0200) Subject: sort correctly by date number, ignore some lines X-Git-Url: http://git.rot13.org/?p=mx01;a=commitdiff_plain;h=refs%2Fheads%2Fklin sort correctly by date number, ignore some lines --- diff --git a/klin/from-by-time.pl b/klin/from-by-time.pl index 332362a..0342043 100755 --- a/klin/from-by-time.pl +++ b/klin/from-by-time.pl @@ -11,6 +11,7 @@ while(<>) { my ( $mon, $dd, $time, $host, $daemon, $msg ) = split(/\s+/,$_,6); next unless $msg =~ m/from=<([^>]+)>/; + next if $msg =~ m/(NOQUEUE|FILTER)/; my $from = $1; my $t = $time; @@ -25,17 +26,18 @@ while(<>) { #warn "# stat = ", dump( $stat ); foreach my $mon ( sort keys %$stat ) { - foreach my $dd ( sort keys %{$stat->{$mon}} ) { + foreach my $dd ( sort { $a <=> $b } keys %{$stat->{$mon}} ) { foreach my $t ( sort keys %{ $stat->{$mon}->{$dd} } ) { my $n = 0; my $e = $stat->{$mon}->{$dd}->{$t}; + my $fmt = "%3s %2s %5s %4d %s\n"; foreach my $email ( sort { $e->{$b} <=> $e->{$a} } keys %$e ) { if ( $n == 0 ) { - printf "%3s %2s %5s %d %s\n", $mon, $dd, $t, $e->{$email}, $email; + printf $fmt, $mon, $dd, $t, $e->{$email}, $email; } elsif ( $n == 5 ) { # XXX top last; } else { - printf "%3s %2s %5s %d %s\n", '', '', '', $e->{$email}, $email; + printf $fmt, '', '', '', $e->{$email}, $email; } $stat->{_from}->{$email} += $e->{$email}; $n++; @@ -44,6 +46,7 @@ foreach my $mon ( sort keys %$stat ) { } } #print "_from = ",dump( $stat->{_from} ); +print "# XXX count,email\n"; foreach my $email ( sort { $stat->{_from}->{$b} <=> $stat->{_from}->{$a} } keys %{ $stat->{_from} } ) { printf "%4d %s\n", $stat->{_from}->{$email}, $email; }