InstanceProfiler { InternalInstanceProfilingData generateProfilingData(long timestamp) throws ProfilingException { final long profilingInterval = timestamp - lastTimestamp; final InternalInstanceProfilingData profilingData = new InternalInstanceProfilingData( this.instanceConnectionInfo, (int) profilingInterval); updateCPUUtilization(profilingData); updateMemoryUtilization(profilingData); updateNetworkUtilization(profilingData); this.lastTimestamp = timestamp; return profilingData; } InstanceProfiler(InstanceConnectionInfo instanceConnectionInfo); InternalInstanceProfilingData generateCheckpointProfilingData();  }
@Test public void shouldHaveNetworkTraffic() { try { final InternalInstanceProfilingData generateProfilingData = out.generateProfilingData(0L); assertEquals(0L, generateProfilingData.getReceivedBytes()); assertEquals(0L, generateProfilingData.getTransmittedBytes()); } catch (ProfilingException e) { fail(e.getMessage()); } }
@Test public void shouldHaveMemSettingsMeasured() { try { final InternalInstanceProfilingData generateProfilingData = out.generateProfilingData(0L); final long totalMemory = generateProfilingData.getTotalMemory(); assertThat(totalMemory, is(equalTo(8052956L))); long freeMemory = generateProfilingData.getFreeMemory(); assertThat(freeMemory, is(equalTo(3999880L))); long buffers = generateProfilingData.getBufferedMemory(); assertThat(buffers, is(equalTo(77216L))); long cached = generateProfilingData.getCachedMemory(); assertThat(cached, is(equalTo(1929640L))); } catch (ProfilingException e) { fail(e.getMessage()); } }
@Test public void shouldMeasureCPUUtilization() { try { final InternalInstanceProfilingData generateProfilingData = out.generateProfilingData(0L); assertEquals(0L, generateProfilingData.getUserCPU()); assertEquals(0L, generateProfilingData.getIdleCPU()); assertEquals(0L, generateProfilingData.getSystemCPU()); assertEquals(0L, generateProfilingData.getHardIrqCPU()); assertEquals(0L, generateProfilingData.getSoftIrqCPU()); assertEquals(0L, generateProfilingData.getIOWaitCPU()); } catch (ProfilingException e) { fail(e.getMessage()); } }