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

Posted on 2006-06-07
Last Modified: 2010-08-05
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.

Question by:Simon336697
    LVL 29

    Expert Comment

    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.
    LVL 29

    Accepted Solution

    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 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

    *** End of script ***


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Suggested Solutions

    I've always wanted to allow a user to have a printer no matter where they login. The steps below will show you how to achieve just that. In this Article I'll show how to deploy printers automatically with group policy and then using security fil…
    On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now