Synclogreport.pl
From Federal Burro of Information
Jump to navigationJump to search
cat zimbra's sync.log to this and get a report.
#!/usr/bin/perl -w use strict; use Data::Dumper; # url: btpool0-61109://mail.uoguelph.ca/Microsoft-Server-ActiveSync?User=aogg&DeviceId=Appl87124GT7A4S&DeviceType=iPhone&Cmd=Ping # args: name=aogg;mid=2690;Cmd=Ping;DeviceID=Appl87124GT7A4S; my $urlref = {}; my %args; my $dump = 0; my $top = 10; # print top X values; my $totallines =0; my $activitylines = 0; while (<>){ $dump && print; $totallines++; if ( /(\d\d\d\d-\d\d-\d\d\s\d\d:\d\d:\d\d,\d\d\d)\s(.*)\s\[(.*)\]\s\[(.*)\]\s(.*)$/ ) { $activitylines++; # print ; my $date = $1; my $sev = $2; my $url = $3; my $args = $4; my $mess = $5; my @tuple; if ( $url =~ /(.*):\/\/(.*)\/(.*)\?(.*)/ ){ my $proc = $1; my $host = $2; my $script = $3; my $leftover = $4; @tuple = split ( "&" , $leftover ) ; foreach my $tuple ( @tuple ) { my ( $name , $value ) = split ( '=' , $tuple ) ; # print "Found $name $value\n"; $urlref->{$name}->{$value}++; } } @tuple = split ( ";" , $args ) ; foreach my $tuple ( @tuple ) { my ( $name , $value ) = split ( '=' , $tuple ) ; next if $urlref->{$name}; $urlref->{$name}->{$value}++; } $urlref->{'message'}->{$mess}++; } } print "Total Lines: $totallines Activity Lines: $activitylines\n"; foreach my $key ( sort keys %$urlref ) { print "Key $key\n"; my $topcount = 0; FOO:{ foreach ( sort {$urlref->{$key}->{$b} <=> $urlref->{$key}->{$a} } keys %{$urlref->{$key}} ) { # print "\t".$_." ".$urlref->{$key}->{$_}."\n"; printf "\t%10d %s\n", $urlref->{$key}->{$_}, $_; $topcount++; if ( $topcount > $top) { last FOO; } } } }