Tuesday, July 13, 2004

Receive an email when a service goes down

The follow is an excerpt of an email newsletter from TechRepublic. Nice tip.

"Sooner or later, whether you're troubleshooting a server or just
managing one, knowing when a particular service goes down can be a real
lifesaver. Early notification can help you recognize that a problem has
occurred so you can get to work on the problem as soon as possible to
minimize disruption to users and/or customers.

A service's properties provide a handful of recovery options. To view
these properties, open the Services console, double-click a service,
and select the Recovery tab.

The Recovery tab sports three drop-down lists that let you specify
which action Windows should take, if any, when the service fails the
first, second, and subsequent times.

For example, you can configure Windows to send you an e-mail
notification if the service goes down. To do so, create the following
script using Notepad:

set objArgs = Wscript.Arguments
Set objEmail = CreateObject("CDO.Message")
objEmail.From = adminaddress@yourdomain.tld
objEmail.To = youraddress@yourdomain.tld
objEmail.Subject = objArgs(0) & " service is down"
objEmail.Textbody = "The service " & objArgs(0) & " has failed."
objEmail.Send
set objArgs = nothing
set objEmail = nothing

Save the script as Mail.vbs, and open the properties for the service
from the Services console. In one of the three drop-down lists, choose
the Run A File option. Click Browse to navigate to the Mail.vbs script
you just created. In the Command Line Parameters field, enter the
service name (without spaces) that you want passed to the script, and
click OK."

No comments:

Post a Comment