use of com.creditease.agent.helpers.jvmtool.JVMAgentInfo in project uavstack by uavorg.
the class JVMToolHelper method getAllVMsInfo.
/**
* @param filter
* @param needLocalAttachSupport
* @param jvmPropertiesList
* @param allVMs
*/
@SuppressWarnings("rawtypes")
private static void getAllVMsInfo(JVMPropertyFilter filter, boolean needLocalAttachSupport, List<JVMAgentInfo> jvmPropertiesList, List allVMs, Set<String> skipLocalAttachSupport) {
for (Object vmInstance : allVMs) {
/**
* now we only support 64bit JVM, in case the 32bit JVM is attached with exception
*/
try {
String id = (String) method_VMId.invoke(vmInstance, (Object[]) null);
// if the jvm is not started by the same user as MA, do not attach it (just in case of linux)
if (isLinux() && !username.equals(Files.getOwner(Paths.get(("/proc/" + id))).getName())) {
continue;
}
Object vm = method_AttachToVM.invoke(null, id);
if (vm == null) {
continue;
}
// agent properties
Properties jvmProperties = (Properties) method_GetAgentProperties.invoke(vm, (Object[]) null);
// system properties
Properties systemProperties = (Properties) method_GetSystemProperties.invoke(vm, (Object[]) null);
if (jvmProperties != null) {
if (filter != null && (!filter.isMatchAgentProperties(jvmProperties) || !filter.isMatchSystemProperties(systemProperties))) {
continue;
}
boolean isNeedLocalAttachSupport = needLocalAttachSupport;
if (skipLocalAttachSupport != null) {
isNeedLocalAttachSupport = (skipLocalAttachSupport.contains(id) == true) ? false : needLocalAttachSupport;
}
jvmProperties = fillJVMProperties(isNeedLocalAttachSupport, vm, jvmProperties);
jvmPropertiesList.add(new JVMAgentInfo(id, jvmProperties, systemProperties));
}
method_DetachFromVM.invoke(vm);
} catch (Exception e) {
// ignore
continue;
}
}
}
Aggregations