0

I am using Windows 7, and I have a remote Linux machine that runs a Java application in Tomcat (on port 8080). Sometimes, the remote machine is up but Tomcat doesn't respond.

How can I code something that will check if it is up periodically (e.g. every 10 minutes) and somehow warn me?

2 Answers 2

1

Install curl

http://curl.haxx.se/download.html

Then you can use the curl command on your tomcat URL on port 8080 to see if it is working.

Or you can just use telnet server 8080.

1

I have developed a VBS script which you can schedule in Windows Scheduler to run in 10 minute intervals

The script when executed tries to connect to the URL given as its first argument. If it is not able to connect, it will popup a message box saying "Could not connect".

Here is the source code:

If WScript.Arguments.Count <> 1 then
  Wscript.Echo "Usage: CheckTomcat.vbs URL"
  wscript.Quit
End If 

URL = WScript.Arguments.Item(0)

Set Http = CreateObject("Microsoft.XmlHttp")
Http.open "GET", URL, FALSE

On Error Resume Next
Http.Send ""

If Err.Number <> 0 Then
    Wscript.Echo "Cannot connect to Tomcat at " & URL
    Wscript.Quit 1
End If

'WScript.Echo "Connection successful. Response Code is " & Http.Status

Set Http = nothing

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .