protected String getStatsName(Stats stats) { String statsName = null; if (stats instanceof JMSProducerStats) { statsName = ((JMSProducerStats) stats).getDestination(); } if (stats instanceof JMSConsumerStats) { statsName = ((JMSConsumerStats) stats).getOrigin(); } if (stats instanceof JCAConnectionStats) { JCAConnectionStats jcaConnectionStats = (JCAConnectionStats) stats; if (StringUtils.isNotEmpty(jcaConnectionStats.getConnectionFactory())) { statsName = jcaConnectionStats.getConnectionFactory(); } else if (StringUtils.isNotEmpty(jcaConnectionStats.getManagedConnectionFactory())) { statsName = jcaConnectionStats.getManagedConnectionFactory(); } } if (stats instanceof JDBCConnectionStats) { statsName = ((JDBCConnectionStats) stats).getJdbcDataSource(); } return statsName; }
HashMap statsMap = new HashMap(); Stats stats = (Stats)mbServer.getAttribute(new ObjectName(objectName), "stats"); String[] sttsName = stats.getStatisticNames(); Statistic[] stts = stats.getStatistics(); for(int i = 0; i < sttsName.length; i++) { Statistic aStat = stats.getStatistic(sttsName[i]); if(aStat instanceof RangeStatistic) { Long current = new Long(((RangeStatistic)aStat).getCurrent()); Long high = new Long(((RangeStatistic)aStat).getHighWaterMark()); Long low = new Long(((RangeStatistic)aStat).getLowWaterMark()); statsMap.put(stts[i].getName() + " Current", current); statsMap.put(stts[i].getName() + " Max", high); statsMap.put(stts[i].getName() + " Min", low); } else if(aStat instanceof CountStatistic) { Long current = new Long(((CountStatistic)aStat).getCount()); statsMap.put(stts[i].getName(), current); } else if(aStat instanceof TimeStatistic) { Long current = new Long(((TimeStatistic)aStat).getCount()); Long max = new Long(((TimeStatistic)aStat).getMaxTime()); Long min = new Long(((TimeStatistic)aStat).getMinTime()); Long total = new Long(((TimeStatistic)aStat).getTotalTime()); statsMap.put(stts[i].getName() + " CurrentTime", current); statsMap.put(stts[i].getName() + " MaxTime", max); statsMap.put(stts[i].getName() + " MinTime", min); statsMap.put(stts[i].getName() + " TotalTime", total); } else {
Stats stats = (Stats) kernel.getAttribute(aname, STATS_ATTRIB); if (statisticsProvider.booleanValue() == true && (stats != null)) { String[] statisticNames = stats.getStatisticNames(); for (int i = 0; i < statisticNames.length; i++) { Statistic statistic = stats.getStatistic(statisticNames[i]); String name = statistic.getName(); mbeanStat.add(new String[] { "Name", name }); mbeanStat.add(new String[] { "Description", statistic.getDescription() }); mbeanStat.add(new String[] { "Unit", statistic.getUnit() }); Date startTime = new Date(statistic.getStartTime()); mbeanStat.add(new String[] { "Start Time", startTime.toString() }); Date lastSampleTime = new Date(statistic.getLastSampleTime()); mbeanStat.add(new String[] { "Last Sample Time", lastSampleTime.toString() }); long count = cStat.getCount(); mbeanStat.add(new String[] { "Count", Long.toString(count) }); } else if (statistic instanceof TimeStatistic) { TimeStatistic tStat = (TimeStatistic) statistic; long count = tStat.getCount(); mbeanStat.add(new String[] { "Count", Long.toString(count) }); String maxTime = TimeUtils.formatDuration(tStat.getMaxTime()); mbeanStat.add(new String[] { "Max Time", maxTime }); String minTime = TimeUtils.formatDuration(tStat.getMinTime()); mbeanStat.add(new String[] { "Min Time", minTime }); long totalTime = tStat.getTotalTime(); mbeanStat.add(new String[] { "Total Time", Long.toString(totalTime) }); } else if (statistic instanceof BoundedRangeStatistic) {
processAttrValue(snapshot, mbAttrInfo, propName.append("Name"), stat.getName()); processAttrValue(snapshot, mbAttrInfo, propName.append("Description"), stat.getDescription()); processAttrValue(snapshot, mbAttrInfo, propName.append("LastSampleTime"), stat.getLastSampleTime()); processAttrValue(snapshot, mbAttrInfo, propName.append("StartTime"), stat.getStartTime()); processAttrValue(snapshot, mbAttrInfo, propName.append("Unit"), stat.getUnit()); processAttrValue(snapshot, mbAttrInfo, propName.append("Count"), cs.getCount()); processAttrValue(snapshot, mbAttrInfo, propName.append("LowerBound"), bs.getLowerBound()); processAttrValue(snapshot, mbAttrInfo, propName.append("UpperBound"), bs.getUpperBound()); processAttrValue(snapshot, mbAttrInfo, propName.append("Current"), rs.getCurrent()); processAttrValue(snapshot, mbAttrInfo, propName.append("LowWaterMark"), rs.getLowWaterMark()); processAttrValue(snapshot, mbAttrInfo, propName.append("HighWaterMark"), rs.getHighWaterMark()); processAttrValue(snapshot, mbAttrInfo, propName.append("Count"), ts.getCount()); processAttrValue(snapshot, mbAttrInfo, propName.append("MaxTime"), ts.getMaxTime()); processAttrValue(snapshot, mbAttrInfo, propName.append("MinTime"), ts.getMinTime()); processAttrValue(snapshot, mbAttrInfo, propName.append("TotalTime"), ts.getTotalTime());
renderRequest.setAttribute("activeRequestCountCurrent", new Long(webStats.getActiveRequestCount().getCurrent())); renderRequest.setAttribute("activeRequestCountLow", new Long(webStats.getActiveRequestCount().getLowWaterMark())); renderRequest.setAttribute("activeRequestCountHigh", new Long(webStats.getActiveRequestCount().getHighWaterMark())); Long count = new Long(webStats.getRequestDuration().getCount()); Long totalTime = new Long(webStats.getRequestDuration().getTotalTime()); renderRequest.setAttribute("totalRequestCount", count); renderRequest.setAttribute("requestDurationMinTime", new Long(webStats.getRequestDuration().getMinTime())); renderRequest.setAttribute("requestDurationMaxTime", new Long(webStats.getRequestDuration().getMaxTime())); renderRequest.setAttribute("requestDurationTotalTime", totalTime); renderRequest.setAttribute("response1xx", Long.valueOf(webStats.getResponses1xx().getCount())); renderRequest.setAttribute("response2xx", Long.valueOf(webStats.getResponses2xx().getCount())); renderRequest.setAttribute("response3xx", Long.valueOf(webStats.getResponses3xx().getCount())); renderRequest.setAttribute("response4xx", Long.valueOf(webStats.getResponses4xx().getCount())); renderRequest.setAttribute("response5xx", Long.valueOf(webStats.getResponses5xx().getCount())); renderRequest.setAttribute("elapsedTime", TimeUtils.formatDuration(webStats.getStatsOnMs().getCount()));
try { Stats stats = (Stats)mbServer.getAttribute(new ObjectName(mbeanName), "stats"); String[] sttsName = stats.getStatisticNames(); Statistic[] stts = stats.getStatistics(); for(int i = 0; i < sttsName.length; i++) { Statistic aStat = stats.getStatistic(sttsName[i]); if(aStat instanceof RangeStatistic) { mbeanStatsList.add(stts[i].getName() + " Current"); mbeanStatsList.add(stts[i].getName() + " Max"); mbeanStatsList.add(stts[i].getName() + " Min"); } else if(aStat instanceof CountStatistic) { mbeanStatsList.add(stts[i].getName()); } else if(aStat instanceof TimeStatistic) { mbeanStatsList.add(stts[i].getName() + " CurrentTime"); mbeanStatsList.add(stts[i].getName() + " MaxTime"); mbeanStatsList.add(stts[i].getName() + " MinTime"); mbeanStatsList.add(stts[i].getName() + " TotalTime"); } else {
collectStats(jcaStats.getConnections(), snapshot, mbAttrInfo, statName); collectStats(jcaStats.getConnectionPools(), snapshot, mbAttrInfo, statName); collectStats(jmsSessionStats.getProducers(), snapshot, mbAttrInfo, statName); collectStats(jmsSessionStats.getConsumers(), snapshot, mbAttrInfo, statName); collectStats(jdbcStats.getConnections(), snapshot, mbAttrInfo, statName); collectStats(jdbcStats.getConnectionPools(), snapshot, mbAttrInfo, statName); collectStats(jmsConnectionStats.getSessions(), snapshot, mbAttrInfo, statName); collectStats(jmsStats.getConnections(), snapshot, mbAttrInfo, statName); Statistic[] statistics = stats.getStatistics(); for (Statistic statistic : statistics) { collectStatistic(statistic, snapshot, mbAttrInfo, statName);
public DynamicServerInfo getJavaVMStatistics() { HttpSession session = WebContextFactory.get().getSession(true); ManagementHelper helper = PortletManager.getManagementHelper(session); J2EEDomain[] domains = helper.getDomains(); J2EEServer[] servers = domains[0].getServerInstances(); JVM[] jvms = helper.getJavaVMs(servers[0]); long elapsed = System.currentTimeMillis() - jvms[0].getKernelBootTime().getTime(); if(jvms[0].isStatisticsProvider()) { JVMStats stats = (JVMStats) ((StatisticsProvider)jvms[0]).getStats(); BoundedRangeStatistic heap = stats.getHeapSize(); return new DynamicServerInfo(heap.getCurrent(), heap.getHighWaterMark(), heap.getUpperBound(), elapsed); } else { return new DynamicServerInfo(elapsed); } } }
public void renderView(RenderRequest request, RenderResponse response, MultiPageModel model) throws PortletException, IOException { AbstractName name = new AbstractName(URI.create(request.getParameter(ABSTRACT_NAME_PARAMETER))); StatisticsProvider pool = (StatisticsProvider) PortletManager.getManagedBean(request, name); ThreadPoolStats stats = (ThreadPoolStats) pool.getStats(); String[] consumers = stats.getThreadConsumers(); ClientStats[] result = new ClientStats[consumers.length]; for (int i = 0; i < result.length; i++) { result[i] = new ClientStats(consumers[i], (int)stats.getCountForConsumer(consumers[i]).getCount()); } request.setAttribute("poolName", name.getName().get(NameFactory.J2EE_NAME)); request.setAttribute("stats", stats); request.setAttribute("consumers", result); }
private void collectStatistic(Statistic statistic, PropertySnapshot snapshot, MBeanAttributeInfo mbAttrInfo, PropertyNameBuilder statName) { processAttrValue(snapshot, mbAttrInfo, statName.append(statistic.getName()), statistic); statName.popLevel(); }
HashMap<String, Long> statsMap = new HashMap<String, Long>(); Stats stats = (Stats)getMEJB().getAttribute(new ObjectName(objectName), "stats"); String[] sttsName = stats.getStatisticNames(); Statistic[] stts = stats.getStatistics(); for(int i = 0; i < sttsName.length; i++) { Statistic aStat = stats.getStatistic(sttsName[i]); if(aStat instanceof RangeStatistic) { Long current = new Long(((RangeStatistic)aStat).getCurrent()); Long high = new Long(((RangeStatistic)aStat).getHighWaterMark()); Long low = new Long(((RangeStatistic)aStat).getLowWaterMark()); statsMap.put(stts[i].getName() + " Current", current); statsMap.put(stts[i].getName() + " Max", high); statsMap.put(stts[i].getName() + " Min", low); } else if(aStat instanceof CountStatistic) { Long current = new Long(((CountStatistic)aStat).getCount()); statsMap.put(stts[i].getName(), current); } else if(aStat instanceof TimeStatistic) { Long current = new Long(((TimeStatistic)aStat).getCount()); Long max = new Long(((TimeStatistic)aStat).getMaxTime()); Long min = new Long(((TimeStatistic)aStat).getMinTime()); Long total = new Long(((TimeStatistic)aStat).getTotalTime()); statsMap.put(stts[i].getName() + " CurrentTime", current); statsMap.put(stts[i].getName() + " MaxTime", max); statsMap.put(stts[i].getName() + " MinTime", min); statsMap.put(stts[i].getName() + " TotalTime", total); } else {
try { Stats stats = (Stats)getMEJB().getAttribute(new ObjectName(mbeanName), "stats"); String[] sttsName = stats.getStatisticNames(); Statistic[] stts = stats.getStatistics(); for(int i = 0; i < sttsName.length; i++) { Statistic aStat = stats.getStatistic(sttsName[i]); if(aStat instanceof RangeStatistic) { mbeanStatsList.add(stts[i].getName() + " Current"); mbeanStatsList.add(stts[i].getName() + " Max"); mbeanStatsList.add(stts[i].getName() + " Min"); } else if(aStat instanceof CountStatistic) { mbeanStatsList.add(stts[i].getName()); } else if(aStat instanceof TimeStatistic) { mbeanStatsList.add(stts[i].getName() + " CurrentTime"); mbeanStatsList.add(stts[i].getName() + " MaxTime"); mbeanStatsList.add(stts[i].getName() + " MinTime"); mbeanStatsList.add(stts[i].getName() + " TotalTime"); } else {