For monitoring of Alfresco we needed to somehow get a number of users currently logged in Alfresco. Here I’m showing how to easily get number of such users as well as list of usernames using simple webscript. This post is based on an answer by mrgrechkin on Alfresco forum.


Write a description file:

    Return json with stats for application
  <format default="json"/>

Webscript implementation:

public class GetStatistics extends AbstractWebScript
  private TicketComponent ticketComponent;

  public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
    JSONObject users = new JSONObject();
    JSONObject response = new JSONObject();

    users.put("online", getNumberOfUsersConnected());
    response.put("users", users);


   * Return approximate number of users, whose ticket didn't expired yet. 
   * By default alfresco ticket expires after one hour of user's inactivity
   * @return number of users who were connected less that one hour ago
  private int getNumberOfUsersConnected()
    Set<String> connectedUsers = ticketComponent.getUsersWithTickets(true);
    return connectedUsers.size();

And register webscript in your-app-context.xml:

<bean id=""

At the end after calling webscript’s URL: /alfresco/s/mycomp/api/getStatistics you’ll get this output:

  "users": {
    "online": 4
  "usernames": "[\"dduck\",\"mmouse\",\"pluto\",\"System\"]"

And in this post: REST call monitoring extension for AppDynamics you will now how to use this webscript as a metric provider for AppDynamics.