Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Event Viewer Notification? 3

Status
Not open for further replies.
Jun 16, 2004
53
0
0
US
Hi all,

Is there any way to have Windows 2003 notify me either through email, cell or pager when a service like MSSQLSERVER starts or stops through Event Viewer or some other means?

I would prefer to do this within Windows without the need of a third party program like What's Up Gold.

Does anyone have any ideas?

Thanks in advance!
 
Yes there is:

Right click "My Computer" -> Manage -> Services and Applications -> Services -> Double click the service of your choice -> Choose the "Recovery" tab.

You can define what to do when the service fails (I guess it is more interesting getting info about failing services than getting info about every time a service starts).

Here you can for instance choose to run a program. This program can be a script that restarts the service and in the same operation notifies you (or anyone else) pr e-mail or sms.

 
Hi Brainsurgery,

Thanks for the reply. I'm aware of this method but unfortunately it requires me to take extra steps (i.e. creating a batch script) in order for me to be notified. But thank you for taking the time to respond.

I wish there was a notification service in Windows that would accomplish what I'm trying to do without the need for third party software. Along the lines of CA's Brighstor ArcServ 11's notification utility.

Oh well. I guess I'll have to write a script to call up some other program.


 
No need to write the script. I've got one.

Edit the following lines in the script for your network:

ODomain = "thespidersparlor.com"
oMyIP = "192.168.1.2"
oTo = "support@thespidersparlor.com"


Pass this script the service name as an argument on the recovery tab.

Code:
'==========================================================================
'
' VBScript Source File -- 
'
' NAME: NotifySvcFailure.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor	
' DATE  : 04/15/2003
'
' COMMENT: 
'
' This script can be added to a services actions to be taken on failure
'
' You must customize the entries for oDomain and oMyIP with the proper company information.
' Items to customize are on lines 28 and 30.
'=====================================
 
Dim oName, ODomain, oMyIP, oTo, svcName

Set svcName = WScript.Arguments

' Get the computer name
Set WshNetwork = CreateObject("WScript.Network")
oName = WshNetwork.ComputerName

' Set the company specific information

' Company Internet Domain Name
ODomain = "thespidersparlor.com"
' Set the SMTP server IP
oMyIP = "192.168.1.2" 
' Where do you want the message to be delivered
oTo = "support@thespidersparlor.com"


' Set the visual basic constants as they do not exist within VBScript.
' Do not set your smtp server information here.
Const cdoSendUsingMethod = "[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing",[/URL] _
cdoSendUsingPort = 2, _
cdoSMTPServer = "[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver"[/URL]

'Create the CDO connections.
Dim iMsg, iConf, Flds
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields

'SMTP server configuration.
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort

'Set the SMTP server address here.
.Item(cdoSMTPServer) = oMyIP
.Update
End With

'Set the message properties.
With iMsg
Set .Configuration = iConf
.To = oTo
.From = oName & "@" & oDomain
.Subject = "Service Failure"
.TextBody = "Service " & svcName & " on Server " & oName & " at company " & ODomain & " failed 2 times, the time of failure was " & now
End With

'An attachment can be included.
'iMsg.AddAttachment Attachment

'Send the message.
iMsg.Send 

'MsgBox "Done"

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Mark, you are the man! :)

Thanks so much!

I'm going to implement this today and I'll write back to let you know how it went.
 
My pleasure. If you like it throw a star my way, I'm so distraught over loosing my top MVP slot. :)

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Mark,
Would it be possible to enter multiple e-mail addresses into your script? Otherwise, looks like a great script, thank you for making it available to those of us who aren't as adept at VB as others.

Regards,

Eric
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top