New feature to show the top N users that look at an url or a domain. Add a new configuration directive, TopUrlUser, to control the number of users to show. Thanks to Mr-Ed for the feature resquest.

This commit is contained in:
Darold Gilles 2013-05-26 17:20:55 +02:00
parent cd53dde6c9
commit 736b6c2d97
6 changed files with 80 additions and 8 deletions

4
README
View File

@ -244,8 +244,10 @@ CONFIGURATION
TopNumber number
Used to set the number of top url and second level domain to show.
Default is top 10.
Default is top 100.
TopUrlUser Use this directive to show the top N users that look at an
URL or a domain. Set it to 0 to disable this feature. Default is top 10.
Exclude exclusion_file
Used to set client ip addresses, network addresses, auth login or
uri to exclude from report.

View File

@ -2383,6 +2383,7 @@ sub _print_top_url_stat
$url_stat{$4}{hits} = $1;
$url_stat{$4}{bytes} = $2;
$url_stat{$4}{duration} = $3;
$url_stat{$4}{users}{$user}++ if ($self->{TopUrlUser});
$total_hits += $1;
$total_bytes += $2;
$total_duration += $3;
@ -2392,6 +2393,7 @@ sub _print_top_url_stat
$url_stat{$6}{duration} = $3;
$url_stat{$6}{firsthit} = $4 if (!$url_stat{$6}{firsthit} || ($4 < $url_stat{$6}{firsthit}));
$url_stat{$6}{lasthit} = $5 if (!$url_stat{$6}{lasthit} || ($5 > $url_stat{$6}{lasthit}));
$url_stat{$6}{users}{$user}++ if ($self->{TopUrlUser});
$total_hits += $1;
$total_bytes += $2;
$total_duration += $3;
@ -2473,9 +2475,23 @@ sub _print_top_url_stat
$firsthit = '-';
}
}
print $out "<tr><td>\n";
if (exists $url_stat{$u}{users}) {
print $out qq{
<div class="tooltipLink"><span class="information"><a href="http://$u/" target="_blank" class="domainLink">$u</a></span><div class="tooltip">
<table><tr><th>User</th><th>Count</th></tr>
};
my $k = 1;
foreach my $user (sort { $url_stat{$u}{users}{$b} <=> $url_stat{$u}{users}{$a} } keys %{$url_stat{$u}{users}}) {
print $out "<tr><td>$user</td><td>$url_stat{$u}{users}{$user}</td></tr>\n";
$k++;
last if ($k > $self->{TopUrlUser});
}
print $out "</table>\n";
} else {
print $out "<a href=\"http://$u/\" target=\"_blank\" class=\"domainLink\">$u</a>\n";
}
print $out qq{
<tr>
<td><a href="http://$u/" target="_blank" class="domainLink">$u</a></td>
<td>$url_stat{$u}{hits} <span class="italicPercent">($h_percent)</span></td>
<td>$comma_bytes <span class="italicPercent">($b_percent)</span></td>
<td>$duration <span class="italicPercent">($d_percent)</span></td>
@ -2560,6 +2576,7 @@ sub _print_top_domain_stat
$domain_stat{"$1$2"}{duration} = $duration;
$domain_stat{"$1$2"}{firsthit} = $first if (!$domain_stat{"$1$2"}{firsthit} || ($first < $domain_stat{"$1$2"}{firsthit}));
$domain_stat{"$1$2"}{lasthit} = $last if (!$domain_stat{"$1$2"}{lasthit} || ($last > $domain_stat{"$1$2"}{lasthit}));
$domain_stat{"$1$2"}{users}{$user}++ if ($self->{TopUrlUser});
}
} else {
$perdomain{'other'}{hits} += $hits;
@ -2569,6 +2586,7 @@ sub _print_top_domain_stat
$domain_stat{'unknown'}{duration} = $duration;
$domain_stat{'unknown'}{firsthit} = $first if (!$domain_stat{'unknown'}{firsthit} || ($first < $domain_stat{'unknown'}{firsthit}));
$domain_stat{'unknown'}{lasthit} = $last if (!$domain_stat{'unknown'}{lasthit} || ($last > $domain_stat{'unknown'}{lasthit}));
$domain_stat{'unknown'}{users}{$user}++ if ($self->{TopUrlUser});
}
$total_hits += $hits;
$total_bytes += $bytes;
@ -2689,9 +2707,24 @@ sub _print_top_domain_stat
$lasthit = '-';
}
}
print $out "<tr><td>\n";
if (exists $domain_stat{$u}{users}) {
print $out qq{
<div class="tooltipLink"><span class="information">*.$u</span><div class="tooltip">
<table><tr><th>User</th><th>Count</th></tr>
};
my $k = 1;
foreach my $user (sort { $domain_stat{$u}{users}{$b} <=> $domain_stat{$u}{users}{$a} } keys %{$domain_stat{$u}{users}}) {
print $out "<tr><td>$user</td><td>$domain_stat{$u}{users}{$user}</td></tr>\n";
$k++;
last if ($k > $self->{TopUrlUser});
}
print $out "</table>\n";
} else {
print $out "*.$u\n";
}
print $out qq{
<tr>
<td>*.$u</td>
</td>
<td>$domain_stat{$u}{hits} <span class="italicPercent">($h_percent)</span></td>
<td>$comma_bytes <span class="italicPercent">($b_percent)</span></td>
<td>$duration <span class="italicPercent">($d_percent)</span></td>

View File

@ -263,7 +263,11 @@ special character. Default is &euro;
=item TopNumber number
Used to set the number of top url and second level domain to show.
Default is top 10.
Default is top 100.
=item TopUrlUser
Use this directive to show the top N users that look at an URL or a domain.
Set it to 0 to disable this feature. Default is top 10.
=item Exclude exclusion_file

View File

@ -124,7 +124,7 @@
.\" ========================================================================
.\"
.IX Title "SQUIDANALYZER 1"
.TH SQUIDANALYZER 1 "2013-05-25" "perl v5.14.2" "User Contributed Perl Documentation"
.TH SQUIDANALYZER 1 "2013-05-26" "perl v5.14.2" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
@ -395,9 +395,13 @@ special character. Default is &euro;
.IP "TopNumber number" 4
.IX Item "TopNumber number"
Used to set the number of top url and second level domain to show.
Default is top 10.
Default is top 100.
.IP "TopUrlUser Use this directive to show the top N users that look at an \s-1URL\s0 or a domain. Set it to 0 to disable this feature. Default is top 10." 4
.IX Item "TopUrlUser Use this directive to show the top N users that look at an URL or a domain. Set it to 0 to disable this feature. Default is top 10."
.PD 0
.IP "Exclude exclusion_file" 4
.IX Item "Exclude exclusion_file"
.PD
Used to set client ip addresses, network addresses, auth login or
uri to exclude from report.
.Sp

View File

@ -96,3 +96,7 @@ MinPie 2
# requests/seconde a value of 30 minutes (1800) or less should help.
WriteDelay 3600
# Use this directive to show the top N users that look at an URL or a domain.
# Set it to 0 to disable this feature.
TopUrlUser 10

View File

@ -121,3 +121,28 @@ ul li a:hover { color: #76add2; }
#calendar table { width: 200px; position: right; background-color: #222222; color: white; text-align: center; border: 0px; }
#calendar table a { color: #76add2; }
#calendar table a:hover { color: silver; }
div.information {
background:#F3F2ED;
border:4px double white;
padding:0 10px;
margin:30px 0 30px 0;
border-radius:10px;
-moz-border-radius:10px;
-webkit-border-radius:10px;
box-shadow:3px 3px 6px 2px #A9A9A9;
-moz-box-shadow:3px 3px 6px 2px #A9A9A9;
-webkit-box-shadow:3px 3px 6px #A9A9A9;
width: 1035px;
}
div.tooltipLink { position:relative; cursor:pointer; }
div.tooltipLink span.information { border-bottom:1px dotted gray; z-index:10; }
div.tooltipLink div.tooltip { display:none; background-color:#EBF0FC; border:1px solid #FFFFFF; -moz-border-radius:10px; padding:6px; width:250px; }
div.tooltipLink div.tooltip table { background-color:white; width:250px; }
div.tooltipLink div.tooltip table tr.row0 td { background-color: #FFFFFF; border: 1px solid #EEEEEE; }
div.tooltipLink div.tooltip table tr.row1 td { background-color: #EEEEEE; border: 1px solid #EEEEEE; }
div.tooltipLink div.tooltip th { font-size:10px; }
div.tooltipLink div.tooltip td { font-size:9px; font-weight:normal; padding:1px; }
div.tooltipLink:hover div.tooltip { display:block; z-index:20; position:absolute; top:1.5em; left:2em; }