Ads

Showing posts with label SQL Server Down Alert Script. Show all posts
Showing posts with label SQL Server Down Alert Script. Show all posts

17 November 2011

SQL Agent Script

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colMonitoredProcesses = objWMIService. _
ExecNotificationQuery("select * from __instancedeletionevent " _
& "within 1 where TargetInstance isa 'Win32_Process'")
Do While i = 0
Set objLatestProcess = colMonitoredProcesses.NextEvent
If objLatestProcess.TargetInstance.Name = "sqlservr.exe" Then
Set objEmail = CreateObject("CDO.Message")
SmtpMail.SmtpServer = "indblrvmsg00"
objEmail.From = "Test@aditi.com"
objEmail.To = "pradyothanapd@aditi.com"
objEmail.Subject = "SQl Server is down on" & strcomputer
objEmail.Textbody = "SQL Sever is down"
objEmail.Send
End If
Loop