项目:JMX-SflowAgent停止从AspectJ的收集JVM度量仪表的WebSphere Application Server
我使用的sFlow +神经节来监视的WebSphere Application Server的JVM度量(WAS)。 WAS使用AspectJ方面进行检测。我添加了一个方面来衡量所有应用程序的运行时间。
我使用Hsflowd作为JVM度量收集器。 Hsflowd内部使用javaagent钩入JVM,以使用MXBeans(RuntimeMXBean,GarbageCollectorMXBean,CompilationMXBean和ThreadMXBean)收集指标。
问题:
当我运行是没有aspectjweaver钩我可以连续看在神经节网所有指标(CPU,书桌,内存,进程等)。但是,当aspectjweaver被添加到JVM参数中,并且在重新启动服务器之后,我可以看到10分钟的指标,但是之后它不会在Ganglia网站中报告JVM指标。
在Aspectj编织日志中,我可以看到AspectJ正在编织JMXsflowAgent代码。尽管它通过!call(* com.sflow.JMX.SFlowAgent(..))
被排除。
看点:
package com.foo.main;
import java.io.*;
import java.lang.reflect.Method;
import java.security.Signature;
import java.util.*;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.osgi.service.application.ApplicationAdminPermission;
@Aspect
public class ResponseTimeAspect {
@Pointcut(
"execution(* com.foo.*(..)) && " +
"!within(com.foo.main.ResponseTimeAspect) && " +
"!within(ThreadLocal+) && " +
"!within(&& !within(*..*Aspect)) && " +
"!within(com.foo.main.AppInformationReader) && " +
"!within(@org.aspectj.lang.annotation.Aspect *) && " +
"!within(com.sflow.jmx.SFlowAgent) && " +
"!(call(* com.sflow.jmx.SFlowAgent(..)))"
)
public void loggingResponseTime() {}
private static ThreadLocal<String> uuidContainer = new ThreadLocal<String>() {
@Override
protected String initialValue(){
return UUID.randomUUID().toString();
}
};
AppInformationReader logWriter = AppInformationReader.getInstance();
@Around("loggingResponseTime()")
public Object tracing(ProceedingJoinPoint thisJoinPoint) throws Throwable {
Long startTime= System.currentTimeMillis();
Long startTotalMemory = Runtime.getRuntime().totalMemory();
Long startFreeMemory = Runtime.getRuntime().freeMemory();
Object ret = thisJoinPoint.proceed();
Long elapsedTime=System.currentTimeMillis() - startTime;
Long endTotalMemory = Runtime.getRuntime().totalMemory();
Long endFreeMemory = Runtime.getRuntime().freeMemory();
String methodSignature=thisJoinPoint.getSignature().toString();
String classname=methodSignature.split("\\.")[thisJoinPoint.getSignature().toString().split("\\.").length-1];
String methodName =thisJoinPoint.getSignature().getDeclaringType().getCanonicalName();
logWriter.writeLog(uuidContainer.get().toString(), startTime, System.currentTimeMillis(), elapsedTime, classname, methodName);
return ret;
}
}
的JMX包com.sflow.jmx.SFlowAgent
下。
对于我们无法看到的AspectJ或Java代码以及我们无法看到的配置,我们有点难以说出任何智能。也许你想考虑提供更多的细节,因为这里没有人拥有魔幻水晶球。 – kriegaex 2014-09-13 09:27:30
@ Kriegaex-不需要进一步的配置..我认为JMX和AspectJ不能在我们的桌面上一起工作。 – 2014-09-16 08:24:40
他们为什么不应该? – kriegaex 2014-09-16 11:23:19