exec sp_whoisactive + cpu

  • Hello everyone

    I am looking for a method to automatically launch the procedure of Adam machanic when I have a conssomation CPU higher than 80%

    thank you for your help

  • You could make use of WMI query and alerting by starting sp_who2 embedded in a SQL Agent job. 
    Just modify the threshold duration and utilization load percentage as required. 
    After creating the alert, you'll need to update it to start the SQL Agent Job that contains your stored procedure, under 'Response' settings of the Alert. 

    USE [msdb]
    GO

    EXEC msdb.dbo.sp_add_alert @name=N'CPU_Usage_Check',
    @message_id=0,
    @severity=0,
    @enabled=1,
    @delay_between_responses=0,
    @include_event_description_in=1,
    @category_name=N'[Uncategorized]',
    @wmi_namespace=N'\\.\ROOT\CIMV2',
    @wmi_query=N'SELECT * FROM __InstanceModificationEvent WITHIN 600 WHERE TargetInstance ISA “Win32_Processor” AND TargetInstance.LoadPercentage > 80',
    @job_id=N'00000000-0000-0000-0000-000000000000'
    GO

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    This thing is addressing problems that dont exist. Its solution-ism at its worst. We are dumbing down machines that are inherently superior. - Gilfoyle

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply