tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <ma...@apache.org>
Subject Re: Would like to monitor memory use offline
Date Sun, 03 Aug 2008 10:34:15 GMT
Richard S. Huntrods wrote:
> SO - my question - is there a relatively easy way to create something 
> (say a servlet) to watch the stack *just like I can do manually using 
> the manager application* but email me when the stack approaches the 
> memory limits?

Richard,

Tomcat is open source so if you want to copy something Tomcat is doing all 
you need to do is look at the Tomcat source and copy it. Granted it can be 
a bit impenetrable in places but I don't think this is one of them.

1. You know from the manager page what URL you are interested in.
2. The web.xml for the manager app will tell you which servlet is serving 
that URL.
3. The Tomcat 6 source is in a single tree under 
http://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk/java/ so finding the 
class is easy.
4. A quick look at the doGet() method in that class points you towards 
StatusTransformer.writeVMState()
5. And there you have your answer - a simple API call.
http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html#freeMemory()

For the e-mail side, take a look at the JavaMail example in the JNDI docs. 
http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html

Mark



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message