Logo
HOW TO
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
 
 
Windows Server

SQL Server 2008 R2 : Performance Monitoring Tools (part 4) - Managing the Data Collector in T-SQL

5/10/2013 6:00:48 PM
Managing the Data Collector

To stop collecting performance data for a SQL Server instance, right-click on Data Collection in the Management node and click Disable Data Collection. If you want to stop a specific data collection set, expand the Data Collection node and then expand the System Data Collection Sets folder. Right-click on the data collection set you want to stop and select Stop Data Collection Set.

You can also force a collection set to gather data and upload statistics manually by right-clicking on the data collection set and selecting Collect and Upload Now.

To check on the status and history of the Data Collectors, you can right click on the Data Collection node and select View Logs. This launches the log viewer that displays the activity that has occurred for each of the data collection sets, such as which collection sets are active and the collection and upload history of each of the collection sets.

Managing the Data Collector in T-SQL

Much of the Data Collector can be managed effectively within SSMS. However, if you have to perform a number of tasks repeatedly, using the wizards and SSMS dialogs can sometimes become tedious. Fortunately, the Data Collector provides an extensive collection of stored procedures that you can use to perform any data collection task. In addition, you can use functions and views to retrieve configuration data from the msdb and management data warehouse databases, execution log data, as well as the performance data stored in the management data warehouse.

Tip

As with most tools in SSMS, when using the GUI, you can click the Script buttion to generate a script for the actions being performed. This is a great way to become more familiar with the T-SQL commands and procedures for managing the Data Collector.


For example, to enable or disable the Data Collector in a SQL Server instance, you can use the sp_syscollector_enable_collector and sp_syscollector_disable_collector stored procedures:

USE msdb;
GO
EXEC dbo.sp_syscollector_disable_collector;
GO
EXEC dbo.sp_syscollector_enable_collector;
GO

To force the running of a noncached collection set and have it upload to the MDW for collection sets configured in noncached collection mode, use the sp_syscollector_run_collection_set system procedure:

sp_syscollector_run_collection_set
          [[ @collection_set_id = ] collection_set_id]
          , [[ @name = ] 'name' ]

You can pass either the collection set ID or the collection name. When you are passing one, the other parameter can be NULL:

USE msdb;
GO
EXEC sp_syscollector_run_collection_set @name = 'Disk Usage'
go

To force a manual update of a cached mode Data Collector, you can use the sp_syscollector_upload_collection_set procedure:

USE msdb;
GO
EXEC sp_syscollector_upload_collection_set @name = 'Server Activity'
go

To stop or start a specific collector set, you can use the sp_syscollector_start_collection_set and sp_syscollector_stop_collection set stored procedures:

USE msdb;
GO
EXEC dbo.sp_syscollector_stop_collection_set @name = 'Disk Usage'
GO
EXEC dbo.sp_syscollector_start_collection_set @name = 'Disk Usage'
GO

To modify a collection set, you can use the sp_syscollector_update_collection_set procedure. The syntax is as follows:

sp_syscollector_update_collection_set
    [ [ @collection_set_id = ] collection_set_id ]
        , [ [ @name = ] 'name' ]
        , [ [ @new_name = ] 'new_name' ]
        , [ [ @target = ] 'target' ]
        , [ [ @collection_mode = ] collection_mode ]
        , [ [ @days_until_expiration = ] days_until_expiration ]
        , [ [ @proxy_id = ] proxy_id ]
        , [ [ @proxy_name = ] 'proxy_name' ]
        , [ [ @schedule_uid = ] 'schedule_uid' ]
        , [ [ @schedule_name = ] 'schedule_name' ]
        , [ [ @logging_level = ] logging_level ]
        , [ [ @description = ] 'description' ]

If the collection set is running, the only options you can modify are the schedule_uid and description. You need to stop the collection set with sp_syscollector_stop_collection_set first to change other options like the collection-mode or days_until_expiration. For example, the following code changes the number of days to retain collection set data to seven days for the Server Activity collection set:

USE msdb;
GO
EXEC dbo.sp_syscollector_stop_collection_set @name = 'Disk Usage'
GO
EXEC dbo.sp_syscollector_update_collection_set
@name = N'Server Activity',
@days_until_expiration = 7;
GO
EXEC dbo.sp_syscollector_start_collection_set @name = 'Disk Usage'
GO

To view information about the configured collection sets, you can run a query on the syscollector_collection_sets table similar to the following:

select collection_set_id as ID,
       cast (scs.name as varchar(20)) as name,
       is_running as 'running',
       case collection_mode when 0 then 'cached'
            else 'noncached' end as coll_mode,
       days_until_expiration as retntn,
       cast (s.name as varchar(30)) as schedule
 from syscollector_collection_sets scs
        inner join
      sysschedules s
        on scs.schedule_uid = s.schedule_uid
go

ID name                 running coll_mode retntn schedule
-- -------------------- ------- --------- ------ -----------------------------
2  Server Activity      1       cached    7      CollectorSchedule_Every_15min
3  Query Statistics     1       cached    14     CollectorSchedule_Every_15min
4  Utility Information  1       noncached 1      CollectorSchedule_Every_30min
1  Disk Usage           1       noncached 730    CollectorSchedule_Every_6h


					  

There are other informational views you can use to view the data collection configuration:

-- To display the location of the temporary cache and the MDW
select * From syscollector_config_store
go
parameter_name     parameter_value
------------------ -----------------------
CacheDirectory     D:\SQL2008\DCTemp
CacheWindow        1
CollectorEnabled   1
MDWDatabase        UnleashedMDW
MDWInstance        LATITUDED830-W7\PERFDW

-- To display the data collection capture and upload
--  information from the execution log
select * From syscollector_config_store
go
select csc.name as collection_set, start_time
 From syscollector_execution_log sel
        inner join
      syscollector_collection_sets csc
        on sel.collection_set_id = csc.collection_set_id
order by csc.name, start_time
go

You can also use the stored procedures, functions, and views that are provided to create your own end-to-end data collection scenarios.

Other -----------------
- Microsoft Systems Management Server 2003 : Package Distribution and Management - Monitoring Status
- Microsoft Systems Management Server 2003 : Configuring the Client (part 4) - Managing the Advanced Client Download Cache, Advertised Programs Process Flow
- Microsoft Systems Management Server 2003 : Configuring the Client (part 3)
- Microsoft Systems Management Server 2003 : Configuring the Client (part 2) - Running Advertised Programs on Clients - Advertised Programs Wizard
- Microsoft Systems Management Server 2003 : Configuring the Client (part 1)
- Microsoft Systems Management Server 2003 : Package Distribution and Management - Creating an Advertisement
- SharePoint 2010 : Connecting and Disconnecting Servers with Windows PowerShell, Additional Functionality in SharePoint 2010
- Microsoft Dynamics CRM 4 : Digital Phone Integration (part 3) - c360 CTI for Microsoft CRM
- Microsoft Dynamics CRM 4 : Digital Phone Integration (part 2) - Cisco Unified CallConnector for Microsoft Dynamics CRM
- Microsoft Dynamics CRM 4 : Digital Phone Integration (part 1)
 
 
REVIEW
- First look: Apple Watch

- 10 Amazing Tools You Should Be Using with Dropbox

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
 
VIDEO TUTORIAL
- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
 
Popular tags
Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS
Popular keywords
HOW TO Swimlane in Visio Visio sort key Pen and Touch Creating groups in Windows Server Raid in Windows Server Exchange 2010 maintenance Exchange server mail enabled groups Debugging Tools Collaborating
Top 10
- Microsoft Excel : How to Use the VLookUp Function
- Fix and Tweak Graphics and Video (part 3) : How to Fix : My Screen Is Sluggish - Adjust Hardware Acceleration
- Fix and Tweak Graphics and Video (part 2) : How to Fix : Text on My Screen Is Too Small
- Fix and Tweak Graphics and Video (part 1) : How to Fix : Adjust the Resolution
- Windows Phone 8 Apps : Camera (part 4) - Adjusting Video Settings, Using the Video Light
- Windows Phone 8 Apps : Camera (part 3) - Using the Front Camera, Activating Video Mode
- Windows Phone 8 Apps : Camera (part 2) - Controlling the Camera’s Flash, Changing the Camera’s Behavior with Lenses
- Windows Phone 8 Apps : Camera (part 1) - Adjusting Photo Settings
- MDT's Client Wizard : Package Properties
- MDT's Client Wizard : Driver Properties
 
Windows XP
Windows Vista
Windows 7
Windows Azure
Windows Server
Windows Phone
2015 Camaro