geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anita Kulshreshtha <a_kuls...@yahoo.com>
Subject Re: How to get memory statistics from a remote Geronimo runtime?
Date Tue, 04 Dec 2007 13:21:09 GMT
   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 <c1vamsi1c@gmail.com> 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/

Mime
View raw message