asp tutorials, asp.net tutorials, sample code, and Microsoft news from 15Seconds
Data Access  |   Troubleshooting  |   Security  |   Performance  |   ADSI  |   Upload  |   Email  |   Control Building  |   Component Building  |   Forms  |   XML  |   Web Services  |   ASP.NET  |   .NET Features  |   .NET 2.0  |   App Development  |   App Architecture  |   IIS  |   Wireless
 
Pioneering Active Server
 Power Search





Active News
15 Seconds Weekly Newsletter
• Complete Coverage
• Site Updates
• Upcoming Features

More Free Newsletters
Reference
News
Articles
Archive
Writers
Code Samples
Components
Tools
FAQ
Feedback
Books
Links
DL Archives
Community
Messageboard
List Servers
Mailing List
WebHosts
Consultants
Tech Jobs
15 Seconds
Home
Site Map
Press
Legal
Privacy Policy
internet.commerce














internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

HardwareCentral
Compare products, prices, and stores at Hardware Central!

Monitoring SharePoint Usage through an ASP.NET Web Application
By Gayan Peiris
Rating: 4.1 out of 5
Rate this article


  • email this article to a colleague
  • suggest an article



  • download source code
  • Introduction

    It is a common requirement to gather information around the Windows SharePoint site usage. Organizations prefer to find out the popular sites in their organizations are or what external WSS sites attract the most number of visitors. This will provide information necessary for an organization to identify the important sites in their environment and properly manage them with extra resources if necessary.

    One of the common complains around accessing theses data are the inflexibility of gathering information in a central location. The administrator will have to navigate to the selected SharePoint site administration pages to access the data. This will become a more time consuming exercise when the administrator need to collect usage data from larger number of SharePoint sites.

    In this article, I am looking at creating an ASP.NET web application that will populate a collection of SharePoint sites in a drop down list for a given SharePoint site collection. The web application will display the usage details of the selected SharePoint site from the list. This will help the SharePoint administrator to gather all SharePoint usage data from a central location with out have to navigate many different SharePoint site locations.

    Usage Analysis Data Web Report

    Figure 1 display a Usage Analysis data for a Windows SharePoint site. The users have the option of selecting a monthly or a daily report.


    Figure 1: Monthly Usage Analysis Report

    Usage Analysis Processing Reports

    First of all let's have a look at what is Usage Analysis Reports in SharePoint. Theses reports will help the organizations to determine how the web sites are used in their environment. The data is taken from IIS Logs on the front end web servers and stored in to temporary files. The data is merged in to the content database on the back end SQL Servers when the daily log processing takes place.

    The Usage Analysis is not enabled by default when the organization deploys the Windows SharePoint Services Sites. Organizations should enable the Usage Analysis logging process on the servers when they require gathering usage information. The logs files are created daily and a flag is attached to mark that it has been processed.

    These logs files are not automatically deleted, they are preserved in "local_drive (C) :\Windows\system32\LogFiles\W3SVC*" where * indicates the Internet Information Server (IIS) instance number of the virtual server as displayed in Figure2. Organizations should consider the advantages against the disk space storage before enabling the Usage Analysis service in their environment. The organization can stop logging process' any time they require to do so.


    Figure 2: Preserved log files folder structure with W3SVC* format

    By default the log files are located at "local_drive (C) :\Windows\system32\LogFiles\STS" directory. Separate folders are created under above directory for each virtual server and separate folders for each day as displayed in the Figure 3.


    Figure 3: Separate directories for each virtual server and for each day

    Organizations can configure the above Log file store path for their own preferred path and create up to 30 log files. (Please look at Setting up Usage Analysis process for more details.) If an organization decides to store the log files in their preferred location, they should grant Read, Write and Update rights permissions for STS_WPG user group for the specified folder. Without the permissions, the usage log files cannot be created or updated by IIS.

    Setting up Usage Analysis Processing

    Administrators can control the setting of Usage Analysis process using the SharePoint Central Administration page. The user must be an administrator on the local server or a member of the SharePoint Administrators group to configure the analysis processing. If the organization adds a new virtual server after the analysis service been configured, they will need to reconfigure the analysis service to collect the data on the newly added virtual server.

    • Click "Start -> All Programs -> Administrative Tools -> SharePoint Central Administration"
    • This will open the "Windows SharePoint Services Central Administration" page
    • Select the "Configure usage analysis processing" from the "Component Configuration" section as displayed in figure 4

      Figure 4: Component Configuration section on the central administration page
    • The Configure Usage Analysis Processing page will open as displayed in Figure 5

      Figure 5: Configure Usage Analysis Processing page
    • Select "Enable logging" check box in "Logging Settings" section
    • The administrator can select a preferred file locations for the log files in "Log file location" box or use the default location C:\WINDOWS\system32\logfiles\STS
    • Enter the number of log files to create in the "Number of log files to create" box. This can be between 1 and 30.
    • Select "Enable usage analysis processing" check box in "Processing Settings" section.
    • Select the time range that analysis process should run from "Run processing between these times daily". By default this is set to start at 1am daily. The administrator can allocate a time period that won't affect the demand on the site.
    • Click "OK" to finish the configuration.

    View Usage Analysis Reports

    The user must be an administrator or have the View Usage Data right for a site to view the site usage reports. The reports are available through Site Administration page.

    The usage data is collected and stored for the entire site collection on a server at a time. The users can see the total number of hits for a site collection on the Site Collection Usage Summary page and for more detailed information, Site Usage Report page for individual sites or sub sites usage information.

    View Site Usage Report

    • Navigate to the site you prefer to view the report.
    • Click Site Settings on top tool bar.
    • Click Go to Site Administration link under Administration section as displayed in Figure 6

      Figure 6: Site Settings page
    • Click View site usage data link under Management and Statistic section in Top-Level Site Administration page as displayed in Figure 7

      Figure 7: Top-Level Site Administration page
    • The Site Usage Report page will open as displayed in Figure 8

      Figure 8: Site Usage Report page

    Site usage reports are useful for identifying which content on Windows SharePoint Services sites are being heavily used or used very little. This will help organizations to understand which sites are candidates for archiving and which sites should be kept online. In addition, this report contains information regarding how much storage space WSS sites are using. This page provides a report that contains following information:

    • Pages that have been accessed on that site, including document libraries
    • Users that have access the site
    • Operating system of the user accessing the site
    • Browser type
    • Referrer URL
    • Data can be displayed by monthly or daily summary format


    Figure 9: Different reports available

    The users can select a report option and a daily or monthly option to generate a report. Figure 9 displays a monthly report of all the pages accessed and different kind of reports options available.

    Code Example

    The web page contains a text box to enter the SharePoint site collection URL. The appropriate sub site will be listed in a dropdown list when user clicks the Submit button. The user then have the option of viewing the daily or monthly usage report of a selected site.

    First of all you will need to add the Microsoft.SharePoint.dll to your web application reference list. This will give us the access to the SharePoint Object Model.

    Then instantiate the SPSite object as displayed below. The absolute URL is passed in through the txtWSSSiteUrl text box. This will populate site collection for the given URL.

    //Get the site collection
    SPSite mySiteCollection = new SPSite(txtWSSSiteUrl.Text);

    Then to access an individual site, instantiate the SPWeb object as displayed below. I am passing in the site name as a parameter.

    //Get the details of the selected WSS site
    SPWeb site = mySiteCollection.AllWebs[siteName];

    After constructing the site SPWeb object, developers can access the information of the site usage data using the public method "GetUsageData" of the SPWeb object as displayed in code example.

    GetUsageData(Microsoft.SharePoint.Administration.SPUsageReportType, Microsoft.SharePoint.Administration.SPUsagePeriodType) Method.

    The GetUsageData method of the SPWeb class returns a data table that contains information about the usage of a Web site based on the specified type of report and time interval.

    SPUsageReportType Enumeration

    The SPUsageReportType enumeration specifies the type of information returned in a usage report for a SharePoint site.

    The following table shows the members of the SPUsageReportType enumeration and a brief description

    NameDescription
    browserThe type of Web browser used to visit the SharePoint site. All usage data refers specifically to visits from referring URLs external to the site.
    osThe operating system used on the client computer. All usage data refers specifically to visits from referring URLs external to the site.
    refUrExternal URLs through which users navigated to the SharePoint site.
    urlURLs of pages that are visited or of pages for lists that are updated. Discussions about a page are counted as hits on that page.
    userUsers who visited the site.

    SPUsagePeriodType Enumeration

    The SPUsagePeriodType enumeration specifies the time interval on which a usage report for a Web site is based.

    The following table shows the members of the SPUsagePeriodType enumeration and a brief description

    NameDescription
    dayReturns usage information for each day during the past 31 days starting from the previous day
    lastMonthSummarizes usage information for the last 31 days relative to the previous day

    I am binding the data table return from GetUsageData property to a DataGrid control to display the information.

    Accessing User daily report

    //Users who visited the site
    DGUsers.DataSource = site.GetUsageData(SPUsageReportType.user, SPUsagePeriodType.day);

    Accessing User monthly report

    //Users who visited the site
    DGUsers.DataSource = site.GetUsageData(SPUsageReportType.user, SPUsagePeriodType.lastMonth);

    Accessing Browser daily report

    //The type of browsers used to visit the site
    DGBrowser.DataSource = site.GetUsageData(SPUsageReportType.browser, SPUsagePeriodType.day);

    Accessing Browser monthly report

    //The type of browsers used to visit the site
    DGBrowser.DataSource = site.GetUsageData(SPUsageReportType.browser, SPUsagePeriodType.lastMonth);

    Accessing Operating System daily report

    //The Operating System used in client computer
    DGOs.DataSource = site.GetUsageData(SPUsageReportType.os, SPUsagePeriodType.day);

    Accessing Operating System monthly report

    //The Operating System used in client computer
    DGOs.DataSource = site.GetUsageData(SPUsageReportType.os, SPUsagePeriodType.lastMonth);

    Accessing refUrl daily report

    //External URL client used to navigate to SharePoint site
    DGRefUrl.DataSource = site.GetUsageData(SPUsageReportType.refUrl, SPUsagePeriodType.day);

    Accessing refUrl monthly report

    //External URL client used to navigate to SharePoint site
    DGRefUrl.DataSource = site.GetUsageData(SPUsageReportType.refUrl, SPUsagePeriodType.lastMonth);

    Accessing url daily report

    //URL's of pages visited
    DGUrls.DataSource = site.GetUsageData(SPUsageReportType.url, SPUsagePeriodType.day);

    Accessing url monthly report

    //URL's of pages visited
    DGUrls.DataSource = site.GetUsageData(SPUsageReportType.url, SPUsagePeriodType.lastMonth);

    Deploying the Web Application to the SharePoint Portal Server

    • Create the "UsageAnalysisData" Virtual directory under the portal web site in IIS
    • Map the virtual directory to the physical file path (this should be done as apart of above step)
    • Open the SharePoint Central Administration pages by clicking "Start > Administration tools > SharePoint Central Administration"
    • Click "Windows SharePoint Services" link on the left hand side
    • Select "Configure Virtual server setting" link from "Virtual Server Configuration" group
    • Select your Portal server from the list
    • Click "Defined managed path" link under Virtual Server Management group in Virtual Server setting page
    • Type name of the virtual directory you created in first step in the Path section of Add new Path section
    • Select "Exclude path" radio button under the type section
    • Click "Ok"
    • Then navigate to http://portal_site_name/UsageAnalysisData/MonitoringPage.aspx


    Figure 10: A list of sub sites of the site collection


    Figure 11: Daily Usage Analysis Report of a Windows SharePoint Site

    Conclusion

    SharePoint Administrators should be able to use this article as a starting point and develop their SharePoint Usage Analysis data gatherer web application according to their requirements.

    About the Author

    Gayan Peiris is a Technical Architect for Unique World Pty Ltd (www.uniqueworld.net) in Canberra, Australia. He is a MCSD with MCAD, MCP, Bcom and MIT certifications. Gayan has designed and developed Microsoft Web and Windows solutions since 1999. His expertise lies in developing scalable, high-performance applications with Microsoft Enterprise Server Products in .NET technology .His core skills are ADO.NET, ASP.NET, C#, VB.NET, Web Services, XML, MS SharePoint Portals, MS Content Management Server, MS Project Server, Live Communication Server, DNA and SQL Server.
    www.gayanpeiris.com

  • Rate This Article
    Not HelpfulMost Helpful
    1 2 3 4 5
    Other Articles
    Jul 28, 2005 - N-Tier Web Applications using ASP.NET 2.0 and SQL Server 2005 - Part 2
    In the second part of his series on building N-tier web applications using ASP.NET 2.0 and SQL Server 2005, Thiru Thangarathinam covers the business logic and user interface layers. In the process, he also examines some new features in ASP.NET 2.0 that greatly simplify the development process.
    [Read This Article]  [Top]
    Jul 14, 2005 - An Innovative Technique for Creating Reusuable Page Templates in ASP.NET 1.x
    Code reusuability is one of the major goals of any good object-oriented programmer. While the ASP.NET framework has made code reusuability easier and more elegant than it was in classic ASP, one area where reusuability could be improved is at the UI level. This article outlines a technique that you can use in ASP.NET 1.x that allows every page in your web application to inherit not only the functionality of a base page, but its UI as well.
    [Read This Article]  [Top]
    May 12, 2005 - Retrieving SharePoint Site Information in an ASP.NET Web Application
    In this article, Gayan Peiris examines using the SharePoint Object Model to access SharePoint site information from an ASP.NET web application. It should be of particular interest to SharePoint administrators who can use the included code as a starting point for development of their own web-based SharePoint administration application.
    [Read This Article]  [Top]
    Dec 23, 2004 - Automated Deployment for Side By Side .NET Web Apps for Visual Studio .NET 2003
    In this article, David Every outlines a step-by-step account of how he solved the problems he encountered while implementing an auto-deployment process. He also describes how to create a stable process for automated remote .NET deployment featuring "side-by-side" capability.
    [Read This Article]  [Top]
    Sep 29, 2004 - Developing Web Parts with ICellConsumer Interface
    Most default SharePoint Server Web Parts can be connected across organizations. The third article in this series shows how to develop connectable Web Parts that consume information provided by other Web Parts.
    [Read This Article]  [Top]
    Aug 10, 2004 - Implementing and Promoting Daily Builds
    Automatic daily builds is a well known software engineering best practice. This article introduces a strategy for implementing and promoting daily builds and offers tips and tricks for preventing and fixing breaks.
    [Read This Article]  [Top]
    Jun 21, 2004 - Using Open Source .NET Tools for Sophisticated Builds
    Building an application can be more than pressing F5. With an increasing number of quality packages being released, developers for the .NET platform now have options to create a very sophisticated build process. Aaron Junod describes a sample build environment and shows how a number of tools can work together to make reliable, predictable, and value-added builds.
    [Read This Article]  [Top]
    Jun 24, 2003 - Programming for the Palm Part 1 - Creating the Palm Application
    The first part of this three part series walks through the process of creating a mobile blog application using a BASIC development environment for Palm OS devices called NS Basic. Subsequent articles will focus on synchronizing the data to the desktop using C# and creating an installer.
    [Read This Article]  [Top]
    Jun 18, 2003 - Online Database Functions Testing Tool
    This short article provides source code for a classic ASP online database functions testing application and shows how to configure and use the tool for either SQL Server or Oracle.
    [Read This Article]  [Top]
    May 22, 2003 - Rewrite.NET -- A URL Rewriting Engine for .NET
    In this article Robert Chartier shows you how to use functionality in the .NET Framework to rewrite requested URLs on the fly.
    [Read This Article]  [Top]
    Mailing List
    Want to receive email when the next article is published? Just Click Here to sign up.

    Support the Active Server Industry