< Back
Get-DbaCpuRingBuffer
Post
NAME Get-DbaCpuRingBuffer
SYNOPSIS
Collects CPU data from sys.dm_os_ring_buffers. Works on SQL Server 2005 and above.
SYNTAX
Get-DbaCpuRingBuffer [-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]> [[-SqlCredential]
<Pscredential>] [[-CollectionMinutes] <Int>] [-EnableException <Switch>] [<CommonParameters>]
DESCRIPTION
This command is based off of Glen Berry's diagnostic query for average CPU
The sys.dm_os_ring_buffers stores the average CPU utilization history
by the current instance of SQL Server, plus the summed average CPU utilization
by all other processes on your machine are captured in one minute increments
for the past 256 minutes.
Reference: https://www.sqlskills.com/blogs/glenn/s ... d-day-16//
PARAMETERS
-CollectionMinutes [<Int>]
Allows you to specify a Collection Period in Minutes. Default is 60 minutes
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables
advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own
try/catch.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlCredential [<Pscredential>]
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -
Integrated are all supported.
For MFA support, please use Connect-DbaInstance. To use:
$cred = Get-Credential, this pass this $cred to the param.
Windows Authentication will be used if DestinationSqlCredential is not specified. To connect as a different
Windows user, run PowerShell as that user.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]
Allows you to specify a comma separated list of servers to query.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Tags: CPU
Author: Patrick Flynn (@sqllensman)
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Get-DbaCpuRingBuffer -SqlInstance sql2008, sqlserver2012
Gets CPU Statistics from sys.dm_os_ring_buffers for servers sql2008 and sqlserver2012 for last 60 minutes.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Get-DbaCpuRingBuffer -SqlInstance sql2008 -CollectionMinutes 240
Gets CPU Statistics from sys.dm_os_ring_buffers for server sql2008 for last 240 minutes
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>$output = Get-DbaCpuRingBuffer -SqlInstance sql2008 -CollectionMinutes 240 | Select-Object * |
ConvertTo-DbaDataTable
Gets CPU Statistics from sys.dm_os_ring_buffers for server sql2008 for last 240 minutes into a Data Table.
-------------------------- EXAMPLE 4 --------------------------
PS C:\\>'sql2008','sql2012' | Get-DbaCpuRingBuffer
Gets CPU Statistics from sys.dm_os_ring_buffers for servers sql2008 and sqlserver2012
-------------------------- EXAMPLE 5 --------------------------
PS C:\\>$cred = Get-Credential sqladmin
PS C:\\> Get-DbaCpuRingBuffer -SqlInstance sql2008 -SqlCredential $cred
Connects using sqladmin credential and returns CPU Statistics from sys.dm_os_ring_buffers from sql2008
RELATED LINKS
https://dbatools.io/Get-DbaCpuRingBuffer
SYNOPSIS
Collects CPU data from sys.dm_os_ring_buffers. Works on SQL Server 2005 and above.
SYNTAX
Get-DbaCpuRingBuffer [-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]> [[-SqlCredential]
<Pscredential>] [[-CollectionMinutes] <Int>] [-EnableException <Switch>] [<CommonParameters>]
DESCRIPTION
This command is based off of Glen Berry's diagnostic query for average CPU
The sys.dm_os_ring_buffers stores the average CPU utilization history
by the current instance of SQL Server, plus the summed average CPU utilization
by all other processes on your machine are captured in one minute increments
for the past 256 minutes.
Reference: https://www.sqlskills.com/blogs/glenn/s ... d-day-16//
PARAMETERS
-CollectionMinutes [<Int>]
Allows you to specify a Collection Period in Minutes. Default is 60 minutes
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables
advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own
try/catch.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlCredential [<Pscredential>]
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -
Integrated are all supported.
For MFA support, please use Connect-DbaInstance. To use:
$cred = Get-Credential, this pass this $cred to the param.
Windows Authentication will be used if DestinationSqlCredential is not specified. To connect as a different
Windows user, run PowerShell as that user.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]
Allows you to specify a comma separated list of servers to query.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Tags: CPU
Author: Patrick Flynn (@sqllensman)
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Get-DbaCpuRingBuffer -SqlInstance sql2008, sqlserver2012
Gets CPU Statistics from sys.dm_os_ring_buffers for servers sql2008 and sqlserver2012 for last 60 minutes.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Get-DbaCpuRingBuffer -SqlInstance sql2008 -CollectionMinutes 240
Gets CPU Statistics from sys.dm_os_ring_buffers for server sql2008 for last 240 minutes
-------------------------- EXAMPLE 3 --------------------------
PS C:\\>$output = Get-DbaCpuRingBuffer -SqlInstance sql2008 -CollectionMinutes 240 | Select-Object * |
ConvertTo-DbaDataTable
Gets CPU Statistics from sys.dm_os_ring_buffers for server sql2008 for last 240 minutes into a Data Table.
-------------------------- EXAMPLE 4 --------------------------
PS C:\\>'sql2008','sql2012' | Get-DbaCpuRingBuffer
Gets CPU Statistics from sys.dm_os_ring_buffers for servers sql2008 and sqlserver2012
-------------------------- EXAMPLE 5 --------------------------
PS C:\\>$cred = Get-Credential sqladmin
PS C:\\> Get-DbaCpuRingBuffer -SqlInstance sql2008 -SqlCredential $cred
Connects using sqladmin credential and returns CPU Statistics from sys.dm_os_ring_buffers from sql2008
RELATED LINKS
https://dbatools.io/Get-DbaCpuRingBuffer