Upload
bryan-norman
View
213
Download
2
Embed Size (px)
Citation preview
Gather Microsoft SQL Server Performance Data with Windows PowerShellAllen WhiteUpSearch Technology ServicesSQL Server MVP
SESSION CODE: DAT306
About MeSQL Server Consultant with UpsearchOver 35 years in ITCareer covered multiple disciplines – operations, development, telecommunications, network design/administration and database design and administrationStarted using Sybase in 1992, MS SQL Server in 1995Microsoft Certified IT Professional: Database Administrator and Database Developer, Microsoft Certified Trainer (MCT)Awarded Microsoft MVP Award for SQL Server for last 3 years
AgendaPerformance CountersCapture OptionsPowerShell ScriptPerformance Analysis ReportNotifications
Goal - Capture Performance BaselineBaseline shows normal performanceDeviations from Baseline require investigationProblem
Data comes from disparate sourcesCoordination of multiple gathering toolsSynchronizing data for true baseline analysis
SolutionPowerShell
Gather SQL Server Performance Data with PowerShell
Key Performance IndicatorsWhich counters show us system healthThere’s no “right” answerThese are my choices
Gather SQL Server Performance Data with PowerShell
Operating System Counters
Object Counter Look For
Processor % Processor Time Should be <= 80%
Memory Available MBytesLow Memory, Server Paging
Paging File(_Total) % Usage Should be < 70%
PhysicalDisk(*) Disk Reads/secBaseline, watch for unusual variations
PhysicalDisk(*) Disk Writes/secBaseline, watch for unusual variations
System Processor Queue Length> 10 threads/proc and CPU > 80% is concern
Gather SQL Server Performance Data with PowerShell
SQL Server Counters
Object Counter Look For
Access Methods Forwarded Records/secShould be < 10 per 100 batch requests/sec
Access Methods Page Splits/secShould be <20 per 100 batch requests/sec
Buffer Manager Buffer cache hit ratio Should be > 90%
Buffer Manager Page life expectancy Should be >=300
General Statistics Processes blocked Baseline, check for changes
SQL Statistics Batch Requests/sec > 1000 is busy system
SQL Statistics SQL Compilations/secShould be < 10% of batch requests/sec
SQL Statistics SQL Re-Compilations/secShould be < 10% of compilations/sec
Gather SQL Server Performance Data with PowerShell
Sources for Performance Data
PerfmonSave data to .CSVUse SSIS or PowerShell to import results
DMVsGreat source of SQL Server data
sys.dm_os_performance_countersOnly returns SQL Server current instance counters
WMIAllows access to all aspects of serverCrunching the numbers can be tricky
Gather SQL Server Performance Data with PowerShell
Performance Data in PowerShellGet-Counter cmdlet (PowerShell 2.0)
Invocation sets own interval handlerSystem.Diagnostics.PerformanceCounter
Support directly within .NETResults directly match Perfmon valuesAccessible from PowerShell
Gather SQL Server Performance Data with PowerShell
Collecting PerformanceCounter data
DEMO
Performance Database
Every Admin should have oneStore Baseline DataStore Server Side Trace infoStore Server and Instance infoKeep all management info in one place
Gather SQL Server Performance Data with PowerShell
Scripting the Data Capture
Capture the counter dataInsert into Performance DatabaseWait defined interval and do it again
Gather SQL Server Performance Data with PowerShell
Capture the counter data# Initialize Perfcounters$ppt = new-object System.Diagnostics.PerformanceCounter$ppt.CategoryName = 'Processor'$ppt.CounterName = '% Processor Time'$ppt.InstanceName = '_Total'
Logic Flow for getperf.ps1
Gather SQL Server Performance Data with PowerShell
Connect to ServerFind Instances
Initialize Server
Counters
For Each Instance
Initialize Instance Counters
While Not EndDate
Capture Server Counters
For Each Instance
Capture Instance Counters
The getperf.ps1 script
DEMO
Creating the Analysis Reports
Create Basic ReportAdd Table for Counter DataAdd Graphs to see TrendsAdd Dashboard Report to SSMS
Demo
Gather SQL Server Performance Data with PowerShell
Notifications
Once Baseline is understoodDefine deviation amount for warningDefine deviation amount for error condition
Build notification mechanismsIf warning send emailIf error send text message
SQL Server Agent Alerts can watch some counters
Gather SQL Server Performance Data with PowerShell
Build Alerts with PowerShell
DEMO
References
Master-PowerShell | With Dr. Tobias Weltnerhttp://powershell.com/cs/blogs/ebook/default.aspx
Let PowerShell do an Inventory of your Servershttp://www.simple-talk.com/sql/database-administration/let-powershell-do-an-inventory-of-your-servers/
Initialize-SqlpsEnvironment.ps1 scripthttp://blogs.msdn.com/mwories/archive/2008/06/14/SQL2008_5F00_Powershell.aspx
Midnight DBA – PowerShell webcastshttp://midnightdba.itbookworm.com/
Gather SQL Server Performance Data with PowerShell
Thank you
DAT Track Scratch 2 Win
Find the DAT Track Surface Table in the Yellow Section of the TLCTry your luck to win a Zune HDSimply scratch the game pieces on the DAT Track Surface Table and Match 3 Zune HDs to win
Resources
www.microsoft.com/teched
Sessions On-Demand & Community Microsoft Certification & Training Resources
Resources for IT Professionals Resources for Developers
www.microsoft.com/learning
http://microsoft.com/technet http://microsoft.com/msdn
Learning
Complete an evaluation on CommNet and enter to win!
Sign up for Tech·Ed 2011 and save $500 starting June 8 – June 31st
http://northamerica.msteched.com/registration
You can also register at the
North America 2011 kiosk located at registrationJoin us in Atlanta next year
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to
be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
JUNE 7-10, 2010 | NEW ORLEANS, LA