geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vamsavardhana Reddy" <c1vams...@gmail.com>
Subject Re: How to get memory statistics from a remote Geronimo runtime?
Date Mon, 03 Dec 2007 19:19:22 GMT
That worked too.  Thanks.

++Vamsi

On Dec 4, 2007 12:29 AM, Viet Nguyen <vhnguy2@gmail.com> 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 <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
> >
>

Mime
View raw message