Email Alert system for Win 2003 Server Crashes


Im after a way that I can recieve a email if certain servers in the domain crash. I thought their might be a program that simply ping's the servers periodically and emails you if the ping fails but I cant seem to find anything yet. Even an email alert when certain services stop running would be useful.

Does anyone know of a way to do this ?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


If you are interested in a simple vbs script to ping servers and email if they are down.

I run this using a scheduled task that run a cmd file every 20 minutes.

The input file is called servers.txt and contains the list of server hostnames or IP addresses you wish to ping.You need to updated the line and the to, from lines.

CMD file
cscript.exe pingservers.vbs

Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("WScript.Shell")
'Here you can set how many pings you want to send, and how long to wait for the response
pingNumber = 4
'note this is in milliseconds
timeOut = 10000
InputFile = "servers.txt"
Set objFile = objFSO.OpenTextFile(InputFile,1,FALSE)
Do Until objFile.AtEndOfStream
     strServer = objFile.ReadLine
     'Give the ability to comment out servers
     If Left(strServer,1) = "'" Then
          strSrvNameLen = Len(strServer)
          WScript.Echo "Skipping server " & Right(strServer,(strSrvNameLen - 1))
     WScript.Echo "Pinging " & strServer & "..."
     Set objPing = objShell.Exec ("ping " & strServer & " -n " & pingNumber &" -w " & timeOut)
     strPingOut = objPing.StdOut.ReadAll
     If (Split(strPingOut," ")(0)) = "Unknown" Then
          WScript.Echo strPingOut
          arrPingWholeReturn = Split(strPingOut,"Received")
          arrPingData = arrPingWholeReturn(1)
          arrPingResult = Split(arrPingData," ")
          If arrPingResult(2) = "0," Then
               'Box or network is dead - better tell someone
               WScript.Echo strServer & " - Ping timed out. Machine may be down."
               'Grab a reference to the email object
               Set objMessage = CreateObject("CDO.Message") 
               'Send an email with the results... self explanatory!
               objMessage.Subject = strServer & " - Ping timed out"
               objMessage.Sender = ""
               objMessage.From = ""
               objMessage.To = ""
               objMessage.TextBody = strPingOut
               objMessage.Configuration.Fields.Item ("") = 2 
               'SMTP Server
               objMessage.Configuration.Fields.Item ("") = ""
               'SMTP Port
               objMessage.Configuration.Fields.Item ("") = 25 
               'Don't really need to do anything... maybe write a log file?
               WScript.Echo strServer & " ping response OK"
          End If
          End If
     End If
'Cleanup vars
Set objShell = Nothing
Set objMessage = Nothing

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ACIARAuthor Commented:
Hello Mass2612,

A couple of questions if I was to use this approach. Im not so familiar with VB scripts so I need to clarify a few questions

* You have 3 different file names mentioned: server.txt || cscript.exe || pingservers.vbs - I think I name the text you provided above and name that pingservers.vbs. With the server.txt file I assume I have to put in the IP address's or Server hostnames - but in what format ??? And lastly what is the cscript.exe file for?

IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

You need to modify the code for the SMTP address info on lines 31, 32, 33 and 34 in the code above.

Aside from that its very simple. Create a directory to store the files i.e. C:\Script\Ping_Script.

Save the code above as a vbs file i.e. pingservers.vbs in C:\Script\Ping_Script.

Create a txt files called servers.txt in C:\Script\Ping_Script. The contents of servers.txt should just include either the hostnames or IP addresses of the servers/Ip's you wish to monitor (hostnames are best): -

Create a batch file or cmd file called pingservers.cmd in C:\Scripts\Ping_Script with the following command: -
cscript.exe pingservers.vbs

Setup a scheduled task to run C:\Scripts\Ping_Script\pingservers.cmd every so many minutes. We do this every 20 minutes so if a box goes down we get an email.

cscript.exe is the Windows executable for vbs scripts cscript runs in a command line mode wscript.exe runs in a Windows/GUI mode.
ACIARAuthor Commented:
Did you mean line 38 not line 34 ?
ACIARAuthor Commented:
Opps - "Did you mean line 38 not line 31"

I cant see what im meant to change on 31 ?
Forgot about line 38. You need to change that as well. You also need to change the email addresses: -
ACIARAuthor Commented:
Hello Mass2612 and tgtran,

I found a server monitoring program that meet my requirements however you have both helped me head in the right direction so ill award points between the 2 of you.

Thanks for the help and thanks Mass2612 for the effort on your part, I think I can also use your method aswell if I ever need to.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2003

From novice to tech pro — start learning today.