use of com.creditease.agent.helpers.jvmtool.JVMAgentInfo in project uavstack by uavorg.
the class JVMLocalOSDetector method run.
@Override
public void run() {
/**
* step 1: build the skip local attach support set which contains those jvm with management.jar attached
*/
Set<String> skipLocalAttachSupportSet = new HashSet<String>();
for (JVMAgentInfo agentInfo : jvmAgentInfos.values()) {
skipLocalAttachSupportSet.add(agentInfo.getId());
}
/**
* step 2: scan out all java processes
*/
List<JVMAgentInfo> appServerJVMInfos = JVMToolHelper.getAllLocalJvmInfo(new JVMPropertyFilter() {
@Override
public boolean isMatchAgentProperties(Properties jvmProperties) {
/**
* exclude all java tools
*/
Enumeration<?> e = jvmProperties.propertyNames();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
String val = jvmProperties.getProperty(key);
for (String t : excludeJavaProc) {
if (val.indexOf(t) > -1) {
return false;
}
}
}
return true;
}
@Override
public boolean isMatchSystemProperties(Properties systemProperties) {
return true;
}
}, true, skipLocalAttachSupportSet);
if (appServerJVMInfos.isEmpty()) {
return;
}
/**
* step 3: see if need start a new worker to catch data for each JVM
*/
for (JVMAgentInfo appServerInfo : appServerJVMInfos) {
try {
addWorker(appServerInfo);
} catch (Exception e) {
log.err(this, "JVMLocalOSDetector[" + this.cName + "] start worker FAIL: java process id=" + appServerInfo.getId(), e);
}
}
}
use of com.creditease.agent.helpers.jvmtool.JVMAgentInfo in project uavstack by uavorg.
the class JVMToolHelper method getLocalJvmInfo.
public static JVMAgentInfo getLocalJvmInfo(String procId, boolean needLocalAttachSupport) {
if (procId == null || "".equals(procId)) {
return null;
}
initJVMToolJarClassLoader();
try {
Object vm = method_AttachToVM.invoke(null, procId);
if (vm != null) {
if (needLocalAttachSupport) {
startVMAgent(vm);
}
Properties jvmProperties = (Properties) method_GetAgentProperties.invoke(vm, (Object[]) null);
// system properties
Properties systemProperties = (Properties) method_GetSystemProperties.invoke(vm, (Object[]) null);
method_DetachFromVM.invoke(vm);
return new JVMAgentInfo(procId, jvmProperties, systemProperties);
}
} catch (Exception e) {
// ignore
}
return null;
}
use of com.creditease.agent.helpers.jvmtool.JVMAgentInfo in project uavstack by uavorg.
the class JVMToolHelper method getAllLocalJvmInfo.
public static List<JVMAgentInfo> getAllLocalJvmInfo(JVMPropertyFilter filter, boolean needLocalAttachSupport, Set<String> skipLocalAttachSupport) {
if (!isOracleJVM()) {
return Collections.emptyList();
}
List<JVMAgentInfo> jvmPropertiesList = new ArrayList<JVMAgentInfo>();
try {
initJVMToolJarClassLoader();
@SuppressWarnings("rawtypes") List allVMs = (List) method_VMList.invoke(null, (Object[]) null);
getAllVMsInfo(filter, needLocalAttachSupport, jvmPropertiesList, allVMs, skipLocalAttachSupport);
} catch (Exception e) {
// ignore
}
return jvmPropertiesList;
}
use of com.creditease.agent.helpers.jvmtool.JVMAgentInfo in project uavstack by uavorg.
the class JVMContainerOSDetector method workerExist.
/**
* check if the worker for this appServer exist
*/
public boolean workerExist(String pid, String url, List<String> urlList) {
String JVMAccessURL = url + UAV_MOF_ROOT;
for (BaseMonitorDataCatchWorker worker : workers.values()) {
JVMAgentInfo appServerInfo = jvmAgentInfos.get(worker.getWorkerId());
if (appServerInfo != null && JVMAccessURL.equals((appServerInfo.getJVMAccessURL()))) {
urlList.clear();
if (!pid.equals(appServerInfo.getId())) {
// remove worker whose JVMAccessURL is the same but pid changes(usually restart)
removeWorker(worker.getName());
urlList.add(url);
}
return true;
}
}
urlList.add(url);
return false;
}
use of com.creditease.agent.helpers.jvmtool.JVMAgentInfo in project uavstack by uavorg.
the class LogProfileDataNotifyHandler method handle.
@Override
public void handle(MonitorDataFrame profileData) {
/**
* find out the logagent feature component and exchange the MDF
*/
AgentFeatureComponent afc = (AgentFeatureComponent) this.getConfigManager().getComponent("logagent", "LogAgent");
/**
* NOTEļ¼both JMX and Http Scan supported
*/
DetectorManager asmd = (DetectorManager) this.getConfigManager().getComponent(this.feature, "AppServerMonitorDetector_TimerWorker");
if (null != afc && null != asmd) {
JVMAgentInfo jvmAgentInfo = asmd.getJVMAgentInfo(profileData.getServerId());
if (null == jvmAgentInfo) {
log.warn(this, "can't find jvm agent info for serverid [" + profileData.getServerId() + "], the jvm may be dead.");
return;
}
afc.exchange("logagent.profiledata.notify", profileData, jvmAgentInfo);
} else {
log.warn(this, "can't find agent feature component [logagent], this feature may not start. LogAgent-null(" + (afc == null) + "), DetectorManager-null(" + (asmd == null) + ")");
}
}
Aggregations