項目: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