How to reliably count active sessions (re-post)
mrgordonz Aug 21, 2008 8:25 AMHi JBoss gurus,
This is a slightly re-worded re-post (http://www.jboss.com/index.html?module=bb&op=viewtopic&t=140995) because I wasn't getting any replies.
I would like to reliably monitor the number of active sessions for a particular web application deployed on JBoss 4.0.5 (the server is Windows Server 2003; JDK is Sun 1.4.2_14). I didn't create the app - I simply provide hosting for a growing number of customers.
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:
active_sessions=65
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 most people have suggested that I need to write my own class which implements HttpSessionListener, and in the class I keep a running tally of sessions as they are created and destroyed.
However, one person suggested I have a look at the "JBoss Management Console" (http://my-server:8180/web-console/),
...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 has exactly the information I want - Active sessions , Session count , Max active sessions, Rejected session creations, Expired sessions , Longest session alive time , Average session alive time. But, how can I get that info into a log file (of my choosing)? According to the person who pointed me in the direction of the JBoss Management Console, this data is not stored anywhere (eg: a log file).
So the big question for me is how does JBoss get this information? Are there built-in APIs which are called by the Management Console? If so, is there some way I can call those APIs using a batch script or a custom class?
My ideal solution would be to have a very simple batch script which simply executes/calls a class (which will probably be one I have to write myself, or get help to write). That class then gets the info which is available in the Management Console, and pumps it into a log file in the following format:
active_sessions=35 session_count=672 max_active_sessions=82 rejected_session_creations=0 expired_sessions=637 longest_session_alive_time=6618 average_session_alive_time=1944
I have no idea if this is possible, but I am hoping like mad that it is. Please, please, someone tell me it is possible to get this information! Better yet, tell me not only it's possible, but how! :)
Cheers,
Paul Hobbs