Sunday, November 01, 2009

Developer Dashboard for SharePoint Performance Monitoring

One of the new useful features SharePoint 2010 introduces is the Development Dashboard. It provides detailed diagnostic information for each page load at the bottom of the page. It is turned Off by default. The setting can be modified using SharePoint Object Model, STSADM.exe or PowerShell.

Below is the object model code snippet to change the settings using object model:

SPPerformanceMonitor SPPerfMon = SPFarm.Local.PerformanceMonitor;
SPPerfMon.DeveloperDashboardLevel = SPPerformanceMonitoringLevel.On;
//SPPerfMon.DeveloperDashboardLevel = SPPerformanceMonitoringLevel.OnDemand;
//SPPerfMon.DeveloperDashboardLevel = SPPerformanceMonitoringLevel.Off;

Setting it to On shows the page diagnostics, load time and other information at the bottom of the page.

Setting it to OnDemand makes the icon appear at the upper right hand side of the page. Clicking on the icon makes the Developer Dashboard appear and disappear on the page.

Using STSADM.exe, the scripts are:

stsadm -o setproperty -pn developer-dashboard -pv on
stsadm -o setproperty -pn developer-dashboard -pv off
stsadm -o setproperty -pn developer-dashboard -pv OnDemand

Everything that can be done in STSADM should be possible in PowerShell too. You can explore it on your own.
I am wondering if there is an option yet on the UI to manage the Developer Dashboard setting. Anyone knows?
The setting is only at the SPFarm level. It would be better if we we have an option to turn this on at the Site Collection or Site Level.

The above code does not work on the updated SP2010 vesion. Try this instead:

SPWebService cs = SPWebService.ContentService;

cs.DeveloperDashboardSettings.DisplayLevel = SPDeveloperDashboardLevel.OnDemand; //or On or Off

You need to refer to the Microsoft.SharePoint.Administration namespace.

No comments: