917
Chapter 37: Performance Monitor and PAL
37
While the code above is useful for outputting results to the screen, in the long run you are
going to ultimately want to convert the results into a datatable so that you can save the
results into a database
$CounterResults = Get-Counter -Counter $CountersList
$CounterRecords = $CounterResults.CounterSamples | Out-DataTable
$CounterRecords | Format-Table -Auto
Finally, as an alternate option you may need to save off your results to a CSV fi le. You use
the built in PowerShell cmdlet to do that for you.
$CounterResults = Get-Counter -Counter $CountersList
$CounterRecords = $CounterResults.CounterSamples | Out-DataTable|
Export-Csv "C:\Temp\MySQLCounters.csv" –NoTypeInformation
Summary
PerfMon is a powerful tool in any DBA’s toolbox. Used alone, it provides a comprehensive
overview of the server’s status — both Windows and SQL Server. The key to PerfMon is
understanding the overwhelming number of counters. If you know which counters to focus
on, you’ll fi nd that PerfMon can be effi cient.
The next chapter looks at Profi ler, a SQL Server monitoring tool that you can use with
PerfMon to produce thorough performance monitoring.
c37.indd 917c37.indd 917 7/31/2012 10:03:54 AM7/31/2012 10:03:54 AM
http://www.it-ebooks.info