Day 24 Performance Monitor
Sql Performance:
❑ performance counters sys.dm_os_performance_counters
❑ Top ten queries from sys.dm_exec_query_stats and sys.dm_exec_sql_text
❑ Processor: sys.dm_os_schedulers
❑Memory : sys.dm_os_memory_clerks
Performance counters using WMIobject:
Formatted Data
❑get-wmiobject Win32_PerfFormattedData_PerfDisk_PhysicalDisk
❑get-wmiobject Win32_PerfFormattedData_PerfOS_Memory
❑get-wmiobject Win32_PerfFormattedData_PerfOS_Processor
❑get-wmiobject Win32_PerfFormattedData_PerfProc_Process
❑get-wmiobject Win32_PerfFormattedData_Tcpip_NetworkInterface
Or
ROW data
❑ Win32_PerfRawData_PerfDisk_PhysicalDisk
❑ Win32_PerfRawData_PerfOS_Memory
❑ Win32_PerfRawData_PerfOS_Processor
❑ Win32_PerfRawData_PerfProc_Process
❑ Win32_PerfRawData_Tcpip_NetworkInterface
As we see the performance monitor can be using WMI now we can also use .net to get performance monitor information
Using PerformanceCounter Object (.NET):
get-wmiobject Win32_PerfFormattedData_PerfProc_Process
$pc = new-object system.diagnostics.PerformanceCounter
[System.Diagnostics.PerformanceCounterCategory]::GetCategories()
$cat = new-object System.Diagnostics.PerformanceCounterCategory(“Process”)
$cat.GetInstanceNames()
$cat.GetCounters(“powershell”)
$cat.GetCounters()
$pc.nextvalue() : is as good as Formatted Data
$pc.nextSample(): is as good as Row Data
Version Powershell V2:
Powershell v2 has introduced new cmdlet for performance counter
get-counter -ListSet *
Get-counter Gets real-time performance counter data from local and remote computers.
Import-counter Exports PerformanceCounterSampleSet objects as performance counter log (.blg, .csv, .tsv) files.
Export-counter Imports performance counter log files and creates objects that represent each counter sample in the log.
Perfmon:
Standard gui way of getting the performance counters is perfmon, you can script this as well.
Using Sqlserver:
Sql server provides sys.sysperfmon
Using Data Collector
Reference:-
http://msdn.microsoft.com/en-us/library/system.diagnostics.aspx
http://mow001.blogspot.com/2005/12/getting-performancemonitor-info-from.html
Keep it refreshing