Wily Introscope - Portal Manager - How many users are on my site?
Over the past few weeks I have been working with Wily Portal Manager for IBM WebSphere Portal, If you don't know what Introscope is by wily and you develop or host Java applications then you probably have no insight into your JVM at all. Go to http://www.wilytech.com and get on board with the products they have to get the visibility into the JVM you wish you had! They really do have a great product and one of the leaders in this space. For a quick background on the Portal Manager it is basically another plug in to the base Introscope software (10 minutes and a restart and your collecting your portal servers metrics.
I wanted to be able to get an approximate number of users logged into the site at any give time. I noticed a few people in the community were looking for this as well. My main problem was how do you know when someone is off the site. Well for this I am going to assume a few users click the logout button but the rest are going to have a session timeout.
With that in mind I started hunting around the IBM site for login and logout API's. I didn't find much but I did find this link especially useful.
http://www-1.ibm.com/support/docview.wss?uid=swg21104482&aid=3
It talks all about the login and logout functionality of portal. Since the Portal Manager already handles logins for me I decided to just use what they already have instrumented. Logout was the issue, especially for the users who do not click the logout button. From the doc above and the javadoc as well as some help from a wily utility 'PBD_Builder' I saw that com.ibm.wps.engine.commands.LogoutUser handles the timeouts of sessions as well as if the user clicks the logout button.
Note in my basic portal application I do not override the login and logout functionality. If you do you'll need to customize this a bit more.
So all I need to do now is count the number of users logged in and subtract the users that logged out and I'll get the estimated number of users on the site!
For the logged in users I'm just going to use a SimpleIncrementor:
TraceOneMethodOfClass: com.ibm.wps.engine.commands.LoginUserAuth doAuthenticate SimpleIncrementor "WebSphere PortalAuthenticationLogin:Total Count"
For the logged out users I will use a Simple SimpleDecrementor:
TraceOneMethodOfClass: com.ibm.wps.engine.commands.LogoutUser execute SimpleDecrementor "WebSphere PortalAuthenticationLogout:Negative Total count"
Note I am writing these to different places as I have other things I'm going to be doing with them but you could write them to the same place like Login:Total Users or something to that effect.
What I do now is create a metric group with both metrics Login:Total Count and Logout: Negative Total Count and use a sum calculator to get the Estimated number of users on the system.
Mileage may very!