[jboss-user] [Tomcat, HTTPD, Servlets & JSP] - How to reliably count active sessions

mrgordonz do-not-reply at jboss.com
Mon Aug 18 21:22:26 EDT 2008

Hi JBoss gurus,

I would like to reliably monitor the number of active sessions for a particular web application deployed on JBoss 4.0.5 (server is Windows Server 2003).

Initially I looked around for monitoring tools (eg: Hyperic) which would do all this for me, but alas they all seemed to monitor everything EXCEPT active sessions for a particular web app.  But I did find one (AdventNet Application Manager) which does the next best thing (for my purposes) - it will execute a script and monitor the output of the script.

For example, say I have a script called sessions.bat, and when it is executed it will (somehow) output the number of sessions to a log file, sessions.log.  Sample log file contents might be:


AdventNet Application Manager will execute the script at a desired interval (say every 15 minutes), and then read the contents of the resulting log file.  I can even specify that it needs to look for the string "active_sessions", and monitor the corresponding numeric value (it even creates pretty graphs for me!).

BUT - I need a script which will output the number of active sessions.

I have done a bunch of searching, and posted on other forums, and so far the consensus seems to be I need to write my own class which implements HttpSessionListener, and have a couple of methods to monitor when sessions are created and destroyed, and tally the session count somehow.  I'm a pretty mediocre Java programmer, so I hunted around for some code which kind of seems to do the trick, but in my testing I found that the session count wasn't accurate (for details see http://forums.sun.com/thread.jspa?messageID=10387351).

One person suggested I have a look at the "JBoss Management Console" (http://my-server:8180/web-console/), 

anonymous wrote : ...then in the console function tree find: Monitoring - > Web Status -> Full Status.
  | You will get a page with loads of stats on the right side.
  | Find [Application list] and link to your application, simply click on it and at the top of the page you will see all the stats that you need...

I had a look at this and it looks perfect.  But my question is this:  how can I get that info (Active sessions , Session count , Max active sessions, Rejected session creations, Expired sessions , Longest session alive time , Average session alive time) into a log file?  Where does JBoss store this info?  Or if it isn't stored anywhere (like a log file), is there some API which I can call which will return this info?  

Going back to my original approach of having a script (eg: sessions.bat) which is executed by the monitoring software, and the script writes the output to a log file (eg: sessions.log) which is read by the monitoring software - what would be the commands in the script to produce the desired output, eg:

  | session_count=672
  | max_active_sessions=82
  | rejected_session_creations=0
  | expired_sessions=637
  | longest_session_alive_time=6618
  | average_session_alive_time=1944

Please, please, someone tell me it is possible to get this information!


Paul Hobbs

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4171170#4171170

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4171170

More information about the jboss-user mailing list