Posted by AlterEgo on 02/06/07 19:00
robboll,
The following script will send a "net send" message and could be run using
the Windows Scheduler. You could substitute the net send command with an
email using MAPI or SMTPMail (requirems more setup possibly). There should
be plenty of scripting examples on Google or Yahoo search. You could also
include an itterator (For Each) using SQL DMO to get a list of server names.
Dim wsh
Set wsh = CreateObject("WScript.Shell")
strComputer = "Computer_Name"
strUser = "Your_Network_Login_Name"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery _
("Select State from Win32_Service where Name = 'SQLSERVERAGENT'")
For Each objService In colServiceList
If objService.State <> "Running" Then
wsh.Run ("net send " & strUser & " SQLSERVERAGENT Service is not
running on " & strComputer & " attempting to start
it.")
' start the service
wsh.Run ("net start /" & strComputer & " SQLSERVERAGENT")
End If
Next
-- Bill
"robboll" <robboll@hotmail.com> wrote in message
news:1170779081.371621.32880@p10g2000cwp.googlegroups.com...
> Is there a simple way of letting the Database Administrator know when
> the SQL Agent get turned off? I know this can happen from time to
> time, but I need a mechanism to shoot me an email or something when
> this happens. I know -- I can set up a SQL Agent job to do that ;)
>
> Any suggestions greatly appreciated!!!
>
> RBollinger
>
[Back to original message]
|