LOGPARSER #23: Get OS version from users hitting your site


This script check OS version on users hitting yours site. You’ll first need a way to extract unique users. If you use Windows Authentication you can use cs-username to get unique users.

SELECT
    DISTINCT cs-username,
    cs(user-agent)
INTO
    UserAgentsUniqueUsers.csv
FROM
    logs\iis\ex*.log
WHERE
    cs-username <> NULL
GROUP BY
    cs-username,
    cs(user-agent)

If you use Anonymous access cs-username will be a hyphen (‘-‘) but in that case you can probably use c-ip instead. From the .CSV you can then get OS version like this

SELECT
  SUM (c60) AS Vista,
  SUM (c52) AS Win2003,
  SUM (c51) AS WinXP,
  SUM (C50) AS Win2000
USING
  CASE strcnt(cs(User-Agent),'Windows+NT+6.0') WHEN 1 THEN 1 ELSE 0 END AS C60,
  CASE strcnt(cs(User-Agent),'Windows+NT+5.2') WHEN 1 THEN 1 ELSE 0 END AS C52,
  CASE strcnt(cs(User-Agent),'Windows+NT+5.1') WHEN 1 THEN 1 ELSE 0 END AS C51,
  CASE strcnt(cs(User-Agent),'Windows+NT+5.0') WHEN 1 THEN 1 ELSE 0 END AS C50
INTO
  GetOSUsed.txt
FROM 
  UserAgentsUniqueUsers.csv

If you like you can add additional OS like strcnt(cs(user-agent),’<OS to check for goes here>’)

Win98
Win95
Win+9x+4.90
Winnt4.0
OS+x
Mac
PPC
Linux

//Anders


Comments (0)

Skip to main content