public int getConnectionsCount(boolean onlyLocal) {
        int total = connectionsCounter.get();
        if (!onlyLocal) {
            Collection<Integer> results =
                    CacheFactory.doSynchronousClusterTask(new GetSessionsCountTask(false), false);
            for (Integer result : results) {
                if (result == null) {
                    continue;
                }
                total = total + result;
            }
        }
        return total;
    }
Returns number of client sessions that are connected to the server. Sessions that
are authenticated and not authenticated will be included

@param onlyLocal true if only sessions connected to this JVM will be considered. Otherwise count cluster wise.
@return number of client sessions that are connected to the server.
xmppserver/src/main/java/org/jivesoftware/openfire/SessionManager.java