You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tim Lucia <ti...@yahoo.com> on 2007/07/02 04:06:59 UTC

RE: Tomcat Monitoring

> -----Original Message-----
> From: Angelov, Rossen [mailto:Rossen.Angelov@SourceMedia.com]
> Sent: Wednesday, June 27, 2007 12:56 PM
> To: Tomcat Users List
> Subject: Tomcat Monitoring
> 
> What is recommended for monitoring Tomcat? Or is there anything built in
> that can help monitoring the performance and the state of the thread
> pools?
> 
> More specifically, I'm trying to find a way to time how long it take
> from the moment a request was received and when the response was
> returned.

I have a suite of filters, one of which does exactly this.  Mixed in is a
display servlet which dumps out all requests, by URL including request
count, min, max and average request times.  PM me and I'll send it your way.

The main method looks like this, if you want to write your own:

    /**
     * Process the container's filter request.
     * @param request - Request object
     * @param response - response object
     * @param chain - next filter in the chain.
     */    
    public void doFilter(ServletRequest request, ServletResponse response,
                         FilterChain chain)
        throws IOException, ServletException 
    {
        hitCount++;
        HttpServletRequest httpRequest = (HttpServletRequest)request;
        final String context = httpRequest.getContextPath();
        String uri = httpRequest.getRequestURI();
        uri = uri.substring(context.length());

        URICount count = new URICount(uri, 1);
        synchronized (pages) {
            final int index = pages.indexOf(count);
            if (index < 0) { 
                pages.add(count);
            }
            else {
                count = (URICount)pages.get(index);
                count.increment();
            }
        }
        lastRequest = new Date();
        long t0 = System.currentTimeMillis();
        chain.doFilter(request, response);
        long t1 = System.currentTimeMillis();
        final long requestTime = t1-t0;
        count.addTotalTime(requestTime);
        processingTime += requestTime;
        maxProcessingTime = 
            (requestTime > maxProcessingTime ? requestTime :
maxProcessingTime);
        
        if (logger.isDebugEnabled()) {
            logger.debug(uri + " in " + (t1-t0) + " ms");
        }
    }

Tim



> 
> Thanks,
> Ross
> 
> "This communication is intended solely for the addressee and is
> confidential and not for third party unauthorized distribution"
> 
> ---------------------------------------------------------------------
> 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




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