cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Current Active Users List

TomU
23-Emerald IV

Current Active Users List

Does anyone have a way of determining the currently active users in Windchill?

Site --> Utilities --> Server Status --> Current Active Users will list the number of active users, so there must be some way to get this information.

Query builder?

Direct database access?

Log file parsing?

This discussion said to look at ptcstatus, but that only works if the users are running Creo. Users connected thru a stand-alone browser session won't pull any licenses.

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
jessh
5-Regular Member
(To:BenPerry)

A comment: I'd general tend to avoid or at least minimize and localize changes to out-of-the-box JSP pages.

You could always create your own page for such a list and add a link to it here if you felt it was necessary.

Also, I should mention that this information is already present in the page resulting from clicking on any of the server manager links in this page. There's a lot of other information present as well, of course, but this information is in there.

View solution in original post

8 REPLIES 8
BenPerry
13-Aquamarine
(To:TomU)

I updated http://communities.ptc.com/thread/52807. I am interested to see if it works for you.

jessh
5-Regular Member
(To:TomU)

As alluded to by Ben, this is exposed via JMX.

The TotalActiveUsers attribute of the com.ptc -> Monitors -> ActiveUsers MBean provides what you're looking for.

And I'd note that the implementation of the server status page is entirely in the JSP itself, so you can see how it does things as needed.

BenPerry
13-Aquamarine
(To:jessh)

Jess,

You got me thinking. Below is a screenshot of a customized <WT_HOME>/codebase/wtcore/jsp/jmx/serverStatus.jsp file.

CAUTION:

I have done this on a test site thus far. I have not done any types of verifications. Also, I'm just a beginner. I appreciate any corrections to the procedure below.

NOTE:

When modifying /codebase files, reference the Windchill Customization Guide with respect to the wtSafeArea.

1. Open serverStatus.jsp.

2. Find

Integer activeUsers = null;

Below that, add a line to instantiate an array for the active users.

String[] activeUserArray = null;

3. Find

activeUsers = (Integer) mbeanServer.getAttribute( activeUsersMBeanName, "TotalActiveUserCount" );

Below that, add a line to populate the activeUserArray variable.

activeUserArray = (String[]) mbeanServer.getAttribute( activeUsersMBeanName, "TotalActiveUsers" );

4. Might need or desire to add an entry to the catch block for activeUserArray.

5. Add the display of the variable anywhere in the page. Look for the screenshot as to where I added it. Code for my addition of the variable to the page is listed below. I looked for

decimalFormat.format( activeUsers )

and added another <tr>below the existing one to show a list of the users. This is probably not the best location to add it because a large list would push all of the stats down the page. The best location to render this on the page is probably at the bottom of the page. But this just serves as proof of concept at this point.

<tr>

<td colspan=3>

<%

int i=0;

for (i=0;i<activeUserArray.length;i++) {

out.print(activeUserArray[i] + "<br />");

}

%>

</td>

</tr>

ss.png

jessh
5-Regular Member
(To:BenPerry)

A comment: I'd general tend to avoid or at least minimize and localize changes to out-of-the-box JSP pages.

You could always create your own page for such a list and add a link to it here if you felt it was necessary.

Also, I should mention that this information is already present in the page resulting from clicking on any of the server manager links in this page. There's a lot of other information present as well, of course, but this information is in there.

BenPerry
13-Aquamarine
(To:jessh)

Jess,

Thanks for the insight. You could not click on that in 9.1, but you can in 10.?. This is very useful and provides the information that we request without customization.

Screenshots of OOTB solution:

ss1.png

ss2.png

jessh
5-Regular Member
(To:BenPerry)

This link and the similar links for method servers will show you all the JMX MBeans and their attributes as you'd see them in JConsole or VisualVM -- except via HTML and all in one report.

As you note there's a downside to the "all at once" nature of this output, but the upside is that its all there and you can scroll around and/or use the browser's find to search out all kinds of information. Also at the top of this report there is a high-level summary and a table of contents (very similar to JConsole or VisualVM's MBean tree) with links to each MBean's details.

What this doesn't give you, of course, is MBean action/operations. For those you need to actually use JConsole or VisualVM.

TomU
23-Emerald IV
(To:jessh)

Sure enough, it's in there. Didn't notice that before.

It would be slick to add the list below the chart when following the "Current Active Users" link.

Thanks guys!

BenPerry
13-Aquamarine
(To:TomU)

FYI...

I have modified my customization. I have been doing a lot of restarting of my 10.2 test system and did not want to keep clicking into Master Server Manager hyperlink, and do a Find for "ActiveUsers". Too many clicks. I decided to implement my customization for good, so that I can simply navigate to http://<host>/Windchill/wtcore/jsp/jmx/serverStatus.jsp and immediately see who is using Windchill. A benefit is that this URL is bookmarkable, whereas the URL to the Master Server Manager is not.

Futhermore, I decided to take things a step further and return the email address of the users currently using Windchill. That way I can copy and paste into the TO field of an email if I need to send them an email for some reason.

Modified Procedure for customizing the <WT_HOME>/codebase/wtcore/jsp/jmx/serverStatus.jsp file:

CAUTION:

I have done this on a test site thus far. I have not done any types of verifications. Also, I'm just a beginner. I appreciate any corrections to the procedure below.

NOTE:

When modifying /codebase files, reference the Windchill Customization Guide with respect to the wtSafeArea.

1. Open the <WT_HOME>/wtSafeArea/siteMod/... .../serverStatus.jsp file in a text editor. Per the Customization Guide, use wtSafeArea instead of modifying the file in /codebase directly. There is a command that will copy the modified file in the proper location in /codebase.

2. Find

Integer activeUsers = null;

Below that, add 2 lines to instantiate 2 arrays for the active users.

String[] activeUserArray = null;

String[] activeUserArrayEmails = null;

3. Find

activeUsers = (Integer) mbeanServer.getAttribute( activeUsersMBeanName, "TotalActiveUserCount" );

Below that, add some lines to populate the activeUserArray and activeUserArrayEmails arrays.

activeUserArray = (String[]) mbeanServer.getAttribute( activeUsersMBeanName, "TotalActiveUsers" );

activeUserArrayEmails = new String[activeUserArray.length];

for (int z=0; z<activeUserArray.length; z++) {

wt.org.WTUser user;

wt.query.QuerySpec qspec=new wt.query.QuerySpec(wt.org.WTUser.class);

qspec.appendWhere(new wt.query.SearchCondition(wt.org.WTUser.class,wt.org.WTUser.NAME,wt.query.SearchCondition.LIKE,activeUserArray[z],false),new int[]{0});

wt.fc.QueryResult qresult=wt.fc.PersistenceHelper.manager.find((wt.pds.StatementSpec)qspec);

while(qresult.hasMoreElements()){

user=(wt.org.WTUser) qresult.nextElement();

activeUserArrayEmails[z]=user.getEMail();

}

}

4. You might need or desire to add an entry to the catch block for activeUserArray and/or activeUserArrayEmails.

5. Add the display of the variable anywhere in the page. Look for the screenshot as to where I added it. Code for my addition of the variables is listed below. I added it as the last table on the page, right before the closing </body> and </html> tags.

<%= MBeanUtilities.formatMessage( RB.getString( serverStatusResource.DATA_COLLECTED_BETWEEN_MSG ),

dateFormat.format( new Date( dataCollectionStart ) ),

dateFormat.format( new Date( dataCollectionEnd ) ) ) %>

</i>

</td>

</tr>

</tbody>

</table>

<%-- Custom table for displaying usernames --%>

<table>

<tbody>

<tr>

<td>

<b>Ben's list of all Active Users:</b>

</td>

</tr>

<tr>

<td>

<%

int i=0;

for (i=0;i<activeUserArray.length;i++) {

out.print(activeUserArray[i] + "<br />");

}

%>

</td>

<td>

<%

int j=0;

for (j=0;j<activeUserArrayEmails.length;j++) {

out.print(activeUserArrayEmails[j] + "<br />");

}

%>

</td>

</tr>

</tbody>

</table>

</body>

</html>

serverStatus.png

Top Tags