• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

Setting up an alert for no connectivity through to an ftp address

Hi guys!

We have a situation where we would like to trigger an email alert to an administrator whenever a server loses connectivity to an ftp address.
The server is running Windows 2003 Server.
Just wondering if you guys know of anything that we may be able to do in order to trigger an email alert, say, if the ftp address cannot be pinged for 15 minutes for example.


Thanks guys.

Simon
0
Simon336697
Asked:
Simon336697
  • 2
1 Solution
 
mass2612Commented:
hi Simon,

I have a vbscript that will ping a list of servers and e-mail if the ping fails. Its set to run every 20 minutes via a scheduled task. I don't have access to it at the moment but should be able to post a copy tomorrow.
0
 
mass2612Commented:
Here you go.

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

Some of the lines may have wrapped here due to length. 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 smtpserver.company.com line and the to, from support@company.com lines.

CMD file
cscript.exe pingservers.vbs

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))
      Else
      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
            Else
            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 = "support@company.com"
                  objMessage.From = "support@company.com"
                  objMessage.To = "support@company.com"
                  objMessage.TextBody = strPingOut
                  objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
                  'SMTP Server
                  objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpserver.company.com"
                  'SMTP Port
                  objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
                  objMessage.Configuration.Fields.Update
                  objMessage.Send
                  Else
                  'Don't really need to do anything... maybe write a log file?
                  WScript.Echo strServer & " ping response OK"
            End If
            End If
      End If
Loop
'Cleanup vars
Set objShell = Nothing
Set objMessage = Nothing

*** End of script ***

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now