How to trigger the SQL Agent Alert using WMI query

  • In the SQL Server Alert system, under the WMI query, consider we code the WMI query in it. How the SQL Server Agent alert picks up the output produced by the WMI query, so that we can raise the final alert in the form of email or job execution.

    An example of WMI query for this purpose will also help.

    John

  • I use the below WMI query to find the balance memory available in a server.

    strComputer = "."

    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

    Set colSettings = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")

    For Each objOperatingSystem in colSettings

    Wscript.Echo "Available Physical Memory: " & objOperatingSystem.FreePhysicalMemory

    Next

    Wscript.quit

    How can I use the result from the above to trigger the SQL Server Alert, so that I get the final alert message as an email.

    John

  • I belive WMI query in SQL Server Alerts only works along with SQL Server EVENT NOTIFICATIONS. So if SQL Server EVENT NOTIFICATION doesnt contain the EVENT for memory usage (RAM usage), then I believe it is not possible to set Alert by the WMI query in SQL Server for RAM usage.

    Please help if my assumptions are wrong.

    John

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

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