Today we need get hits by browser in specific URLs.
We have used the following tools, Logparser Lizard,Powershell and Excel to present a graphic report.
Logparser Lizard query
SELECT
cs(User-Agent) As UserAgent,
COUNT(*) as Hits
FROM 'C:\PATH_IIS_LOGS_server1\*.log', 'C:\PATH_IIS_LOGS_server2\*.log' , 'C:\PATH_IIS_LOGS_server3\*.log'
where cs-uri-stem like '%URL_TO_SEARCH%'
GROUP BY UserAgent
ORDER BY Hits DESC
Export Logparser Lizard results to CSV.
Clean CSV file of trash characters like ".
The user-agent string (KHTML,+like+Gecko) of Iphones can broke the parser, so replace this string to (KHTML+like+Gecko) with texteditor is a good idea. We don´t know if put "," character here is a standard in the user-agent string.
Of course you can use logparser from command line.
Powershell script
Run a script like this:
$ie6=0
$ie7=0
$ie8=0
$ie9=0
$ie10=0
$chrome=0
$firefox=0
$mac=0
$iphone=0
$ipad=0
$android=0
$total=0
Get-Content E:\Path\To\Resultant\file\resultantfileoflogparser.txt | Foreach-Object {
$linea=$_.split(",")
if ($linea[0] -match 'MSIE\+7' )
{
[int]$b = $null
[int32]::TryParse($($linea[1]) , [ref]$b )
$ie7=$ie7+$b
}
if ($linea[0] -match 'MSIE\+6' )
{
[int]$b = $null
[int32]::TryParse($($linea[1]) , [ref]$b )
$ie6=$ie6+$b
}
if ($linea[0] -match 'MSIE\+8' )
{
[int]$b = $null
[int32]::TryParse($($linea[1]) , [ref]$b )
$ie8=$ie8+$b
}
if ($linea[0] -match 'MSIE\+9' )
{
[int]$b = $null
[int32]::TryParse($($linea[1]) , [ref]$b )
$ie9=$ie9+$b
}
if ($linea[0] -match 'MSIE\+10' )
{
[int]$b = $null
[int32]::TryParse($($linea[1]) , [ref]$b )
$ie10=$ie10+$b
}
if ($linea[0] -match 'Chrome' )
{
[int]$b = $null
[int32]::TryParse($($linea[1]) , [ref]$b )
$chrome=$chrome+$b
}
if ($linea[0] -match 'Firefox' )
{
[int]$b = $null
[int32]::TryParse($($linea[1]) , [ref]$b )
$firefox=$firefox+$b
}
if ($linea[0] -match 'iPhone' )
{
[int]$b = $null
[int32]::TryParse($($linea[1]) , [ref]$b )
$iphone=$iphone+$b
}
if ($linea[0] -match 'iPad' )
{
[int]$b = $null
[int32]::TryParse($($linea[1]) , [ref]$b )
$ipad=$ipad+$b
}
if ($linea[0] -match 'Macintosh' )
{
[int]$b = $null
[int32]::TryParse($($linea[1]) , [ref]$b )
$mac=$mac+$b
}
if ($linea[0] -match 'Android' )
{
[int]$b = $null
[int32]::TryParse($($linea[1]) , [ref]$b )
$android=$android+$b
}
[int]$b = $null
[int32]::TryParse($($linea[1]) , [ref]$b )
$total=$total+$b
}
write-host "IE6"$ie6
write-host "IE7"$ie7
write-host "IE8"$ie8
write-host "IE9"$ie9
write-host "IE10"$ie10
write-host "Chrome"$chrome
write-host "Firefox"$firefox
write-host "Ipad"$ipad
write-host "Iphone"$iphone
write-host "Mac"$mac
write-host "Android"$android
You can fit this script for your needs, for example adding extra browsers or changing the identification string for more accurate results.
You can get user-agent list from this URL http://www.useragentstring.com/pages/useragentstring.php
Our script returns this data in two columns:
IE6 5
IE7 81
IE8 161
IE9 71
IE10 26
Chrome 0
Firefox 82
Ipad 0
Iphone 0
Mac 2
Android 0
Excel Result
Finally you can make a pie chart with the script output and get something like this:
No comments:
Post a Comment