Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

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

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
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)
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server