Purclot
Purclot

Reputation: 559

PowerShell SQL Server Processor Performance Counter

I'd like to monitor the Processor-Load on a Server with 8 SQL Instances. I discover the proper counters with:

get-counter -listset processor | select -expandproperty counter

I get something like: \Processor(*)% Processor Time and \Process(sqlsrv#1...sqlsrv#XX) which I'm intersting in. I can now declare my counter:

$counter="\Process(sqlsrv#1)\% Processor Time"; Get-counter -counter $counter -sampleInterval 3

But how do I know which one of the SQL-Instances is hidden behind "sqlsrv#1".."sqlsrv#8"?

Upvotes: 0

Views: 254

Answers (1)

SQLServerBuddy
SQLServerBuddy

Reputation: 161

Actually, I don't think we have direct way to do that... But

Says suppose - If you have 3 Instance in your Server (Process will be sqlservr, sqlservr#1 and sqlservr#2). Right ?

You can find the PID of each of them using below Counter name ID Process in Process Object

\Process(sqlservr)\ID Process
\Process(sqlservr#1)\ID Process
\Process(sqlservr#2)\ID Process

Powershell

Get-counter -counter "\Process(sqlservr)\ID Process"
Get-counter -counter "\Process(sqlservr#1)\ID Process"
Get-counter -counter "\Process(sqlservr#2)\ID Process"

Once you get the PID, You can compare the PID in Task Manager and find the "User name" tab will have the actual Instance name

Note: The Numbers suffixed with process called InstanceIndex

Upvotes: 1

Related Questions