The Code
use strict;
# change the $mds_log variable to your log file
my $mds_log = "BESNAME_MDAT_01_20050607_0002.txt";
my $http_data = {};
open MDS, $mds_log;
while (<MDS>) {
chomp;
my $id = "";
my $host = "";
my $get = "";
if (/EVENT = ReceivedFromDevice/ and
/HTTPTRANSMISSION = Host:([^>]+)>/) {
$host = $1;
($id) = (/CONNECTIONID = (\d+),/);
$http_data->{$id}->{host} = $host;
} elsif (/EVENT = SentToServer/ and
/HTTPTRANSMISSION = GET (.+) HTTP\/1\.1>/) {
$get = $1;
($id) = (/CONNECTIONID = (\d+),/);
$http_data->{$id}->{get} = $get;
}
}
close MDS;
my %urls = ();
foreach my $id (keys %{ $http_data }) {
my $host = $http_data->{$id}->{host};
my $get = $http_data->{$id}->{get};
next if not $host and $get;
my $url = "http://$host" . $get;
$urls{$url}++;
}
foreach my $url (sort { $urls{$b} <=> $urls{$a} } keys %urls) {
print "$urls{$url}\t$url\n";
}
Your MDS logs appear with your other BlackBerry logs in the following directory where YYYYMMDD is the current date (assuming you've installed your BES on the C: drive):
C:\Program Files\Research In Motion\BlackBerry Enterprise Server\Logs\YYYYMMDD\
The Mobile Data Service logs will start with your BES name followed by the string MDAT.
BESNAME_MDAT_01_20050607_0002.txt
Type the code into your text editor and save it as site_extract.pl.