From dev-return-57338-apmail-geronimo-dev-archive=geronimo.apache.org@geronimo.apache.org Mon Dec 03 18:59:48 2007 Return-Path: Delivered-To: apmail-geronimo-dev-archive@www.apache.org Received: (qmail 50128 invoked from network); 3 Dec 2007 18:59:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Dec 2007 18:59:47 -0000 Received: (qmail 45619 invoked by uid 500); 3 Dec 2007 18:59:34 -0000 Delivered-To: apmail-geronimo-dev-archive@geronimo.apache.org Received: (qmail 45557 invoked by uid 500); 3 Dec 2007 18:59:34 -0000 Mailing-List: contact dev-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list dev@geronimo.apache.org Received: (qmail 45544 invoked by uid 99); 3 Dec 2007 18:59:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Dec 2007 10:59:34 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of vhnguy2@gmail.com designates 66.249.92.172 as permitted sender) Received: from [66.249.92.172] (HELO ug-out-1314.google.com) (66.249.92.172) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Dec 2007 18:59:15 +0000 Received: by ug-out-1314.google.com with SMTP id 29so3026178ugc for ; Mon, 03 Dec 2007 10:59:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=xvCib2NTYEChme4gWRIqX4qJKWESmrHHv3newoCLEOY=; b=VBstkhh3eZ67snvfKt1uEsM+oW89EyxmuwXm3zIrbJwryAV8IWEIjF5O4el75TjOVFA/2148a4L6ZBGoJi1SbZMOF9TkLqzwkNeSYH8NIYAoddFPSIrdi6Zs3PM9j0A2xGIbUVjWuj+4hFMeSXeyKWsuLI7jBGn9FsBwQC+vCBQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=MHiBRbeOf7r7bAXLcTTqrWgtKXrxgQ/yb3cdaZ3Jv4mTZfm9JPVvBjRp/Mq7JTDPwstaE5jIYCNFXhtCMxPCczi19cL8sjGiYqPK961QIgnIYdEbeCvjmGwEEcJHtn1QSISDdlvbmCiaEG0U2e5FV6knchpF9C08tq58o13p5V4= Received: by 10.78.131.8 with SMTP id e8mr6952806hud.1196708356418; Mon, 03 Dec 2007 10:59:16 -0800 (PST) Received: by 10.78.203.6 with HTTP; Mon, 3 Dec 2007 10:59:16 -0800 (PST) Message-ID: Date: Mon, 3 Dec 2007 13:59:16 -0500 From: "Viet Nguyen" To: dev@geronimo.apache.org Subject: Re: How to get memory statistics from a remote Geronimo runtime? In-Reply-To: <22d56c4d0712031052t65fd3841va87e4fd66efda697@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <22d56c4d0712031052t65fd3841va87e4fd66efda697@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org 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(), "stats"); Hope this helps, Viet Nguyen On Dec 3, 2007 1:52 PM, Vamsavardhana Reddy 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 >