Re: How to get memory statistics from a remote Geronimo runtime?
On Dec 5, 2007, at 4:29 AM, Vamsavardhana Reddy wrote: On Dec 4, 2007 11:23 PM, Anita Kulshreshtha [EMAIL PROTECTED] wrote: It is not clear to me if this is part of the earlier code or a separate program. If it is part of the JMX code, then Runtime is from the local jvm not remote. The non heap Memory for this program in either case is negligible. You could start G with -Dcom.sun.management.jmxremote. Start jconsole and click on the Memory tab to get the whole picture. I have started G with the said option and hooked up jconsole. The HeapMemoryUsage is showing exactly what Runtime is returning. It is only the heap memory exhaustion that results in OOME. I guess I am ok for now as this is what I am interested in. One will get OOM Exceptions if there is insufficient native memory to satisfy a Java request. For instance, when creating a thread, the OS has to allocate some native memory to create the Java Object. If that native allocation fails you will get an OOM even though you have plenty of heap memory.
Re: How to get memory statistics from a remote Geronimo runtime?
On Dec 7, 2007 9:38 PM, Matt Hogstrom [EMAIL PROTECTED] wrote: On Dec 5, 2007, at 4:29 AM, Vamsavardhana Reddy wrote: On Dec 4, 2007 11:23 PM, Anita Kulshreshtha [EMAIL PROTECTED] wrote: It is not clear to me if this is part of the earlier code or a separate program. If it is part of the JMX code, then Runtime is from the local jvm not remote. The non heap Memory for this program in either case is negligible. You could start G with -Dcom.sun.management.jmxremote. Start jconsole and click on the Memory tab to get the whole picture. I have started G with the said option and hooked up jconsole. The HeapMemoryUsage is showing exactly what Runtime is returning. It is only the heap memory exhaustion that results in OOME. I guess I am ok for now as this is what I am interested in. One will get OOM Exceptions if there is insufficient native memory to satisfy a Java request. For instance, when creating a thread, the OS has to allocate some native memory to create the Java Object. If that native allocation fails you will get an OOM even though you have plenty of heap memory. You are right. Any ideas on how to figure if we are exhausting that native memory?
Re: How to get memory statistics from a remote Geronimo runtime?
On Dec 4, 2007 11:23 PM, Anita Kulshreshtha [EMAIL PROTECTED] wrote: It is not clear to me if this is part of the earlier code or a separate program. If it is part of the JMX code, then Runtime is from the local jvm not remote. The non heap Memory for this program in either case is negligible. You could start G with -Dcom.sun.management.jmxremote. Start jconsole and click on the Memory tab to get the whole picture. I have started G with the said option and hooked up jconsole. The HeapMemoryUsage is showing exactly what Runtime is returning. It is only the heap memory exhaustion that results in OOME. I guess I am ok for now as this is what I am interested in. Hope this is helpful Thanks Anita --- Vamsavardhana Reddy [EMAIL PROTECTED] wrote: I don't know why the non heap memory is missing in the equations. The equations I gave are based what I observed by running the following code. MemoryMXBean memmxbean = ManagementFactory.getMemoryMXBean(); Runtime rt = Runtime.getRuntime(); MemoryUsage memUsage = memmxbean.getHeapMemoryUsage(); System.err.println(init=+memUsage.getInit()); System.err.println(max=+memUsage.getMax()); System.err.println(used=+memUsage.getUsed()); System.err.println(committed=+memUsage.getCommitted()); System.err.println(free=+(memUsage.getCommitted()- memUsage.getUsed())); System.err.println(TotalMemory = +rt.totalMemory()); System.err.println(MaxMemory = +rt.maxMemory()); System.err.println(FreeMemory = +rt.freeMemory()); System.err.println(Used=+(rt.totalMemory()-rt.freeMemory())); ++Vamsi On Dec 4, 2007 8:57 PM, Anita Kulshreshtha [EMAIL PROTECTED] wrote: IIUC, http://java.sun.com/j2se/1.5.0/docs/api/java/lang/management/MemoryMXBean.html runtime values are sum of values from Heap and non heap memory. In other words you need to add contribution from non heap Memory to all 4 equations. Thanks Anita --- Vamsavardhana Reddy [EMAIL PROTECTED] wrote: I don't know if it is necessary to add the statistics from Runtime. Here is the relationship I see between the stats from Runtime and those got from MemoryMXBean.getHeapMemoryUsage() Runtime.totalMemory() == MemoryUsage.getCommitted() Runtime.maxMemory() == MemoryUsage.getMax() Runtime.freeMemory() == MemoryUsage.getCommitted() - MemoryUsage.getUsed() Runtime.totalMemory() - Runtime.freeMemory() == MemoryUsage.getUsed() ++Vamsi On Dec 4, 2007 6:51 PM, Anita Kulshreshtha [EMAIL PROTECTED] wrote: If you are interested in usedMemory and maxMemory as given by Runtime, we could add that again. The JVM Stats give a rough estimate of heap memory only. Thanks Anita --- Vamsavardhana Reddy [EMAIL PROTECTED] wrote: I am wondering if the following (which works) is the correct way to get maxHeapSize and usedMemory from a remote Geronimo server. import org.apache.geronimo.management.stats.BoundedRangeStatisticImpl; Map map = new HashMap(); map.put(jmx.remote.credentials, new String[] {user, password}); JMXServiceURL address = new JMXServiceURL( service:jmx:rmi:///jndi/rmi://+host+ : + port + /JMXConnector); JMXConnector jmxConnector = JMXConnectorFactory.connect(address, map); mbServerConnection = jmxConnector.getMBeanServerConnection(); objName = ObjectName.getInstance (geronimo:J2EEServer=geronimo,name=JVM,j2eeType=JVM); Stats stats = (Stats) mbServerConnection.getAttribute(objName, stats); BoundedRangeStatisticImpl statistic = (BoundedRangeStatisticImpl) stats.getStatistic(HeapSize); long maxMemory = statistic.getUpperBound(); long usedMemory = statistic.getCurrent(); Is this ok? Or, is there a better way? ++Vamsi Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how. http://overview.mail.yahoo.com/ Be a better sports nut! Let your teams follow you with Yahoo Mobile. Try it now. http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
Re: How to get memory statistics from a remote Geronimo runtime?
If you are interested in usedMemory and maxMemory as given by Runtime, we could add that again. The JVM Stats give a rough estimate of heap memory only. Thanks Anita --- Vamsavardhana Reddy [EMAIL PROTECTED] wrote: I am wondering if the following (which works) is the correct way to get maxHeapSize and usedMemory from a remote Geronimo server. import org.apache.geronimo.management.stats.BoundedRangeStatisticImpl; Map map = new HashMap(); map.put(jmx.remote.credentials, new String[] {user, password}); JMXServiceURL address = new JMXServiceURL( service:jmx:rmi:///jndi/rmi://+host+ : + port + /JMXConnector); JMXConnector jmxConnector = JMXConnectorFactory.connect(address, map); mbServerConnection = jmxConnector.getMBeanServerConnection(); objName = ObjectName.getInstance (geronimo:J2EEServer=geronimo,name=JVM,j2eeType=JVM); Stats stats = (Stats) mbServerConnection.getAttribute(objName, stats); BoundedRangeStatisticImpl statistic = (BoundedRangeStatisticImpl) stats.getStatistic(HeapSize); long maxMemory = statistic.getUpperBound(); long usedMemory = statistic.getCurrent(); Is this ok? Or, is there a better way? ++Vamsi Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how. http://overview.mail.yahoo.com/
Re: How to get memory statistics from a remote Geronimo runtime?
I don't know if it is necessary to add the statistics from Runtime. Here is the relationship I see between the stats from Runtime and those got from MemoryMXBean.getHeapMemoryUsage() Runtime.totalMemory() == MemoryUsage.getCommitted() Runtime.maxMemory() == MemoryUsage.getMax() Runtime.freeMemory() == MemoryUsage.getCommitted() - MemoryUsage.getUsed() Runtime.totalMemory() - Runtime.freeMemory() == MemoryUsage.getUsed() ++Vamsi On Dec 4, 2007 6:51 PM, Anita Kulshreshtha [EMAIL PROTECTED] wrote: If you are interested in usedMemory and maxMemory as given by Runtime, we could add that again. The JVM Stats give a rough estimate of heap memory only. Thanks Anita --- Vamsavardhana Reddy [EMAIL PROTECTED] wrote: I am wondering if the following (which works) is the correct way to get maxHeapSize and usedMemory from a remote Geronimo server. import org.apache.geronimo.management.stats.BoundedRangeStatisticImpl; Map map = new HashMap(); map.put(jmx.remote.credentials, new String[] {user, password}); JMXServiceURL address = new JMXServiceURL( service:jmx:rmi:///jndi/rmi://+host+ : + port + /JMXConnector); JMXConnector jmxConnector = JMXConnectorFactory.connect(address, map); mbServerConnection = jmxConnector.getMBeanServerConnection(); objName = ObjectName.getInstance (geronimo:J2EEServer=geronimo,name=JVM,j2eeType=JVM); Stats stats = (Stats) mbServerConnection.getAttribute(objName, stats); BoundedRangeStatisticImpl statistic = (BoundedRangeStatisticImpl) stats.getStatistic(HeapSize); long maxMemory = statistic.getUpperBound(); long usedMemory = statistic.getCurrent(); Is this ok? Or, is there a better way? ++Vamsi Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how. http://overview.mail.yahoo.com/
Re: How to get memory statistics from a remote Geronimo runtime?
IIUC, http://java.sun.com/j2se/1.5.0/docs/api/java/lang/management/MemoryMXBean.html runtime values are sum of values from Heap and non heap memory. In other words you need to add contribution from non heap Memory to all 4 equations. Thanks Anita --- Vamsavardhana Reddy [EMAIL PROTECTED] wrote: I don't know if it is necessary to add the statistics from Runtime. Here is the relationship I see between the stats from Runtime and those got from MemoryMXBean.getHeapMemoryUsage() Runtime.totalMemory() == MemoryUsage.getCommitted() Runtime.maxMemory() == MemoryUsage.getMax() Runtime.freeMemory() == MemoryUsage.getCommitted() - MemoryUsage.getUsed() Runtime.totalMemory() - Runtime.freeMemory() == MemoryUsage.getUsed() ++Vamsi On Dec 4, 2007 6:51 PM, Anita Kulshreshtha [EMAIL PROTECTED] wrote: If you are interested in usedMemory and maxMemory as given by Runtime, we could add that again. The JVM Stats give a rough estimate of heap memory only. Thanks Anita --- Vamsavardhana Reddy [EMAIL PROTECTED] wrote: I am wondering if the following (which works) is the correct way to get maxHeapSize and usedMemory from a remote Geronimo server. import org.apache.geronimo.management.stats.BoundedRangeStatisticImpl; Map map = new HashMap(); map.put(jmx.remote.credentials, new String[] {user, password}); JMXServiceURL address = new JMXServiceURL( service:jmx:rmi:///jndi/rmi://+host+ : + port + /JMXConnector); JMXConnector jmxConnector = JMXConnectorFactory.connect(address, map); mbServerConnection = jmxConnector.getMBeanServerConnection(); objName = ObjectName.getInstance (geronimo:J2EEServer=geronimo,name=JVM,j2eeType=JVM); Stats stats = (Stats) mbServerConnection.getAttribute(objName, stats); BoundedRangeStatisticImpl statistic = (BoundedRangeStatisticImpl) stats.getStatistic(HeapSize); long maxMemory = statistic.getUpperBound(); long usedMemory = statistic.getCurrent(); Is this ok? Or, is there a better way? ++Vamsi Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how. http://overview.mail.yahoo.com/ Be a better sports nut! Let your teams follow you with Yahoo Mobile. Try it now. http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ
Re: How to get memory statistics from a remote Geronimo runtime?
I don't know why the non heap memory is missing in the equations. The equations I gave are based what I observed by running the following code. MemoryMXBean memmxbean = ManagementFactory.getMemoryMXBean(); Runtime rt = Runtime.getRuntime(); MemoryUsage memUsage = memmxbean.getHeapMemoryUsage(); System.err.println(init=+memUsage.getInit()); System.err.println(max=+memUsage.getMax()); System.err.println(used=+memUsage.getUsed()); System.err.println(committed=+memUsage.getCommitted()); System.err.println(free=+(memUsage.getCommitted()- memUsage.getUsed())); System.err.println(TotalMemory = +rt.totalMemory()); System.err.println(MaxMemory = +rt.maxMemory()); System.err.println(FreeMemory = +rt.freeMemory()); System.err.println(Used=+(rt.totalMemory()-rt.freeMemory())); ++Vamsi On Dec 4, 2007 8:57 PM, Anita Kulshreshtha [EMAIL PROTECTED] wrote: IIUC, http://java.sun.com/j2se/1.5.0/docs/api/java/lang/management/MemoryMXBean.html runtime values are sum of values from Heap and non heap memory. In other words you need to add contribution from non heap Memory to all 4 equations. Thanks Anita --- Vamsavardhana Reddy [EMAIL PROTECTED] wrote: I don't know if it is necessary to add the statistics from Runtime. Here is the relationship I see between the stats from Runtime and those got from MemoryMXBean.getHeapMemoryUsage() Runtime.totalMemory() == MemoryUsage.getCommitted() Runtime.maxMemory() == MemoryUsage.getMax() Runtime.freeMemory() == MemoryUsage.getCommitted() - MemoryUsage.getUsed() Runtime.totalMemory() - Runtime.freeMemory() == MemoryUsage.getUsed() ++Vamsi On Dec 4, 2007 6:51 PM, Anita Kulshreshtha [EMAIL PROTECTED] wrote: If you are interested in usedMemory and maxMemory as given by Runtime, we could add that again. The JVM Stats give a rough estimate of heap memory only. Thanks Anita --- Vamsavardhana Reddy [EMAIL PROTECTED] wrote: I am wondering if the following (which works) is the correct way to get maxHeapSize and usedMemory from a remote Geronimo server. import org.apache.geronimo.management.stats.BoundedRangeStatisticImpl; Map map = new HashMap(); map.put(jmx.remote.credentials, new String[] {user, password}); JMXServiceURL address = new JMXServiceURL( service:jmx:rmi:///jndi/rmi://+host+ : + port + /JMXConnector); JMXConnector jmxConnector = JMXConnectorFactory.connect(address, map); mbServerConnection = jmxConnector.getMBeanServerConnection(); objName = ObjectName.getInstance (geronimo:J2EEServer=geronimo,name=JVM,j2eeType=JVM); Stats stats = (Stats) mbServerConnection.getAttribute(objName, stats); BoundedRangeStatisticImpl statistic = (BoundedRangeStatisticImpl) stats.getStatistic(HeapSize); long maxMemory = statistic.getUpperBound(); long usedMemory = statistic.getCurrent(); Is this ok? Or, is there a better way? ++Vamsi Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how. http://overview.mail.yahoo.com/ Be a better sports nut! Let your teams follow you with Yahoo Mobile. Try it now. http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ
Re: How to get memory statistics from a remote Geronimo runtime?
It is not clear to me if this is part of the earlier code or a separate program. If it is part of the JMX code, then Runtime is from the local jvm not remote. The non heap Memory for this program in either case is negligible. You could start G with -Dcom.sun.management.jmxremote. Start jconsole and click on the Memory tab to get the whole picture. Hope this is helpful Thanks Anita --- Vamsavardhana Reddy [EMAIL PROTECTED] wrote: I don't know why the non heap memory is missing in the equations. The equations I gave are based what I observed by running the following code. MemoryMXBean memmxbean = ManagementFactory.getMemoryMXBean(); Runtime rt = Runtime.getRuntime(); MemoryUsage memUsage = memmxbean.getHeapMemoryUsage(); System.err.println(init=+memUsage.getInit()); System.err.println(max=+memUsage.getMax()); System.err.println(used=+memUsage.getUsed()); System.err.println(committed=+memUsage.getCommitted()); System.err.println(free=+(memUsage.getCommitted()- memUsage.getUsed())); System.err.println(TotalMemory = +rt.totalMemory()); System.err.println(MaxMemory = +rt.maxMemory()); System.err.println(FreeMemory = +rt.freeMemory()); System.err.println(Used=+(rt.totalMemory()-rt.freeMemory())); ++Vamsi On Dec 4, 2007 8:57 PM, Anita Kulshreshtha [EMAIL PROTECTED] wrote: IIUC, http://java.sun.com/j2se/1.5.0/docs/api/java/lang/management/MemoryMXBean.html runtime values are sum of values from Heap and non heap memory. In other words you need to add contribution from non heap Memory to all 4 equations. Thanks Anita --- Vamsavardhana Reddy [EMAIL PROTECTED] wrote: I don't know if it is necessary to add the statistics from Runtime. Here is the relationship I see between the stats from Runtime and those got from MemoryMXBean.getHeapMemoryUsage() Runtime.totalMemory() == MemoryUsage.getCommitted() Runtime.maxMemory() == MemoryUsage.getMax() Runtime.freeMemory() == MemoryUsage.getCommitted() - MemoryUsage.getUsed() Runtime.totalMemory() - Runtime.freeMemory() == MemoryUsage.getUsed() ++Vamsi On Dec 4, 2007 6:51 PM, Anita Kulshreshtha [EMAIL PROTECTED] wrote: If you are interested in usedMemory and maxMemory as given by Runtime, we could add that again. The JVM Stats give a rough estimate of heap memory only. Thanks Anita --- Vamsavardhana Reddy [EMAIL PROTECTED] wrote: I am wondering if the following (which works) is the correct way to get maxHeapSize and usedMemory from a remote Geronimo server. import org.apache.geronimo.management.stats.BoundedRangeStatisticImpl; Map map = new HashMap(); map.put(jmx.remote.credentials, new String[] {user, password}); JMXServiceURL address = new JMXServiceURL( service:jmx:rmi:///jndi/rmi://+host+ : + port + /JMXConnector); JMXConnector jmxConnector = JMXConnectorFactory.connect(address, map); mbServerConnection = jmxConnector.getMBeanServerConnection(); objName = ObjectName.getInstance (geronimo:J2EEServer=geronimo,name=JVM,j2eeType=JVM); Stats stats = (Stats) mbServerConnection.getAttribute(objName, stats); BoundedRangeStatisticImpl statistic = (BoundedRangeStatisticImpl) stats.getStatistic(HeapSize); long maxMemory = statistic.getUpperBound(); long usedMemory = statistic.getCurrent(); Is this ok? Or, is there a better way? ++Vamsi Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how. http://overview.mail.yahoo.com/ Be a better sports nut! Let your teams follow you with Yahoo Mobile. Try it now. http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
Re: How to get memory statistics from a remote Geronimo runtime?
On Dec 4, 2007 11:23 PM, Anita Kulshreshtha [EMAIL PROTECTED] wrote: It is not clear to me if this is part of the earlier code or a separate program. If it is part of the JMX code, then Runtime is from the local jvm not remote. The non heap Memory for this program in either case is negligible. I got the code to run in a jsp. So, the statistics it shows are indeed from Geronimo's JVM. You could start G with -Dcom.sun.management.jmxremote. Start jconsole and click on the Memory tab to get the whole picture. Will try this. Thank you. Hope this is helpful Thanks Anita --- Vamsavardhana Reddy [EMAIL PROTECTED] wrote: I don't know why the non heap memory is missing in the equations. The equations I gave are based what I observed by running the following code. MemoryMXBean memmxbean = ManagementFactory.getMemoryMXBean(); Runtime rt = Runtime.getRuntime(); MemoryUsage memUsage = memmxbean.getHeapMemoryUsage(); System.err.println(init=+memUsage.getInit()); System.err.println(max=+memUsage.getMax()); System.err.println(used=+memUsage.getUsed()); System.err.println(committed=+memUsage.getCommitted()); System.err.println(free=+(memUsage.getCommitted()- memUsage.getUsed())); System.err.println(TotalMemory = +rt.totalMemory()); System.err.println(MaxMemory = +rt.maxMemory()); System.err.println(FreeMemory = +rt.freeMemory()); System.err.println(Used=+(rt.totalMemory()-rt.freeMemory())); ++Vamsi On Dec 4, 2007 8:57 PM, Anita Kulshreshtha [EMAIL PROTECTED] wrote: IIUC, http://java.sun.com/j2se/1.5.0/docs/api/java/lang/management/MemoryMXBean.html runtime values are sum of values from Heap and non heap memory. In other words you need to add contribution from non heap Memory to all 4 equations. Thanks Anita --- Vamsavardhana Reddy [EMAIL PROTECTED] wrote: I don't know if it is necessary to add the statistics from Runtime. Here is the relationship I see between the stats from Runtime and those got from MemoryMXBean.getHeapMemoryUsage() Runtime.totalMemory() == MemoryUsage.getCommitted() Runtime.maxMemory() == MemoryUsage.getMax() Runtime.freeMemory() == MemoryUsage.getCommitted() - MemoryUsage.getUsed() Runtime.totalMemory() - Runtime.freeMemory() == MemoryUsage.getUsed() ++Vamsi On Dec 4, 2007 6:51 PM, Anita Kulshreshtha [EMAIL PROTECTED] wrote: If you are interested in usedMemory and maxMemory as given by Runtime, we could add that again. The JVM Stats give a rough estimate of heap memory only. Thanks Anita --- Vamsavardhana Reddy [EMAIL PROTECTED] wrote: I am wondering if the following (which works) is the correct way to get maxHeapSize and usedMemory from a remote Geronimo server. import org.apache.geronimo.management.stats.BoundedRangeStatisticImpl; Map map = new HashMap(); map.put(jmx.remote.credentials, new String[] {user, password}); JMXServiceURL address = new JMXServiceURL( service:jmx:rmi:///jndi/rmi://+host+ : + port + /JMXConnector); JMXConnector jmxConnector = JMXConnectorFactory.connect(address, map); mbServerConnection = jmxConnector.getMBeanServerConnection(); objName = ObjectName.getInstance (geronimo:J2EEServer=geronimo,name=JVM,j2eeType=JVM); Stats stats = (Stats) mbServerConnection.getAttribute(objName, stats); BoundedRangeStatisticImpl statistic = (BoundedRangeStatisticImpl) stats.getStatistic(HeapSize); long maxMemory = statistic.getUpperBound(); long usedMemory = statistic.getCurrent(); Is this ok? Or, is there a better way? ++Vamsi Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how. http://overview.mail.yahoo.com/ Be a better sports nut! Let your teams follow you with Yahoo Mobile. Try it now. http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
Re: How to get memory statistics from a remote Geronimo runtime?
You can do it that way or do it the JSR-77 way. Properties props = new Properties(); props.setProperty(Context.INITIAL_CONTEXT_FACTORY, org.apache.openejb.client.RemoteInitialContextFactory); props.setProperty(Context.PROVIDER_URL, ejbd://localhost:4201); props.setProperty(Context.SECURITY_PRINCIPAL, username); props.setProperty(Context.SECURITY_CREDENTIALS, password); props.setProperty(openejb.authentication.realmName, geronimo-admin); InitialContext ctx = new InitialContext(p); ManagementHome mejbHome = (ManagementHome)ctx.lookup(ejb/mgmt/MEJBRemoteHome); mejb = mejbHome.create(); Stats stats = (Stats)mejb.getAttribute(new ObjectName(mbean_name_here), stats); Hope this helps, Viet Nguyen On Dec 3, 2007 1:52 PM, Vamsavardhana Reddy [EMAIL PROTECTED] wrote: I am wondering if the following (which works) is the correct way to get maxHeapSize and usedMemory from a remote Geronimo server. import org.apache.geronimo.management.stats.BoundedRangeStatisticImpl; Map map = new HashMap(); map.put(jmx.remote.credentials, new String[] {user, password}); JMXServiceURL address = new JMXServiceURL( service:jmx:rmi:///jndi/rmi://+host+ : + port + /JMXConnector); JMXConnector jmxConnector = JMXConnectorFactory.connect(address, map); mbServerConnection = jmxConnector.getMBeanServerConnection(); objName = ObjectName.getInstance(geronimo:J2EEServer=geronimo,name=JVM,j2eeType=JVM); Stats stats = (Stats) mbServerConnection.getAttribute(objName, stats); BoundedRangeStatisticImpl statistic = (BoundedRangeStatisticImpl) stats.getStatistic(HeapSize); long maxMemory = statistic.getUpperBound(); long usedMemory = statistic.getCurrent(); Is this ok? Or, is there a better way? ++Vamsi
Re: How to get memory statistics from a remote Geronimo runtime?
That worked too. Thanks. ++Vamsi On Dec 4, 2007 12:29 AM, Viet Nguyen [EMAIL PROTECTED] wrote: You can do it that way or do it the JSR-77 way. Properties props = new Properties(); props.setProperty(Context.INITIAL_CONTEXT_FACTORY, org.apache.openejb.client.RemoteInitialContextFactory); props.setProperty(Context.PROVIDER_URL, ejbd://localhost:4201); props.setProperty(Context.SECURITY_PRINCIPAL, username); props.setProperty(Context.SECURITY_CREDENTIALS, password); props.setProperty(openejb.authentication.realmName, geronimo-admin); InitialContext ctx = new InitialContext(p); ManagementHome mejbHome = (ManagementHome)ctx.lookup(ejb/mgmt/MEJBRemoteHome); mejb = mejbHome.create(); Stats stats = (Stats)mejb.getAttribute(new ObjectName(mbean_name_here), stats); Hope this helps, Viet Nguyen On Dec 3, 2007 1:52 PM, Vamsavardhana Reddy [EMAIL PROTECTED] wrote: I am wondering if the following (which works) is the correct way to get maxHeapSize and usedMemory from a remote Geronimo server. import org.apache.geronimo.management.stats.BoundedRangeStatisticImpl; Map map = new HashMap(); map.put(jmx.remote.credentials, new String[] {user, password}); JMXServiceURL address = new JMXServiceURL( service:jmx:rmi:///jndi/rmi://+host+ : + port + /JMXConnector); JMXConnector jmxConnector = JMXConnectorFactory.connect(address, map); mbServerConnection = jmxConnector.getMBeanServerConnection(); objName = ObjectName.getInstance (geronimo:J2EEServer=geronimo,name=JVM,j2eeType=JVM); Stats stats = (Stats) mbServerConnection.getAttribute(objName, stats); BoundedRangeStatisticImpl statistic = (BoundedRangeStatisticImpl) stats.getStatistic(HeapSize); long maxMemory = statistic.getUpperBound(); long usedMemory = statistic.getCurrent(); Is this ok? Or, is there a better way? ++Vamsi