aspose file tools*
The moose likes Tomcat and the fly likes Active session count per server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Active session count per server " Watch "Active session count per server " New topic
Author

Active session count per server

Abhishek Rath
Ranch Hand

Joined: Nov 22, 2007
Posts: 38
Hi

We have a distributed Web application deployed in Tomact server.We are trying to find out the no of active session per server for a given period of time.
Could you please let me know if we can find it out by using some tool or by programatically..

Regards
Abhishek Rath
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 501
    
    5
Option 1: Using JMX
- Start Tomcat with its JMX agent enabled
- Use jconsole to connect to Tomcat over JMX. The "Catalina/Manager" JMX object will give you active sessions for each webapp.
- If you want it programmatically, write a JMX client

Option 2: Write a custom HttpSessionListener and implement your own session count logging.

In my opinion, option 1 is better for you because you can use the same client to query all your servers and aggregate the data.

Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 501
    
    5
Update: Just struck me that if you're already running a production cluster, then it's likely you're already using a system monitoring tool like collectd / nagios / ganglia, etc.
If so, they will very likely have plugins to get JMX data and graph it (I know for sure that collectd does...google says ganglia and nagios can too).
Abhishek Rath
Ranch Hand

Joined: Nov 22, 2007
Posts: 38
Hi Karthik

Thanks a lot for the info.I have another query.In our case many web applications are deployed in each server.So does JMX+Jconsole provide the count per server or per web apps?


Regards
Abhishek Rath
Abhishek Rath
Ranch Hand

Joined: Nov 22, 2007
Posts: 38
Hi Karthik

I will get the information about the monitoring tools being used in prod.I know App Dynamics is being used in the production.

Regards
Abhishek Rath

Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 501
    
    5
Abhishek Rath wrote:In our case many web applications are deployed in each server.So does JMX+Jconsole provide the count per server or per web apps

Each tomcat has 1 JMX agent running, which provides session counts for every individual webapp running in that tomcat instance.
Try out with jconsole - you'll understand easily. It'll show a node under Manager for each webapp, and each node reports an 'activeSession' variable.

Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
PSI-Probe is awesome for such tasks: http://code.google.com/p/psi-probe/
Abhishek Rath
Ranch Hand

Joined: Nov 22, 2007
Posts: 38
Hi Karthik Shiraly

I checked the J Console UI and please see the attached screen shot for the active session.Could you please check and let me know If I am referring to the correct path or not.

Regards
Abhishek Rath


[Thumbnail for active_session_Jconsole.JPG]

Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 501
    
    5
Yes, that's the one. Your screenshot is showing for /manager webapp; similarly, every other webapp will have its own activesession counter.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Active session count per server