Commit a53d644f authored by Florian Fittkau's avatar Florian Fittkau

using sigar for cpu util

parent 1d497c2b
......@@ -9,6 +9,7 @@
<classpathentry kind="lib" path="lib/activemq-broker-5.9.1.jar"/>
<classpathentry kind="lib" path="lib/aspectjweaver-1.8.5.jar"/>
<classpathentry kind="lib" path="lib/disruptor-3.3.0.jar"/>
<classpathentry kind="lib" path="lib/sigar.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/common-monitoring"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/slf4j-api-1.7.5.jar"/>
......
......@@ -74,6 +74,7 @@
<zipfileset excludes="META-INF/*.SF" src="lib/aspectjweaver-1.8.5.jar"/>
<zipfileset excludes="META-INF/*.SF" src="lib/slf4j-api-1.7.5.jar"/>
<zipfileset excludes="META-INF/*.SF" src="lib/disruptor-3.3.0.jar"/>
<zipfileset excludes="META-INF/*.SF" src="lib/sigar.jar"/>
<!-- <zipfileset excludes="META-INF/*.SF" src="lib/hsqldb-2.3.1.jar"/> -->
<!-- <zipfileset excludes="META-INF/*.SF" src="lib/servlet-api-3.0.jar"/> -->
</jar>
......@@ -100,6 +101,7 @@
<zipfileset excludes="META-INF/*.SF" src="${build.dir}/explorviz-common.jar"/>
<zipfileset excludes="META-INF/*.SF" src="lib/slf4j-api-1.7.5.jar"/>
<zipfileset excludes="META-INF/*.SF" src="lib/disruptor-3.3.0.jar"/>
<zipfileset excludes="META-INF/*.SF" src="lib/sigar.jar"/>
</jar>
</target>
......
File added
......@@ -31,7 +31,7 @@ public abstract class AbstractAspect {
private static final ThreadLocalLastSendingTime lastSendingTime = new ThreadLocalLastSendingTime();
private static final AdaptiveMonitoring adaptiveMonitoring = new AdaptiveMonitoring();
@Pointcut("!within(explorviz..*) && !within(com.lmax..*)")
@Pointcut("!within(explorviz..*) && !within(com.lmax..*) && !within(org.hyperic.sigar..*)")
public void notWithinExplorViz() {
}
......@@ -56,7 +56,7 @@ public abstract class AbstractAspect {
AfterFailedOperationEventRecord.CLAZZ_ID,
AfterOperationEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID,
AfterOperationEventRecord.CLAZZ_ID, System.identityHashCode(thisObject), thisObject
.getClass().getName(), getInterface(thisJoinPoint));
.getClass().getName(), getInterface(thisJoinPoint));
}
@Around("monitoredOperation() && !this(java.lang.Object) && notWithinExplorViz()")
......@@ -73,7 +73,7 @@ public abstract class AbstractAspect {
AfterFailedStaticOperationEventRecord.CLAZZ_ID,
AfterStaticOperationEventRecord.COMPRESSED_BYTE_LENGTH_WITH_CLAZZ_ID,
AfterStaticOperationEventRecord.CLAZZ_ID, 0, thisJoinPoint.getSignature()
.getDeclaringTypeName(), getInterface(thisJoinPoint));
.getDeclaringTypeName(), getInterface(thisJoinPoint));
}
@Around("monitoredConstructor() && this(thisObject) && notWithinExplorViz()")
......@@ -118,7 +118,7 @@ public abstract class AbstractAspect {
final int beforeLength, final byte beforeId, final int afterFailedLength,
final byte afterFailedId, final int afterLength, final byte afterId,
final int objectId, final String clazz, final String implementedInterface)
throws Throwable {
throws Throwable {
final ByteBuffer buffer = bufferStore.get();
final ProbeTraceMetaData trace = TraceRegistry.getTrace();
......
......@@ -27,11 +27,11 @@ public class SystemMonitor {
@Override
public void run() {
try {
final double cpuUtil = SystemMonitorProbe.getSystemCpuLoad();
final double cpuUtil = SystemMonitorSigarProbe.getSystemCpuLoad();
if (cpuUtil >= 0) { // fixes -1 bug in first seconds
final SystemMonitoringRecord record = new SystemMonitoringRecord(cpuUtil,
SystemMonitorProbe.getUsedPhysicalMemorySize(), SystemMonitorProbe
.getTotalPhysicalMemorySize(), null);
.getTotalPhysicalMemorySize(), null);
MonitoringController.sendOutSystemRecord(record);
}
} catch (final Exception e) {
......
package explorviz.live_trace_processing.system_mon;
import org.hyperic.sigar.CpuPerc;
import org.hyperic.sigar.Mem;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
public class SystemMonitorSigarProbe {
private final static Sigar sigar = new Sigar();
public static double getSystemCpuLoad() {
CpuPerc cpu = null;
try {
cpu = sigar.getCpuPerc();
} catch (final SigarException se) {
se.printStackTrace();
}
return cpu.getCombined();
}
public static long getTotalPhysicalMemorySize() {
Mem mem = null;
try {
mem = sigar.getMem();
} catch (final SigarException se) {
se.printStackTrace();
}
return mem.getTotal();
}
public static long getFreePhysicalMemorySize() {
Mem mem = null;
try {
mem = sigar.getMem();
} catch (final SigarException se) {
se.printStackTrace();
}
return mem.getFree();
}
public static long getUsedPhysicalMemorySize() {
Mem mem = null;
try {
mem = sigar.getMem();
} catch (final SigarException se) {
se.printStackTrace();
}
return mem.getUsed();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment