---
title: "Get-DbaCpuRingBuffer"
description: "Retrieves historical CPU utilization data from SQL Server's internal ring buffer for performance analysis"
url: "https://dbatools.io/Get-DbaCpuRingBuffer/"
availability: "Windows, Linux, macOS"
tags: ["Diagnostic", "Buffer", "CPU"]
author: "Patrick Flynn (@sqllensman)"
source: "https://github.com/dataplat/dbatools/blob/master/public/Get-DbaCpuRingBuffer.ps1"
last_updated: "2024-01-01"
---

# Get-DbaCpuRingBuffer

## Synopsis

Retrieves historical CPU utilization data from SQL Server's internal ring buffer for performance analysis

## Description

This command queries sys.dm_os_ring_buffers to extract detailed CPU utilization history for performance troubleshooting and capacity planning. Based on Glen Berry's diagnostic query, it provides minute-by-minute CPU usage breakdowns that help identify performance patterns and resource contention.  
  
The ring buffer stores CPU utilization data in one-minute increments for up to 256 minutes, tracking three key metrics: SQL Server process utilization, other processes utilization, and system idle time. This historical data is invaluable when investigating performance issues, establishing baselines, or determining if high CPU usage originates from SQL Server or other system processes.  
  
Use this function to analyze CPU trends during specific time periods, correlate CPU spikes with application events, or gather evidence for capacity planning decisions without requiring external monitoring tools.  
  
Reference: https://www.sqlskills.com/blogs/glenn/sql-server-diagnostic-information-queries-detailed-day-16//

## Syntax

```powershell
Get-DbaCpuRingBuffer
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [[-CollectionMinutes] <Int32>]
    [-EnableException]
    [<CommonParameters>]

```

## Examples

### Example 1: Gets CPU Statistics from sys.dm_os_ring_buffers for servers sql2008 and sqlserver2012 for last 60 minutes

```powershell
PS C:\> Get-DbaCpuRingBuffer -SqlInstance sql2008, sqlserver2012
```

### Example 2: Gets CPU Statistics from sys.dm_os_ring_buffers for server sql2008 for last 240 minutes

```powershell
PS C:\> Get-DbaCpuRingBuffer -SqlInstance sql2008 -CollectionMinutes 240
```

### Example 3: Gets CPU Statistics from sys.dm_os_ring_buffers for server sql2008 for last 240 minutes into a Data Table

```powershell
PS C:\> $output = Get-DbaCpuRingBuffer -SqlInstance sql2008 -CollectionMinutes 240 | Select-Object * | ConvertTo-DbaDataTable
```

### Example 4: Gets CPU Statistics from sys.dm_os_ring_buffers for servers sql2008 and sqlserver2012

```powershell
PS C:\> 'sql2008','sql2012' | Get-DbaCpuRingBuffer
```

### Example 5: Connects using sqladmin credential and returns CPU Statistics from sys.dm_os_ring_buffers from sql2008

```powershell
PS C:\> $cred = Get-Credential sqladmin
PS C:\> Get-DbaCpuRingBuffer -SqlInstance sql2008 -SqlCredential $cred
```

### Required Parameters

##### -SqlInstance

Allows you to specify a comma separated list of servers to query.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | True |
| Pipeline | true (ByValue) |
| Default Value |  |

### Optional Parameters

##### -SqlCredential

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.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -CollectionMinutes

Specifies how many minutes of historical CPU data to retrieve from the ring buffer. Defaults to 60 minutes.  
Use this to extend the analysis window when investigating longer-term CPU trends or to focus on recent activity with shorter periods. Maximum available history is typically 256 minutes depending on   
system activity.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value | 60 |

##### -EnableException

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.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value | False |

## Outputs

**PSCustomObject**

Returns one object per minute of CPU ring buffer data retrieved from the SQL Server instance.

**Properties:**

- ComputerName: The computer name of the SQL Server instance
- InstanceName: The SQL Server instance name
- SqlInstance: The full SQL Server instance name (computer\instance)
- RecordId: The unique record identifier from the ring buffer entry
- EventTime: DateTime of the CPU sample (in local server time)
- SQLProcessUtilization: Percentage of CPU used by the SQL Server process (0-100)
- SystemIdle: Percentage of CPU that is idle (0-100)
- OtherProcessUtilization: Percentage of CPU used by other processes (0-100), calculated as 100 - SystemIdle - SQLProcessUtilization

---

Part of [dbatools](https://dbatools.io/), a free and open source PowerShell module for SQL Server administration. Full command index: https://dbatools.io/commands/
