Java Code Examples for com.sun.tools.attach.VirtualMachine#getAgentProperties()
The following examples show how to use
com.sun.tools.attach.VirtualMachine#getAgentProperties() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalVirtualMachine.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private void loadManagementAgent() throws IOException { VirtualMachine vm = null; String name = String.valueOf(vmid); try { vm = VirtualMachine.attach(name); } catch (AttachNotSupportedException x) { IOException ioe = new IOException(x.getMessage()); ioe.initCause(x); throw ioe; } vm.startLocalManagementAgent(); // get the connector address Properties agentProps = vm.getAgentProperties(); address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); vm.detach(); }
Example 2
Source File: StartManagementAgent.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void testLocalAgent(VirtualMachine vm) throws Exception { Properties agentProps = vm.getAgentProperties(); String address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); if (address != null) { throw new Exception("Local management agent already started"); } String result = vm.startLocalManagementAgent(); // try to parse the return value as a JMXServiceURL new JMXServiceURL(result); agentProps = vm.getAgentProperties(); address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); if (address == null) { throw new Exception("Local management agent could not be started"); } }
Example 3
Source File: StartManagementAgent.java From hottub with GNU General Public License v2.0 | 6 votes |
public static void testLocalAgent(VirtualMachine vm) throws Exception { Properties agentProps = vm.getAgentProperties(); String address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); if (address != null) { throw new Exception("Local management agent already started"); } String result = vm.startLocalManagementAgent(); // try to parse the return value as a JMXServiceURL new JMXServiceURL(result); agentProps = vm.getAgentProperties(); address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); if (address == null) { throw new Exception("Local management agent could not be started"); } }
Example 4
Source File: LocalVirtualMachine.java From hottub with GNU General Public License v2.0 | 6 votes |
private void loadManagementAgent() throws IOException { VirtualMachine vm = null; String name = String.valueOf(vmid); try { vm = VirtualMachine.attach(name); } catch (AttachNotSupportedException x) { IOException ioe = new IOException(x.getMessage()); ioe.initCause(x); throw ioe; } vm.startLocalManagementAgent(); // get the connector address Properties agentProps = vm.getAgentProperties(); address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); vm.detach(); }
Example 5
Source File: StartManagementAgent.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void testLocalAgent(VirtualMachine vm) throws Exception { Properties agentProps = vm.getAgentProperties(); String address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); if (address != null) { throw new Exception("Local management agent already started"); } String result = vm.startLocalManagementAgent(); // try to parse the return value as a JMXServiceURL new JMXServiceURL(result); agentProps = vm.getAgentProperties(); address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); if (address == null) { throw new Exception("Local management agent could not be started"); } }
Example 6
Source File: LocalVirtualMachine.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private void loadManagementAgent() throws IOException { VirtualMachine vm = null; String name = String.valueOf(vmid); try { vm = VirtualMachine.attach(name); } catch (AttachNotSupportedException x) { IOException ioe = new IOException(x.getMessage()); ioe.initCause(x); throw ioe; } vm.startLocalManagementAgent(); // get the connector address Properties agentProps = vm.getAgentProperties(); address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); vm.detach(); }
Example 7
Source File: LocalVirtualMachine.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private void loadManagementAgent() throws IOException { VirtualMachine vm = null; String name = String.valueOf(vmid); try { vm = VirtualMachine.attach(name); } catch (AttachNotSupportedException x) { IOException ioe = new IOException(x.getMessage()); ioe.initCause(x); throw ioe; } vm.startLocalManagementAgent(); // get the connector address Properties agentProps = vm.getAgentProperties(); address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); vm.detach(); }
Example 8
Source File: LocalVirtualMachine.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private void loadManagementAgent() throws IOException { VirtualMachine vm = null; String name = String.valueOf(vmid); try { vm = VirtualMachine.attach(name); } catch (AttachNotSupportedException x) { IOException ioe = new IOException(x.getMessage()); ioe.initCause(x); throw ioe; } vm.startLocalManagementAgent(); // get the connector address Properties agentProps = vm.getAgentProperties(); address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); vm.detach(); }
Example 9
Source File: StartManagementAgent.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void testLocalAgent(VirtualMachine vm) throws Exception { Properties agentProps = vm.getAgentProperties(); String address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); if (address != null) { throw new Exception("Local management agent already started"); } String result = vm.startLocalManagementAgent(); // try to parse the return value as a JMXServiceURL new JMXServiceURL(result); agentProps = vm.getAgentProperties(); address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); if (address == null) { throw new Exception("Local management agent could not be started"); } }
Example 10
Source File: StartManagementAgent.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void testLocalAgent(VirtualMachine vm) throws Exception { Properties agentProps = vm.getAgentProperties(); String address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); if (address != null) { throw new Exception("Local management agent already started"); } String result = vm.startLocalManagementAgent(); // try to parse the return value as a JMXServiceURL new JMXServiceURL(result); agentProps = vm.getAgentProperties(); address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); if (address == null) { throw new Exception("Local management agent could not be started"); } }
Example 11
Source File: LocalVirtualMachine.java From jvmtop with GNU General Public License v2.0 | 6 votes |
public static LocalVirtualMachine getLocalVirtualMachine(int vmid) throws Exception { Map<Integer, LocalVirtualMachine> map = getAllVirtualMachines(); LocalVirtualMachine lvm = map.get(vmid); if (lvm == null) { // Check if the VM is attachable but not included in the list // if it's running with a different security context. // For example, Windows services running // local SYSTEM account are attachable if you have Adminstrator // privileges. boolean attachable = false; String address = null; String name = String.valueOf(vmid); // default display name to pid VirtualMachine vm = VirtualMachine.attach(name); attachable = true; Properties agentProps = vm.getAgentProperties(); address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); vm.detach(); lvm = new LocalVirtualMachine(vmid, name, attachable, address); } return lvm; }
Example 12
Source File: StartManagementAgent.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static void testLocalAgent(VirtualMachine vm) throws Exception { Properties agentProps = vm.getAgentProperties(); String address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); if (address != null) { throw new Exception("Local management agent already started"); } String result = vm.startLocalManagementAgent(); // try to parse the return value as a JMXServiceURL new JMXServiceURL(result); agentProps = vm.getAgentProperties(); address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); if (address == null) { throw new Exception("Local management agent could not be started"); } }
Example 13
Source File: LocalVirtualMachine.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private void loadManagementAgent() throws IOException { VirtualMachine vm = null; String name = String.valueOf(vmid); try { vm = VirtualMachine.attach(name); } catch (AttachNotSupportedException x) { IOException ioe = new IOException(x.getMessage()); ioe.initCause(x); throw ioe; } vm.startLocalManagementAgent(); // get the connector address Properties agentProps = vm.getAgentProperties(); address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); vm.detach(); }
Example 14
Source File: LocalVirtualMachine.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private void loadManagementAgent() throws IOException { VirtualMachine vm = null; String name = String.valueOf(vmid); try { vm = VirtualMachine.attach(name); } catch (AttachNotSupportedException x) { IOException ioe = new IOException(x.getMessage()); ioe.initCause(x); throw ioe; } vm.startLocalManagementAgent(); // get the connector address Properties agentProps = vm.getAgentProperties(); address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); vm.detach(); }
Example 15
Source File: LocalVirtualMachine.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
private void loadManagementAgent() throws IOException { VirtualMachine vm = null; String name = String.valueOf(vmid); try { vm = VirtualMachine.attach(name); } catch (AttachNotSupportedException x) { IOException ioe = new IOException(x.getMessage()); ioe.initCause(x); throw ioe; } vm.startLocalManagementAgent(); // get the connector address Properties agentProps = vm.getAgentProperties(); address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); vm.detach(); }
Example 16
Source File: StartManagementAgent.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void testLocalAgent(VirtualMachine vm) throws Exception { Properties agentProps = vm.getAgentProperties(); String address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); if (address != null) { throw new Exception("Local management agent already started"); } String result = vm.startLocalManagementAgent(); // try to parse the return value as a JMXServiceURL new JMXServiceURL(result); agentProps = vm.getAgentProperties(); address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); if (address == null) { throw new Exception("Local management agent could not be started"); } }
Example 17
Source File: StartManagementAgent.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public static void testLocalAgent(VirtualMachine vm) throws Exception { Properties agentProps = vm.getAgentProperties(); String address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); if (address != null) { throw new Exception("Local management agent already started"); } String result = vm.startLocalManagementAgent(); // try to parse the return value as a JMXServiceURL new JMXServiceURL(result); agentProps = vm.getAgentProperties(); address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); if (address == null) { throw new Exception("Local management agent could not be started"); } }
Example 18
Source File: StartManagementAgent.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public static void testLocalAgent(VirtualMachine vm) throws Exception { Properties agentProps = vm.getAgentProperties(); String address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); if (address != null) { throw new Exception("Local management agent already started"); } String result = vm.startLocalManagementAgent(); // try to parse the return value as a JMXServiceURL new JMXServiceURL(result); agentProps = vm.getAgentProperties(); address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP); if (address == null) { throw new Exception("Local management agent could not be started"); } }
Example 19
Source File: JVMTest.java From bistoury with GNU General Public License v3.0 | 5 votes |
public static void getVmInfo() throws Exception { VirtualMachine vm = VirtualMachine.attach(String.valueOf(10248)); // 获得连接地址 Properties properties = vm.getAgentProperties(); String address = (String) properties.get("com.sun.management.jmxremote.localConnectorAddress"); System.out.println(address); JMXServiceURL url = new JMXServiceURL(address); JMXConnector connector = JMXConnectorFactory.connect(url); RuntimeMXBean rmxb = ManagementFactory.newPlatformMXBeanProxy(connector.getMBeanServerConnection(), "java.lang:type=Runtime", RuntimeMXBean.class); MemoryMXBean memoryMXBean = ManagementFactory.newPlatformMXBeanProxy(connector.getMBeanServerConnection(), ManagementFactory.MEMORY_MXBEAN_NAME, MemoryMXBean.class); OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.newPlatformMXBeanProxy(connector.getMBeanServerConnection(), ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, OperatingSystemMXBean.class); System.out.println(operatingSystemMXBean.getSystemCpuLoad()); MemoryUsage memoryUsage = memoryMXBean.getHeapMemoryUsage(); Map<String, Object> result = new HashMap<>(); //堆提交内存 result.put("heapCommitedMemory", memoryUsage.getCommitted() / KB); //当前堆内存 result.put("heapUsedMemory", memoryUsage.getUsed() / KB); //最大堆大小 result.put("heapMaxMemory", memoryUsage.getMax() / KB); memoryUsage = memoryMXBean.getNonHeapMemoryUsage(); //非堆提交内存 result.put("nonHeapCommitedMemory", memoryUsage.getCommitted() / KB); //当前非堆内存 result.put("nonHeapUsedMemory", memoryUsage.getUsed() / KB); //最大非堆大小 result.put("nonHeapMaxMemory", memoryUsage.getMax() / KB); System.out.println(result); vm.detach(); }
Example 20
Source File: JCozServiceImpl.java From JCoz with GNU General Public License v3.0 | 5 votes |
@Override public int attachToProcess(int localProcessId) throws RemoteException { logger.info("Attaching to process {}", localProcessId); try { for (VirtualMachineDescriptor desc : VirtualMachine.list()) { if (Integer.parseInt(desc.id()) == localProcessId) { VirtualMachine vm = VirtualMachine.attach(desc); vm.startLocalManagementAgent(); Properties props = vm.getAgentProperties(); String connectorAddress = props .getProperty(CONNECTOR_ADDRESS_PROPERTY_KEY); JMXServiceURL url = new JMXServiceURL(connectorAddress); JMXConnector connector = JMXConnectorFactory.connect(url); MBeanServerConnection mbeanConn = connector .getMBeanServerConnection(); attachedVMs.put(localProcessId, JMX.newMXBeanProxy(mbeanConn, JCozProfiler.getMBeanName(), JCozProfilerMBean.class)); return JCozProfilingErrorCodes.NORMAL_RETURN; } } } catch (IOException | NumberFormatException | AttachNotSupportedException e) { StringWriter stringWriter = new StringWriter(); e.printStackTrace(new PrintWriter(stringWriter)); logger.error("Got an exception during attachToProcess, stacktrace: {}", stringWriter); throw new RemoteException("", e); } return JCozProfilingErrorCodes.INVALID_JAVA_PROCESS; }