vm.loadAgent(agent, "com.sun.management.jmxremote"); } catch (AgentLoadException x) { throw new IOException(x.getMessage(), x);
private void attachAgent(final String targetJvmPid, final String agentJarPath, final String cfg) throws Exception { VirtualMachine vmObj = null; try { vmObj = VirtualMachine.attach(targetJvmPid); if (vmObj != null) { vmObj.loadAgent(agentJarPath, cfg); } } finally { if (null != vmObj) { vmObj.detach(); } } }
vm.loadAgent(agentPath, "com.sun.management.jmxremote");
public static JMXServiceURL extractJMXServiceURLFromPid(String pid) throws IOException { try { VirtualMachine vm = VirtualMachine.attach(pid); try { String connectorAddress = vm.getAgentProperties().getProperty(CONNECTOR_ADDRESS); if (connectorAddress == null) { String agent = vm.getSystemProperties().getProperty("java.home") + File.separator + "lib" + File.separator + "management-agent.jar"; vm.loadAgent(agent); connectorAddress = vm.getAgentProperties().getProperty(CONNECTOR_ADDRESS); } return new JMXServiceURL(connectorAddress); } finally { vm.detach(); } } catch(Exception e) { throw new IOException(e); } }
vm.loadAgent(agentPath, "com.sun.management.jmxremote"); } catch (AgentLoadException x) { IOException ioe = new IOException(x.getMessage());
String pid = nameOfRunningVM.substring(0, nameOfRunningVM.indexOf('@')); VirtualMachine vm = VirtualMachine.attach(pid); vm.loadAgent(agentJar.getAbsolutePath(), null); vm.detach();
String pid = nameOfRunningVM.substring(0, nameOfRunningVM.indexOf('@')); VirtualMachine vm = VirtualMachine.attach(pid); vm.loadAgent(agentJar.getAbsolutePath(), null); vm.detach();
vm.loadAgent(createJar().getAbsolutePath()); synchronized(SelfAttacher.class) { while(BACK_LINK==null) SelfAttacher.class.wait();
try vm.loadAgent(agent, "com.sun.management.jmxremote");
debugPrint("agent args: " + agentArgs); vm.loadAgent(agentPath, agentArgs); if (debug) { debugPrint("loaded " + agentPath);
String agentJAR = "myAgent.jar"; VirtualMachine vm = VirtualMachine.attach (processid); vm.loadAgent(agentJAR);
public static void loadAgent() { logger.info("dynamically loading javaagent"); String nameOfRunningVM = ManagementFactory.getRuntimeMXBean().getName(); int p = nameOfRunningVM.indexOf('@'); String pid = nameOfRunningVM.substring(0, p); try { VirtualMachine vm = VirtualMachine.attach(pid); vm.loadAgent(jarFilePath, ""); vm.detach(); } catch (Exception e) { throw new RuntimeException(e); } }
vm.loadAgent(agent, "com.sun.management.jmxremote"); } catch (AgentLoadException x) { throw new IOException(x.getMessage(), x);
final VirtualMachine vm = VirtualMachine.attach("" + pid); log.log(Level.INFO, "Loading agent with command " + options + " as agent " + agentFile.getCanonicalPath()); vm.loadAgent(agentFile.getCanonicalPath(), options); server.accept(); shell = server.getShell(); String options = sb.toString(); log.log(Level.INFO, "Loading agent with command " + options + " as agent " + agentFile.getCanonicalPath()); vm.loadAgent(agentFile.getCanonicalPath(), options);
public static void attachGivenAgentToThisVM(String pathToAgentJar) { try { String nameOfRunningVM = ManagementFactory.getRuntimeMXBean().getName(); String pid = nameOfRunningVM.substring(0, nameOfRunningVM.indexOf('@')); VirtualMachine vm = VirtualMachine.attach(pid); vm.loadAgent(pathToAgentJar, ""); vm.detach(); } catch (Exception e) { e.printStackTrace(); } }
private synchronized void loadAgent(String jarPath, String arg) throws Exception { if (!attached) { this.attach(); } vm.loadAgent(jarPath, arg); agentedJars.add(jarPath); }
String name = ... List vms = VirtualMachine.list(); for (VirtualMachineDescriptor vmd: vms) { if (vmd.displayName().equals(name)) { VirtualMachine vm = VirtualMachine.attach(vmd.id()); String agent = ... vm.loadAgent(agent); // ... } }
String name = ... List vms = VirtualMachine.list(); for (VirtualMachineDescriptor vmd: vms) { if (vmd.displayName().equals(name)) { VirtualMachine vm = VirtualMachine.attach(vmd.id()); String agent = ... vm.loadAgent(agent); // ... } }
public static void attach(String pid, String agentArgs) throws AttachNotSupportedException, IOException, AgentLoadException, AgentInitializationException { Log.warn("attach to pid:" + pid); vm = VirtualMachine.attach(pid); Log.warn("successed attach to pid:" + pid + ",vm:" + vm); File path = new File(InspectAttacher.class.getProtectionDomain().getCodeSource().getLocation().getFile()); Log.warn("loadAgent from:" + path); vm.loadAgent(path.getAbsolutePath(), agentArgs); Log.warn("successed loadAgent from:" + path); vm.detach(); }