Meaningless Drivel is fun!*
The moose likes Tomcat and the fly likes check whether the Tomcat server is up and running Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "check whether the Tomcat server is up and running " Watch "check whether the Tomcat server is up and running " New topic
Author

check whether the Tomcat server is up and running

Chethan Sharma
Ranch Hand

Joined: Mar 22, 2006
Posts: 59
Hi,

Availability to check whether the Tomcat server is up and running all the time. Please let me know how to know the server availability: listening to Tomcat server port periodically (configured in crontab) and send out notification when there is no response on the port.


Thanks,


chaithu
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Since you've mentioned crontab, I assume you want to do this on a Unix/Linux based system.
Are you familiar with wget and the mail program?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Chethan Sharma
Ranch Hand

Joined: Mar 22, 2006
Posts: 59
Hi Ben,

Thanks for the reply.

test.sh
======
1) ps -ef | grep java

root 3231 1 0 04:57:06 pts/13 1:41 /usr/jdk/j2sdk1.4.2_09/bin/java -Xms256m -Xmx512m -Djava.endorsed.dirs=/space/n

2) If server is running the above line will be displayed. So I will check whether the above line is displaying or not, otherwise I will send mail
using

Mail login-name@hostname

Crontab
=======
Here i will call test.sh for every second.

I am not sure whether this is the right way or not.

So only I Posted this question to the forum.
Is there any other way to find whether the tomcat server is running or
not on Linux.
[ December 20, 2006: Message edited by: Chethan Sharma ]
Chethan Sharma
Ranch Hand

Joined: Mar 22, 2006
Posts: 59
Hi Ben,

Thanks for the reply.

test.sh
======
1) ps -ef | grep java

root 3231 1 0 04:57:06 pts/13 1:41 /usr/jdk/j2sdk1.4.2_09/bin/java -Xms256m -Xmx512m -Djava.endorsed.dirs=/space/n

2) If server is running the above line will be displayed. So I will check whether the above line is displaying or not, otherwise I will send mail
using

Mail login-name@hostname

Crontab
=======
Here i will call test.sh for every second.

I am not sure whether this is the right way or not.

So only I Posted this question to the forum.
Is there any other way to find whether the tomcat server is running or
not on linux.

Thanks,
[ December 20, 2006: Message edited by: Chethan Sharma ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I was picturing using wget (tool for pulling web content from the command line) to hit a servlet or JSP running under tomcat, capturing stderr, and piping it into the mail command.... or something like that.

This would tell you, not only if there is a java process but that Tomcat is running properly and that the app in question is running.... at least well enough to respond.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: check whether the Tomcat server is up and running