SQL Server News & Information tsql, performance tuning, industry trends, & bad jokes
tsql, performance tuning, industry trends, & bad jokes
This site is maintained by Jason Massie. He has 10 years experience as a DBA and has specialized in performance tuning for the last five. He was recognized by Microsoft as a SQL Server MVP. Jason has spoken at the Professional Association of SQL Server Conference, the North Texas SQL Server Users Group, SQL Connections and TechED. He has worked at Terremark (formerly Data Return) for nearly a decade.
You can contact him at jason@statisticsio.com or 469.569.5965
Abstracts addition Affinity Aggregation allocation Always Analysis Announced another API Appending article Authentication backup be Behavior between Bootstrapper Breaking Build Cache Caching Check checksums Codeplex collection Connecting contest Controller Creating CTEs CTP CUBE cursors Data Database DATALENGTH Debugging Design Diagnosing Diagnostic Differences Documentation DTS Emergency enhancement Entity ETW Exchange execution Express Extensions Fall February Filestream Filtered group GROUPING have Hosting Idle impact Improvement Increase Index Indexes Inserts Instances Interoperability Introduction IO large Late LOB local Localized Magazine Maintaining Maintenance Management maps March Microsoft minutes missing Mix Never November Offline OLE Online operations operators optimizations Optimized Overlapping Package Page Paging Panacea parallel part Partial Partition partitioned Partitioning PASS Performance PFS plan Plans Practices problem Problems Procedure Program programmatically Programming Protection Queries query read recent Recursive Related released Reports Restore return ROLLUP ROWCOUNT Runtime Security Select Sequence sequential Server Services set SETS Shooting shorts sizes Solutions Sortable SPARSE Spool SQL SQLIOSim SSIS Stalled Star Statement Statements stats Stored strategy Stuck Studio Submission Subreports Suggested Summarizing system Table Tables Tampa Task Than there through Timeouts Total Traces Transaction transfer Tricks Trouble TSQL turning understand Understanding undocumented Unique unused upgrade Upgrading Useful Value variables VDI Vista Will Windows Wireless
In the first post, we took a quick look at how data collection works. In this post, we will see how to create custom data collection.
To create a custom collection, you must use the stored procedures. In Bill Ramos's web cast, he hints it may stay like this i.e. NO GUI. I tend to doubt it because Microsoft built their empire making hard stuff easy.
In this example, we will look at collecting 3 key indicators of a CPU bottleneck. These items are actually included in the "server activity" system data collection. However, it cannot be modified and it collects everything under the kitchen sink. Multiply that times 20 or 100 servers and you are looking at some huge storage requirements. I think smaller data collections like this will be common.
Let's get to business...
use msdb;
--Let's create the collection set
Declare @collection_set_id_1 int
Declare @collection_set_uid_2 uniqueidentifier
EXEC [dbo].[sp_syscollector_create_collection_set]
@name=N'CPU indicators',
@collection_mode=0, --Let's start in cached mode.
@description=N'Collects CPU KPIs from perfmon and DMVs',
@target=N'', --Undocumented
@logging_level=0, --0 through 2 are valid
@days_until_expiration=5, --Let's just keep data 5 days. We will rollup for reporting.
@proxy_name=N'', --Use if you want it to run under something other than the SQL Agent svc account.
@schedule_name=N'CollectorSchedule_Every_5min', --Built in schedule
@collection_set_id=@collection_set_id_1 OUTPUT,
@collection_set_uid=@collection_set_uid_2 OUTPUT
Select @collection_set_id_1, @collection_set_uid_2
--Let's get the needed perfmon counters
Declare @collector_type_uid_7 uniqueidentifier
Select @collector_type_uid_7 = collector_type_uid From [dbo].[syscollector_collector_types] Where name = N'Performance Counters Collector Type';
Declare @collection_item_id_8 int
EXEC [dbo].[sp_syscollector_create_collection_item]
@name=N'Perfmon CPU counters',
@parameters=N'
<PerformanceCountersCollector>
<PerformanceCounters Objects="SYSTEM" Counters="Processor Queue Length" Instances="*" />
<PerformanceCounters Objects="Processor" Counters="% Processor Time" Instances="*" />
</PerformanceCountersCollector>',
@collection_item_id=@collection_item_id_8 OUTPUT,
@frequency=5,
@collection_set_id=@collection_set_id_1, --Output from sp_syscollector_create_collection_set
@collector_type_uid=@collector_type_uid_7
Select @collection_item_id_8
--Let's get the DMV data
Declare @collector_type_uid_3 uniqueidentifier
Select @collector_type_uid_3 = collector_type_uid From [dbo].[syscollector_collector_types] Where name = N'Generic T-SQL Query Collector Type';
Declare @collection_item_id_4 int
@name=N'CPU pressure check',
@parameters=
N'<TSQLQueryCollector>
<Query>
<Value>select SUM(runnable_tasks_count) from sys.dm_os_schedulers where scheduler_id >2
</Value>
<OutputTable>CPU_Pressure_OS_Schedulers</OutputTable>
</Query>
<Databases UseSystemDatabases="true" UseUserDatabases="true" />
</TSQLQueryCollector>',
@collection_item_id=@collection_item_id_4 OUTPUT,
@collector_type_uid=@collector_type_uid_3
Select @collection_item_id_4
--Let's start the collection
exec sp_syscollector_start_collection_set @collection_set_id = @collection_set_id_1 --Output from sp_syscollector_create_collection_set
We can now see that the collection has been created in SSMS. This is what it looks like:
That's it. In the next part, we will look at reporting off of this collection through tsql and SSRS.
posted @ Tuesday, March 04, 2008 10:32 AM by Technical Musings
Name (required)
Email (required)
Website
Notify me of followup comments via e-mail