tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ziggy <zigg...@gmail.com>
Subject Re: Accessing context information remotely - Context.getAvailable() etc.
Date Thu, 06 Jan 2011 18:48:32 GMT
Hi,

Thanks for your response. I am aware of the activeSessions attribute under
"Catalina:type=Manager,path=/testapp,host=localhost". I am actually doing
this programmatically and would like to know of an Mbean that would tell me
if the application is available. The activeSessions attribute can sometimes
report 0 even when the application is available so it is not reliable.

Thanks

On Thu, Jan 6, 2011 at 6:29 PM, Pid <pid@pidster.com> wrote:

> On 1/6/11 6:07 PM, Ziggy wrote:
> > I was looking at the code for the Tomcat Manager application to try and
> find
> > out how it is determining whether a webapp/context is running and how
> many
> > sesions are active. Looking at the code i think it uses these two methods
> >
> > Context.getAvailalbe() //check if available
> > Context.getManager().findSessions().length // Number of sessions.
> >
> > Here is the relevant function
> >
> >    protected void list(PrintWriter writer) {
> >
> >         if (debug >= 1)
> >             log("list: Listing contexts for virtual host '" +
> >                 host.getName() + "'");
> >
> >         writer.println(sm.getString("managerServlet.listed",
> >                                     host.getName()));
> >         Container[] contexts = host.findChildren();
> >         for (int i = 0; i < contexts.length; i++) {
> >             Context context = (Context) contexts[i];
> >             String displayPath = context.getPath();
> >             if( displayPath.equals("") )
> >                 displayPath = "/";
> >             if (context != null ) {
> >                 if (context.getAvailable()) {
> >
> writer.println(sm.getString("managerServlet.listitem",
> >                                                 displayPath,
> >                                                 "running",
> >                                       "" +
> > context.getManager().findSessions().length,
> >                                                 context.getDocBase()));
> >                 } else {
> >
> writer.println(sm.getString("managerServlet.listitem",
> >                                                 displayPath,
> >                                                 "stopped",
> >                                                 "0",
> >                                                 context.getDocBase()));
> >                 }
> >             }
> >         }
> >     }
> >
> > I was looking at the above for the above information as i am working on a
> > client tool that tries to find out this exact information. The tool i am
> > using connects to Tomcat via JMX but i am not sure if i can get the same
> > information via JMX. Can i access the Context class? or is there any
> other
> > way (Mbeans?) i can check if a context is running via JMX?
>
> Connect to a Tomcat instance using JConsole and look for the 'Manager'
> objects.
>
>  Catalina:type=Manager,path=/app01,host=localhost
>
> There's an attribute 'activeSessions'.
>
>
> p
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message