WebManager[] managers = PortletManager.getCurrentServer(renderRequest).getWebManagers();
if (managers != null) {
WebManager manager = managers[0]; //todo: handle multiple
WebContainer[] containers = (WebContainer[]) manager.getContainers();
if (containers != null) {
WebContainer container = containers[0]; //todo: handle multiple
if(container.isStatisticsProvider()) {
WebContainerStats webStats = (WebContainerStats) ((StatisticsProvider)container).getStats();
if (webStats.isStatsOn()) {
renderRequest.setAttribute("statsOn", Boolean.TRUE);
renderRequest.setAttribute("totalRequestCount", new Long(webStats.getTotalRequestCount().getCount()));
renderRequest.setAttribute("totalConnectionCount", new Long(webStats.getTotalConnectionCount().getCount()));