public List<StoreIncomingStatisticsElement> processNonHeapMemory(String line) { List<StoreIncomingStatisticsElement> statList = new ArrayList<StoreIncomingStatisticsElement>(); String[] params = line.split(DELIMETER); String agentName; String maxMem; String usedMem; String commitedMem; String initMem; String timestampStr; if (params.length == 6) { agentName = params[0]; maxMem = params[1]; usedMem = params[2]; commitedMem = params[3]; initMem = params[4]; timestampStr = params[5]; Long timeperiod = 0l; try { timeperiod = Long.parseLong(timestampStr); timeperiod = ((long) (timeperiod / 15000)); // Round down to nearest 15 second period 00, 15, 30, 45 } catch (NumberFormatException nfe) { log.error("Unable to read in timestamp"); } StoreIncomingStatisticsElement initElem = new StoreIncomingStatisticsElement(); initElem.setGuiPath(agentName + ":Memory:NonHeap:Init"); initElem.setTimeperiod(timeperiod); initElem.setValue(initMem); initElem.setUnitType(UnitType.N.value()); initElem.setValueType(ValueType.VALUE.value()); statList.add(initElem); StoreIncomingStatisticsElement maxElem = new StoreIncomingStatisticsElement(); maxElem.setGuiPath(agentName + ":Memory:NonHeap:Max"); maxElem.setTimeperiod(timeperiod); maxElem.setValue(maxMem); maxElem.setUnitType(UnitType.N.value()); maxElem.setValueType(ValueType.VALUE.value()); statList.add(maxElem); StoreIncomingStatisticsElement usedElem = new StoreIncomingStatisticsElement(); usedElem.setGuiPath(agentName + ":Memory:NonHeap:Used"); usedElem.setTimeperiod(timeperiod); usedElem.setValue(usedMem); usedElem.setUnitType(UnitType.N.value()); usedElem.setValueType(ValueType.VALUE.value()); statList.add(usedElem); StoreIncomingStatisticsElement commitedElem = new StoreIncomingStatisticsElement(); commitedElem.setGuiPath(agentName + ":Memory:NonHeap:Committed"); commitedElem.setTimeperiod(timeperiod); commitedElem.setValue(commitedMem); commitedElem.setUnitType(UnitType.N.value()); commitedElem.setValueType(ValueType.VALUE.value()); statList.add(commitedElem); } return statList; }
public List<StoreIncomingStatisticsElement> processThreads(String line) { List<StoreIncomingStatisticsElement> statList = new ArrayList<StoreIncomingStatisticsElement>(); String[] params = line.split(DELIMETER); String agentName; String threadCount; String peakThreadCount; String totatStartedThreads; String timestampStr; if (params.length == 5) { agentName = params[0]; threadCount = params[1]; peakThreadCount = params[2]; totatStartedThreads = params[3]; timestampStr = params[4]; Long timeperiod = 0l; try { timeperiod = Long.parseLong(timestampStr); timeperiod = ((long) (timeperiod / 15000)); // Round down to nearest 15 second period 00, 15, 30, 45 } catch (NumberFormatException nfe) { log.error("Unable to read in timestamp"); } StoreIncomingStatisticsElement maxElem = new StoreIncomingStatisticsElement(); maxElem.setGuiPath(agentName + ":Threads:ThreadCount"); maxElem.setTimeperiod(timeperiod); maxElem.setValue(threadCount); maxElem.setUnitType(UnitType.N.value()); maxElem.setValueType(ValueType.VALUE.value()); statList.add(maxElem); StoreIncomingStatisticsElement usedElem = new StoreIncomingStatisticsElement(); usedElem.setGuiPath(agentName + ":Threads:PeakThreadCount"); usedElem.setTimeperiod(timeperiod); usedElem.setValue(peakThreadCount); usedElem.setUnitType(UnitType.N.value()); usedElem.setValueType(ValueType.VALUE.value()); statList.add(usedElem); StoreIncomingStatisticsElement commitedElem = new StoreIncomingStatisticsElement(); commitedElem.setGuiPath(agentName + ":Threads:TotalStartedThreads"); commitedElem.setTimeperiod(timeperiod); commitedElem.setValue(totatStartedThreads); commitedElem.setUnitType(UnitType.N.value()); commitedElem.setValueType(ValueType.VALUE.value()); statList.add(commitedElem); } return statList; }
public List<StoreIncomingStatisticsElement> processGCTime(String line) { List<StoreIncomingStatisticsElement> statList = new ArrayList<StoreIncomingStatisticsElement>(); String[] params = line.split(DELIMETER); String agentName; // String gcCountStr; String gcTimeStr; // String msTimeStr; String timestampStr; if (params.length == 3) { agentName = params[0]; // gcCountStr = params[1]; gcTimeStr = params[1]; // msTimeStr = params[3]; timestampStr = params[2]; Long timeperiod = 0l; try { timeperiod = Long.parseLong(timestampStr); timeperiod = ((long) (timeperiod / 15000)); // Round down to nearest 15 second period 00, 15, 30, 45 } catch (NumberFormatException nfe) { log.error("Unable to read in timestamp"); } StoreIncomingStatisticsElement commitedElem = new StoreIncomingStatisticsElement(); commitedElem.setGuiPath(agentName + ":Memory:GC:Time Spent In GC(%)"); commitedElem.setTimeperiod(timeperiod); commitedElem.setValue(gcTimeStr); commitedElem.setUnitType(UnitType.N.value()); commitedElem.setValueType(ValueType.VALUE.value()); statList.add(commitedElem); } return statList; }
@Override public List<LiveStatistics> getLiveStatistics( String guiPath, String accountName, Long minTimeperiod, Long maxTimeperiod) { Long fromHoursSince1970 = minTimeperiod / 240; Long toHoursSince1970 = maxTimeperiod / 240; List<LiveStatistics> retList = new ArrayList<LiveStatistics>(); for (Long index = fromHoursSince1970; index <= toHoursSince1970; index++) { BasicMetricHour metricHour = getMetricHour(accountName, guiPath, index); if (metricHour == null) { metricHour = new BasicMetricHour( guiPath, accountName, index, ValueType.VALUE.value(), UnitType.N.value()); } // If this is the first hour, start from the correct 15-second timeslot within the hour Integer minTimeperiodWithinTheHour = 0; if (index.longValue() == fromHoursSince1970.longValue()) { minTimeperiodWithinTheHour = LiveStatisticsUtil.getFifteensecondTimeperiodsSinceStartOfHour(minTimeperiod * 15); } // If this is the last hour, end with the correct 15-second timeslot within the hour Integer maxTimeperiodWithinTheHour = null; if (index.longValue() == toHoursSince1970.longValue()) { maxTimeperiodWithinTheHour = LiveStatisticsUtil.getFifteensecondTimeperiodsSinceStartOfHour(maxTimeperiod * 15); } retList.addAll( createLivestatisticsFromMetricHour( metricHour, minTimeperiodWithinTheHour, maxTimeperiodWithinTheHour, index)); } return retList; }
public List<StoreIncomingStatisticsElement> processThreadsLiveByType(String line) { List<StoreIncomingStatisticsElement> statList = new ArrayList<StoreIncomingStatisticsElement>(); // JSFlotAgent;java.lang.Thread;0;1272306420000 String[] params = line.split(DELIMETER); String agentName; String threadname; String threadCount; String timestampStr; if (params.length == 4) { agentName = params[0]; threadname = params[1]; threadCount = params[2]; timestampStr = params[3]; Long timeperiod = 0l; try { timeperiod = Long.parseLong(timestampStr); timeperiod = ((long) (timeperiod / 15000)); // Round down to nearest 15 second period 00, 15, 30, 45 } catch (NumberFormatException nfe) { log.error("Unable to read in timestamp"); } StringBuilder sb = new StringBuilder(); sb.append(agentName).append(":Threads:").append(threadname).append(":ThreadCount"); StoreIncomingStatisticsElement maxElem = new StoreIncomingStatisticsElement(); maxElem.setGuiPath(sb.toString()); maxElem.setTimeperiod(timeperiod); maxElem.setValue(threadCount); maxElem.setUnitType(UnitType.N.value()); maxElem.setValueType(ValueType.VALUE.value()); statList.add(maxElem); } return statList; }
public List<StoreIncomingStatisticsElement> processBtraceProfiling(String line) { List<StoreIncomingStatisticsElement> statList = new ArrayList<StoreIncomingStatisticsElement>(); // agentname package.Class method timeperiod exectime guiPath String[] params = line.split(DELIMETER); String agentName; String className; String methodName; Long timeperiod; String invocations; String totalSelftime; String avgSelftime; String minSelftime; String maxSelftime; String totalWalltime; String avgWalltime; String minWalltime; String maxWalltime; String guiPath = null; if (params.length >= 13 && !line.contains("N/A")) { if (params.length == 13) { guiPath = "Custom"; } if (params.length == 14) { guiPath = params[13]; } if (guiPath != null && guiPath.length() > 0) { agentName = params[0]; className = params[1]; methodName = params[2]; String timestampStr = params[3]; timeperiod = 0l; try { timeperiod = Long.parseLong(timestampStr); timeperiod = ((long) (timeperiod / 15000)); } catch (NumberFormatException nfe) { log.error("Unable to read in timestamp"); } invocations = params[4]; totalSelftime = params[5]; avgSelftime = params[6]; minSelftime = params[7]; maxSelftime = params[8]; totalWalltime = params[9]; avgWalltime = params[10]; minWalltime = params[11]; maxWalltime = params[12]; StringBuilder sb = new StringBuilder(); sb.append(agentName) .append(":") .append(guiPath) .append(":") .append(className) .append(":") .append(methodName); StoreIncomingStatisticsElement statElem = new StoreIncomingStatisticsElement(); statElem.setGuiPath(sb.toString() + ":Calls Per Interval"); statElem.setTimeperiod(timeperiod); statElem.setValue(invocations); statElem.setUnitType(UnitType.N.value()); statElem.setValueType(ValueType.AGGREGATE.value()); statList.add(statElem); StoreIncomingStatisticsElement statElem2 = new StoreIncomingStatisticsElement(); statElem2.setGuiPath(sb.toString() + ":Total Selftime"); statElem2.setTimeperiod(timeperiod); statElem2.setValue(totalSelftime); statElem2.setUnitType(UnitType.NS.value()); statElem2.setValueType(ValueType.AGGREGATE.value()); statList.add(statElem2); StoreIncomingStatisticsElement statElem3 = new StoreIncomingStatisticsElement(); statElem3.setGuiPath(sb.toString() + ":Average Selftime"); statElem3.setTimeperiod(timeperiod); statElem3.setValue(avgSelftime); statElem3.setUnitType(UnitType.NS.value()); statElem3.setValueType(ValueType.AVERAGE.value()); statList.add(statElem3); StoreIncomingStatisticsElement statElem4 = new StoreIncomingStatisticsElement(); statElem4.setGuiPath(sb.toString() + ":Max Selftime"); statElem4.setTimeperiod(timeperiod); statElem4.setValue(maxSelftime); statElem4.setUnitType(UnitType.NS.value()); statElem4.setValueType(ValueType.VALUE.value()); statList.add(statElem4); StoreIncomingStatisticsElement statElem5 = new StoreIncomingStatisticsElement(); statElem5.setGuiPath(sb.toString() + ":Min Selftime"); statElem5.setTimeperiod(timeperiod); statElem5.setValue(minSelftime); statElem5.setUnitType(UnitType.NS.value()); statElem5.setValueType(ValueType.VALUE.value()); statList.add(statElem5); StoreIncomingStatisticsElement statElem6 = new StoreIncomingStatisticsElement(); statElem6.setGuiPath(sb.toString() + ":Total Walltime"); statElem6.setTimeperiod(timeperiod); statElem6.setValue(totalWalltime); statElem6.setUnitType(UnitType.NS.value()); statElem6.setValueType(ValueType.AGGREGATE.value()); statList.add(statElem6); StoreIncomingStatisticsElement statElem7 = new StoreIncomingStatisticsElement(); statElem7.setGuiPath(sb.toString() + ":Avgerage Walltime"); statElem7.setTimeperiod(timeperiod); statElem7.setValue(avgWalltime); statElem7.setUnitType(UnitType.NS.value()); statElem7.setValueType(ValueType.AVERAGE.value()); statList.add(statElem7); StoreIncomingStatisticsElement statElem8 = new StoreIncomingStatisticsElement(); statElem8.setGuiPath(sb.toString() + ":Max Walltime"); statElem8.setTimeperiod(timeperiod); statElem8.setValue(maxWalltime); statElem8.setUnitType(UnitType.NS.value()); statElem8.setValueType(ValueType.VALUE.value()); statList.add(statElem8); StoreIncomingStatisticsElement statElem9 = new StoreIncomingStatisticsElement(); statElem9.setGuiPath(sb.toString() + ":Min Walltime"); statElem9.setTimeperiod(timeperiod); statElem9.setValue(minWalltime); statElem9.setUnitType(UnitType.NS.value()); statElem9.setValueType(ValueType.VALUE.value()); statList.add(statElem9); } } return statList; }
@Test public void testStoringMetricHour() { DateTime fromDate = new DateTime(2012, 04, 18, 9, 0, 0); DateTime toDate = new DateTime(2012, 04, 18, 12, 0, 0); // DateTime fromDate = new DateTime(2010, 01, 01, 0, 0, 0); // DateTime toDate = new DateTime(2010, 12, 31, 23, 59, 59); Long from15SecPeriod = fromDate.getMillis() / 15000; Long to15SecPeriod = toDate.getMillis() / 15000; long numMetrics = to15SecPeriod - from15SecPeriod; long index = 0; while (index <= numMetrics) { for (int i = 0; i < 100; i++) { List<LiveStatistics> liveStatisticsList = new ArrayList<LiveStatistics>(); liveStatisticsList.add( new TestLiveStatistics( "EurekaJAgent:Memory:Heap:Used" + i, "ACCOUNT NAME", from15SecPeriod + index, new Double(index), ValueType.AGGREGATE.value(), UnitType.N.value())); newEnv.getLiveStatissticsDao().storeIncomingStatistics(liveStatisticsList); } if (index > 0 && index % 500 == 0) { logger.info( "stored 500 keys for: " + index + " 15 second time periods. Now at: " + index + " of " + numMetrics + " hours"); } index++; } try { Thread.sleep(15000); } catch (InterruptedException e) { e .printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } System.out.println("Stored " + index + " values in the database"); int expectedNumMetrics = (4 * 60 * 3) + 1; // 3 hours worth of metrics // expectedNumMetrics = (4 * 60 * 24 * 365); //31 days worth of metrics List<LiveStatistics> statList = newEnv .getLiveStatissticsDao() .getLiveStatistics("Test:A", "ACCOUNT NAME", from15SecPeriod, to15SecPeriod); Assert.assertEquals( "Expecting " + expectedNumMetrics + " LiveStatistcs back from DB", expectedNumMetrics, statList.size()); // newEnv.getLiveStatissticsDao().deleteLiveStatisticsOlderThan(new DateTime(2010, 12, 14, 23, // 59, 59).toDate(), "ACCOUNT NAME"); // newEnv.getLiveStatissticsDao().markLiveStatisticsAsCalculated("Test:A", "ACCOUNT NAME", // from15SecPeriod, to15SecPeriod); // newEnv.getLiveStatissticsDao().deleteMarkedLiveStatistics(); /*statList = newEnv.getLiveStatissticsDao().getLiveStatistics("Test:A", "ACCOUNT NAME", from15SecPeriod, to15SecPeriod); for (LiveStatistics stat : statList) { printStat(stat); Assert.assertNull("Expecting that value is NULL for timeperiod: " + stat.getTimeperiod(), stat.getValue()); }*/ }