Using cptool to get the number of active sessions per webserver is very useful when in the PD environment, but "cptool list sessions -c" is very slow. So I created a jsp page that can be placed in the luminis webapp's jsp directory which gives the same result by runs ten times faster. I've attached the file if you want to try it yourself.
Comments
This is really handy, just
This is really handy, just rolled it out in our Dev environment.
For Luminis 4?
I just tried this and get no errors, but I get 0. If I instead run "cptool list sessions -c" I get like 300...
Working now...
By commenting out this line: "sessions.remove((sessions.size() - 1));" It works now. Not sure what the intention was with that, but whatever... it works.
Beyond that hiccup, this is a hugely useful piece of data to have so quickly available. Plus it sure beats the heck out of "cptool list sessions -c"
sorry ...
Sorry about that. I put that line in to remove the resource tier webserver, in the PD environment which always has zero count of sessions
channel
To make this work, do I have to create an inline frame channel that calls the jsp file?
channel
To make this work, do I have to create an inline frame channel that calls the jsp file?
Nope
No you don't. All you need to do is place is in your $CP_DOC_ROOT/jsp directory.
For example, I created a directory under $CP_DOC_ROOT/jsp/misc called "ucd" which is our universities initials, and I placed the script there. So then you would go to the "http://your_portal_address/jsp/misc/ucd/listSessions.jsp" address to view it.
You don't need to be logged into luminis to see it
list sessions jsp
Very nice thank you.
Did you find some documentation on this class, or did you work with Sungard to get the methods, etc..?
documentation on classes and methods
yeah! where do you find documentation on classes and methods? I've looked hard and cannot find any.
documentation? Ha! Ha! :)
That is a funny one. No there was no documentation. I just figured it out via trial and error
documentation
I found some on http://pdf.moreservlets.com/
Access denied
After placing listSessions.jsp into $CP_DOC/ROOT/jsp/misc I get "Access denied" .
File has Read/Write/Execute permissions to public.
Login to your portal, then
Login to your portal, then try executing https://portalname.edu/jsp/misc/listSessions.jsp
If that doesn't work, checkout your $CP_WEBINF/config/websecure.xml file (search for jsp then search for misc) and see what the requirements are on the misc directory.
Or try moving it up a directory to the root jsp directory, just as a test.
System error
If I login to the portal I get the following error:
Can't service request to /jsp/misc/listSessions.jsp
Click here to go back to previous page.
/jsp/misc/listSessions.jsp(2,0) equal symbol expected
Can it be related to Java version?
i am getting the same error as well.
Hi,
Did you ever figure out what the issue was, I am getting the same error.
Thank you,
list sessions
I compared what is working for me from myportal.edu/jsp/pcc/sessions.jsp to what is attached up top, and its a bit different.
What works for me in production on Lum IV
<%@ page language="java" contentType="text/plain; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import="java.util.List"%><%@ page import="java.util.ListIterator"%> <%@ page import="com.pipeline.system.SessionLister"%> <%@ page import="com.pipeline.system.SessionsInfo"%> <% List sessions = SessionLister.getSessionsInfos(); int totalSessions = 0; ListIterator li = sessions.listIterator(); while (li.hasNext()) { SessionsInfo sess = (SessionsInfo) li.next(); String host = sess.getSourceHost(); String[] users = sess.getSessionUsers(); totalSessions = totalSessions + users.length; out.println("Active sessions on " + host + ": " + users.length); } out.println("\nTotal number of active sessions: " + totalSessions); %>At least when I click the jsp attached up top, it appears to have wrapped improperly. Oh right, look a few posts up. There are a couple lines that needed to be removed, which I did in the code I posted here. Just copy that into a file called whatever.jsp and it should work.
ListSession - Users?
This is working great. We wanted to extend it to list the users. It appears that getSessionUsers() returns an array of immutable IDs. How can I get the real username so that I can display a list like cptool list sessions does?
Thanks,
Paul
hi i am getting this error
Can't service request to /jsp/misc/listSessions.jsp
Click here to go back to previous page.
/jsp/misc/listSessions.jsp(2,0) equal symbol expected
Do you know what the issue might be?
Thank you
Validate login
Hey. Good script!
However, you might want to validate the user's login and/or add role checking to make sure only the people you want to see the information can see it (and to avoid a DOS attack as this script can use a non-negligible amount of resources). Right now, I can go to [portal URL]/jsp/misc/ucd/listSessions.jsp and view the sessions and such without being logged in. Just a word of advice.
Good point, you maybe don't
Good point, you maybe don't want that information exposed to everyone. The way I do it is I format it as an XML document (so I can request the data using a REST Web Service for integration with a custom admin interface I'm working on), but with a POST variable that will allow the data to be show. The reason I do this is I have a cron job running on another box which does the logging to a MySQL DB so we can see historical data.
The security isn't fool proof, but should stave off the majority of people lucky enough to workout the list sessions URL.
Paul