With a command line I did notice that the SQL Server process has exceeded its threshold


Quick Tip

Do you believe if I said that with a PowerShell command line you will be notified if the SQL Server process has exceeded its threshold? say 80%

   1: #SQLServiceStop

   2: $query = "Select * from __instanceModificationEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_PerfFormattedData_PerfProc_Process' AND TargetInstance.Name='sqlservr' AND TargetInstance.PercentProcessorTime>80"

   3: #Register WMI event

   4: Register-WMIEvent -Query $query -Action {Write-Host "Hey..hey..wakeup Man. Your SQL Server Process exceeded 80%"}

HA. You’re lying to me Laerte, I’m seeing two lines.. Ok..Ok..

   1: Register-WMIEvent -Query "Select * from __instanceModificationEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_PerfFormattedData_PerfProc_Process' AND TargetInstance.Name='sqlservr' AND TargetInstance.PercentProcessorTime>80"  -Action {Write-Host "Hey..hey..wakeup Man. Your SQL Server Process exceeded 80%"}

Now You can register the WMI event in a remote server, and be notifed by Email, Ballon notification ( Robert Ro Belo´s Blog – Sly PowerShell (Balloon tip notifications)…your imagination is the limit.

Big Thanks to my good friend Ravikanth Chaganti who showed  me WMI and WQL. I strongly suggest you download the Ebook

Ravikanth Chaganti – WMI Query Language (WQL) – Event Queries: Introduction

 

Can you see this ? Can you feel this ? Can you feel the power ?

Powershell ROCKS !!!!

About Laerte Junior

Laerte Junior Laerte Junior is a SQL Server specialist and an active member of WW SQL Server and the Windows PowerShell community. He also is a huge Star Wars fan (yes, he has the Darth Vader´s Helmet with the voice changer). He has a passion for DC comics and living the simple life. "May The Force be with all of us"
This entry was posted in Algo que Esqueci de Categorizar. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s