From da4f32a307ff4f8e12045c7c773395400834aad6 Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Thu, 18 Feb 2010 11:06:39 +0000 Subject: Add some initial examples of using jmx to add new queues and delete messages from tmp_* queues. Create new management/examples submodule to hold them git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@911326 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/qpid/example/jmxexample/AddQueue.java | 149 +++++++++++++++++++++ .../jmxexample/DeleteMessagesFromTopOfTmp.java | 119 ++++++++++++++++ 2 files changed, 268 insertions(+) create mode 100644 qpid/java/management/example/src/main/java/org/apache/qpid/example/jmxexample/AddQueue.java create mode 100644 qpid/java/management/example/src/main/java/org/apache/qpid/example/jmxexample/DeleteMessagesFromTopOfTmp.java (limited to 'qpid/java/management/example/src') diff --git a/qpid/java/management/example/src/main/java/org/apache/qpid/example/jmxexample/AddQueue.java b/qpid/java/management/example/src/main/java/org/apache/qpid/example/jmxexample/AddQueue.java new file mode 100644 index 0000000000..b858742c4e --- /dev/null +++ b/qpid/java/management/example/src/main/java/org/apache/qpid/example/jmxexample/AddQueue.java @@ -0,0 +1,149 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.example.jmxexample; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.management.MBeanServerConnection; +import javax.management.MBeanServerInvocationHandler; +import javax.management.ObjectName; +import javax.management.remote.JMXConnector; +import javax.management.remote.JMXConnectorFactory; +import javax.management.remote.JMXServiceURL; + +import org.apache.qpid.management.common.mbeans.ManagedBroker; +import org.apache.qpid.management.common.mbeans.ManagedExchange; + +public class AddQueue +{ + + public static void main(String[] args) + { + //Example: add 'newqueue' to the 'test' virtualhost and bind to the 'amq.direct' exchange + //TODO: take these parameters as arguments + + addQueue("test", "amq.direct", "newqueue"); + } + + private static JMXConnector getJMXConnection() throws Exception + { + //TODO: Take these parameters as main+method arguments + String host = "localhost"; + int port = 8999; + String username = "admin"; + String password = "admin"; + + Map env = new HashMap(); + JMXServiceURL jmxUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxrmi"); + + //Add user credential's to environment map for RMIConnector startup. + env.put(JMXConnector.CREDENTIALS, new String[] {username,password}); + + return JMXConnectorFactory.connect(jmxUrl, env); + } + + public static boolean addQueue(String virHost, String exchName, String queueName) { + + JMXConnector jmxc = null; + try + { + jmxc = getJMXConnection(); + + MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); + + ObjectName hostManagerObjectName = new ObjectName( + "org.apache.qpid:" + + "type=VirtualHost.VirtualHostManager," + + "VirtualHost=" + virHost + ",*"); + + Set vhostManagers = mbsc.queryNames(hostManagerObjectName, null); + + if(vhostManagers.size() == 0) + { + //The vhostManager MBean wasnt found, cant procede + return false; + } + + ManagedBroker vhostManager = (ManagedBroker) MBeanServerInvocationHandler.newProxyInstance( + mbsc, (ObjectName) vhostManagers.toArray()[0], ManagedBroker.class, false); + + ObjectName customExchangeObjectName = new ObjectName( + "org.apache.qpid:" + + "type=VirtualHost.Exchange," + + "VirtualHost=" + virHost + "," + + "name=" + exchName + "," + + "ExchangeType=direct,*"); + + Set exchanges = mbsc.queryNames(customExchangeObjectName, null); + + if(exchanges.size() == 0) + { + //The exchange doesnt exist, cant procede. + return false; + } + + //create the MBean proxy + ManagedExchange managedExchange = (ManagedExchange) MBeanServerInvocationHandler.newProxyInstance( + mbsc, (ObjectName) exchanges.toArray()[0], ManagedExchange.class, false); + + try + { + //create the new durable queue and bind it. + vhostManager.createNewQueue(queueName, null, true); + managedExchange.createNewBinding(queueName,queueName); + } + catch (Exception e) + { + System.out.println("Could not add queue due to exception :" + e.getMessage()); + e.printStackTrace(); + return false; + } + + return true; + + } + catch (Exception e) + { + System.out.println("Could not add queue due to error :" + e.getMessage()); + e.printStackTrace(); + } + finally + { + if(jmxc != null) + { + try + { + jmxc.close(); + } + catch (IOException e) + { + //ignore + } + } + } + + return false; + + } + +} diff --git a/qpid/java/management/example/src/main/java/org/apache/qpid/example/jmxexample/DeleteMessagesFromTopOfTmp.java b/qpid/java/management/example/src/main/java/org/apache/qpid/example/jmxexample/DeleteMessagesFromTopOfTmp.java new file mode 100644 index 0000000000..5d529a8ff6 --- /dev/null +++ b/qpid/java/management/example/src/main/java/org/apache/qpid/example/jmxexample/DeleteMessagesFromTopOfTmp.java @@ -0,0 +1,119 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.example.jmxexample; + +import java.util.Set; + +import javax.management.MBeanServerConnection; +import javax.management.ObjectName; +import javax.management.remote.JMXConnector; +import javax.management.remote.JMXConnectorFactory; +import javax.management.remote.JMXServiceURL; + +/** + * Connects to a server and queries all info for tmp_* named queues, determines + * their message count, and if this is above a given threshold deletes the + * specified number of messages from the front of the queue + */ +public class DeleteMessagesFromTopOfTmp +{ + /** + * Params: + * 0: host, e.g. myserver.mydomain.com + * 1: port, e.g. 8999 + * 2: Number of messages to delete, e.g. 1000 + * 3: Threshold MessageCount on queue required before deletion will be undertaken e.g. 5000 + */ + public static void main(String[] args) throws Exception + { + if (args.length < 4) + { + System.out.println("Usage: "); + System.out.println(" "); + return; + } + + String host = args[0]; + int port = Integer.parseInt(args[1]); + int numToDel = Integer.parseInt(args[2]); + int numRequired = Integer.parseInt(args[3]); + + deleteFromTop(host, port, numToDel, numRequired); + } + + private static void deleteFromTop(String host, int port, + int numMsgsToDel, int minRequiredQueueMsgCount) throws Exception + { + JMXConnector con = getJMXConnection(host, port); + MBeanServerConnection mbsc = con.getMBeanServerConnection(); + + // Gets all tmp_* queue MBean ObjectNames + Set names = mbsc.queryNames( + new ObjectName("org.apache.qpid:type=VirtualHost.Queue,name=tmp_*,*"), null); + + // Traverse objects and delete specified number of message if the min msg count is breached + for (ObjectName queueObjectName : names) + { + String queueName = queueObjectName.getKeyProperty("name"); + System.out.println("Checking message count on queue: " + queueName); + + long mc = (Integer) mbsc.getAttribute(queueObjectName, "MessageCount"); + + if(mc >= minRequiredQueueMsgCount) + { + System.out.println("MessageCount (" + mc + ") is above the specified threshold (" + + minRequiredQueueMsgCount + ")"); + System.out.println("Deleting first " + numMsgsToDel + " messages on queue: " + queueName); + + int i; + for(i=0; i Date: Thu, 18 Feb 2010 11:21:27 +0000 Subject: Move queue info example to the new management/examples submodule git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@911333 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/example/jmxexample/QueueInformation.java | 177 +++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 qpid/java/management/example/src/main/java/org/apache/qpid/example/jmxexample/QueueInformation.java (limited to 'qpid/java/management/example/src') diff --git a/qpid/java/management/example/src/main/java/org/apache/qpid/example/jmxexample/QueueInformation.java b/qpid/java/management/example/src/main/java/org/apache/qpid/example/jmxexample/QueueInformation.java new file mode 100644 index 0000000000..0df6e3dd58 --- /dev/null +++ b/qpid/java/management/example/src/main/java/org/apache/qpid/example/jmxexample/QueueInformation.java @@ -0,0 +1,177 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.example.jmxexample; + +import java.io.IOException; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.management.MBeanAttributeInfo; +import javax.management.MBeanInfo; +import javax.management.MBeanServerConnection; +import javax.management.ObjectName; +import javax.management.remote.JMXConnector; +import javax.management.remote.JMXConnectorFactory; +import javax.management.remote.JMXServiceURL; +import javax.net.ssl.SSLException; + + +/** + * Connects to a server and queries all info for Queues + * Includes _tmp queues thus covering queues underlying topic subscriptions + */ +public class QueueInformation { + + private static long previousTimePoint = 0l; + private static Map previousRMC = new HashMap(); + private static Map previousMC = new HashMap(); + + /** + * Params: + * 0: host, e.g. eqd-myserver.mydomain.com + * 1: port, e.g. 8999 + * 2: vhost e.g. dev-only + * 3: username, e.g. guest + * 4: pwd, e.g. guest + * 5: loop pause, no value indicates one-off, any other value is millisecs + */ + public static void main(String[] args) throws Exception { + if (args.length < 5) { + System.out.println("Usage: "); + System.out.println(" "); + return; + } + String host = args[0]; + int port = Integer.parseInt(args[1]); + String vhost = args[2]; + String usr = args[3]; + String pwd = args[4]; + long pause = args.length == 6 ? Long.parseLong(args[5]) : -1l; + + getDetails(30000, host, port, vhost, usr, pwd, pause, true); + previousTimePoint = System.currentTimeMillis(); + + if (pause > 0) { + while (true) { + Thread.currentThread().sleep(pause); + getDetails(30000, host, port, vhost, usr, pwd, pause, false); + previousTimePoint = System.currentTimeMillis(); + } + } + } + + private static void getDetails(int timeout, String host, int port, String vhost, String username, String password, long pause, boolean printHeader) throws Exception { + JMXConnector con = getJMXConnection(timeout, host, port, username, password); + MBeanServerConnection mbsc = con.getMBeanServerConnection(); + + // Gets all Queues names + Set names = mbsc.queryNames(new ObjectName("org.apache.qpid:type=VirtualHost.Queue,*"), null); + + // Print header + if (names.size() > 0 && printHeader) { + System.out.print("Time,"); + + MBeanAttributeInfo[] attInfo = ((MBeanInfo) mbsc.getMBeanInfo((ObjectName) names.toArray()[0])).getAttributes(); + for (int i = 0; attInfo.length > i; i++) { + System.out.print(attInfo[i].getName() + ","); + } + + // Include update rate calculations + if (pause > 0) { + System.out.print("Consumption rate,"); + System.out.print("Buildup rate"); + } + System.out.print("\n"); + } + + // Traverse objects and print data on a row basis + for (ObjectName object : names) { + MBeanAttributeInfo[] attInfo = ((MBeanInfo) mbsc.getMBeanInfo(object)).getAttributes(); + + if (object.getCanonicalKeyPropertyListString().indexOf("VirtualHost=" + vhost) >= 0) { + String name = object.getKeyProperty("name"); + + // Include the "ping" queue + if (name.equals("ping")) { + System.out.print(Calendar.getInstance().getTime().toString().substring(11, 19) + ","); + for (int i = 0; attInfo.length > i; i++) { + System.out.print(mbsc.getAttribute(object, attInfo[i].getName()) + ","); + } + System.out.print("\n"); + + // Include the "tmp_*" queues + } else if (name.indexOf("tmp") >= 0) { + System.out.print(Calendar.getInstance().getTime().toString().substring(11, 19) + ","); + for (int i = 0; attInfo.length > i; i++) { + System.out.print(mbsc.getAttribute(object, attInfo[i].getName()) + ","); + } + + // Output consumption rate calc + if (pause > 0) { + double timeDelta = (System.currentTimeMillis() - previousTimePoint) / 1000.0f; + + long rmc2 = (Long) mbsc.getAttribute(object, "ReceivedMessageCount"); + long mc2 = (Integer) mbsc.getAttribute(object, "MessageCount"); + + long rmc1 = 0l; + if (previousRMC.get(name) != null) { + rmc1 = previousRMC.get(name); + } + long mc1 = 0l; + if (previousMC.get(name) != null) { + mc1 = previousMC.get(name); + } + + if (rmc1 > 0) { + double consumptionRate = ((rmc2 - rmc1) - (mc2 - mc1)) / timeDelta; + System.out.print(consumptionRate); + + System.out.print(","); + + double buildupRate = (mc2 - mc1) / timeDelta; + System.out.print(buildupRate); + } else { + System.out.print("null"); + } + + previousRMC.put(name, rmc2); + previousMC.put(name, mc2); + } + + System.out.print("\n"); + } + } + } + } + + private static JMXConnector getJMXConnection(int timeout, String host, int port, String username, String password) throws SSLException, IOException, Exception { + //Open JMX connection + JMXServiceURL jmxUrl = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxrmi"); + Map env = new HashMap(); + env.put(JMXConnector.CREDENTIALS, new String[]{username, password}); + JMXConnector con = JMXConnectorFactory.connect(jmxUrl, env); + return con; + } +} + -- cgit v1.2.1 From 976be941b903a18b524d86b00c82650a3eaf6a51 Mon Sep 17 00:00:00 2001 From: Martin Ritchie Date: Wed, 21 Apr 2010 11:46:54 +0000 Subject: QPID-2525: Updated Build.xml to build Management Examples Updated QueueInformation to allow the specification of queues to monitor and the attributes to print. Updated to only use a single connection rather than one per query. Perform connection cleanup on shutdown git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@936267 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/example/jmxexample/QueueInformation.java | 353 ++++++++++++++++----- 1 file changed, 269 insertions(+), 84 deletions(-) (limited to 'qpid/java/management/example/src') diff --git a/qpid/java/management/example/src/main/java/org/apache/qpid/example/jmxexample/QueueInformation.java b/qpid/java/management/example/src/main/java/org/apache/qpid/example/jmxexample/QueueInformation.java index 0df6e3dd58..2b34e2da5d 100644 --- a/qpid/java/management/example/src/main/java/org/apache/qpid/example/jmxexample/QueueInformation.java +++ b/qpid/java/management/example/src/main/java/org/apache/qpid/example/jmxexample/QueueInformation.java @@ -20,32 +20,47 @@ */ package org.apache.qpid.example.jmxexample; -import java.io.IOException; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - +import javax.management.InstanceNotFoundException; +import javax.management.IntrospectionException; import javax.management.MBeanAttributeInfo; import javax.management.MBeanInfo; import javax.management.MBeanServerConnection; +import javax.management.MalformedObjectNameException; import javax.management.ObjectName; +import javax.management.ReflectionException; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; -import javax.net.ssl.SSLException; - +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.Map; +import java.util.Set; /** * Connects to a server and queries all info for Queues * Includes _tmp queues thus covering queues underlying topic subscriptions */ -public class QueueInformation { +public class QueueInformation +{ + + private static long _previousTimePoint = 0l; + private static Map _previousRMC = new HashMap(); + private static Map _previousMC = new HashMap(); + private static MBeanServerConnection _mbsc; + private static final String DEFAULT_DATE_FORMAT = System.getProperty("qpid.dateFormat", "yyyy-MM-dd HH:mm:ss"); + private static final SimpleDateFormat _formatter = new SimpleDateFormat(DEFAULT_DATE_FORMAT); + + private static final String QUEUE_ARGS = "queues="; + private static Set _queueNames; + private static final String ATTRIB_ARGS = "attributes="; + private static Set _attribNames; - private static long previousTimePoint = 0l; - private static Map previousRMC = new HashMap(); - private static Map previousMC = new HashMap(); + private static MBeanAttributeInfo[] _attribInfo; + private static String _vhost; /** * Params: @@ -55,117 +70,262 @@ public class QueueInformation { * 3: username, e.g. guest * 4: pwd, e.g. guest * 5: loop pause, no value indicates one-off, any other value is millisecs + * ..: attributes= , queue= + * The queue list can use wildcards such as * and ?. Basically any value + * that JMX will accept in the query string for t name='' value of the queue. */ - public static void main(String[] args) throws Exception { - if (args.length < 5) { + public static void main(String[] args) throws Exception + { + if (args.length < 5 || args.length > 8) + { System.out.println("Usage: "); - System.out.println(" "); + System.out.println(" [] [queues=] [attributes=]"); return; } String host = args[0]; int port = Integer.parseInt(args[1]); - String vhost = args[2]; + _vhost = args[2]; String usr = args[3]; String pwd = args[4]; - long pause = args.length == 6 ? Long.parseLong(args[5]) : -1l; + long pause = -1; - getDetails(30000, host, port, vhost, usr, pwd, pause, true); - previousTimePoint = System.currentTimeMillis(); - - if (pause > 0) { - while (true) { - Thread.currentThread().sleep(pause); - getDetails(30000, host, port, vhost, usr, pwd, pause, false); - previousTimePoint = System.currentTimeMillis(); + if (args.length > 5) + { + try + { + pause = Long.parseLong(args[5]); + } + catch (NumberFormatException nfe) + { + // If it wasn't a queue or attribute request then show error + if (!!args[5].startsWith(QUEUE_ARGS) && + !!args[5].startsWith(ATTRIB_ARGS)) + { + System.out.println("Unknown argument '" + args[5] + "'"); + System.exit(1); + } } } - } - private static void getDetails(int timeout, String host, int port, String vhost, String username, String password, long pause, boolean printHeader) throws Exception { - JMXConnector con = getJMXConnection(timeout, host, port, username, password); - MBeanServerConnection mbsc = con.getMBeanServerConnection(); + //Process remaining args + // Skip arg 5 if we have assigned pause a value + int arg = (pause == -1) ? 5 : 6; + for (; args.length > arg; arg++) + { + processCommandLine(args[arg]); + } - // Gets all Queues names - Set names = mbsc.queryNames(new ObjectName("org.apache.qpid:type=VirtualHost.Queue,*"), null); + JMXConnector con = getJMXConnection(host, port, usr, pwd); + + _mbsc = con.getMBeanServerConnection(); + + Set names = _mbsc.queryNames(new ObjectName("org.apache.qpid:type=VirtualHost.Queue,VirtualHost=" + _vhost + ",*"), null); // Print header - if (names.size() > 0 && printHeader) { - System.out.print("Time,"); + if (names.size() > 0) + { + System.out.print("Time"); + + MBeanAttributeInfo[] attributeList = getAttributeList(names.toArray(new ObjectName[1])[0]); - MBeanAttributeInfo[] attInfo = ((MBeanInfo) mbsc.getMBeanInfo((ObjectName) names.toArray()[0])).getAttributes(); - for (int i = 0; attInfo.length > i; i++) { - System.out.print(attInfo[i].getName() + ","); + for (int i = 0; attributeList.length > i; i++) + { + System.out.print(", " + attributeList[i].getName()); } // Include update rate calculations - if (pause > 0) { - System.out.print("Consumption rate,"); - System.out.print("Buildup rate"); + if (pause > 0) + { + System.out.print(", Consumption rate"); + System.out.print(", Receive rate"); } System.out.print("\n"); } + else + { + System.out.println("No queues found on specified vhost unable to continue."); + System.exit(1); + } - // Traverse objects and print data on a row basis - for (ObjectName object : names) { - MBeanAttributeInfo[] attInfo = ((MBeanInfo) mbsc.getMBeanInfo(object)).getAttributes(); + try + { + do + { + getDetails(pause > -1); + if (pause > 0) + { + _previousTimePoint = System.currentTimeMillis(); + Thread.currentThread().sleep(pause); + } + } + while (pause > 0); + } + finally + { + con.close(); + } + } - if (object.getCanonicalKeyPropertyListString().indexOf("VirtualHost=" + vhost) >= 0) { - String name = object.getKeyProperty("name"); + private static MBeanAttributeInfo[] getAttributeList(ObjectName name) + throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException + { + if (_attribInfo == null) + { + MBeanAttributeInfo[] allAttribs = ((MBeanInfo) _mbsc.getMBeanInfo((ObjectName) name)).getAttributes(); - // Include the "ping" queue - if (name.equals("ping")) { - System.out.print(Calendar.getInstance().getTime().toString().substring(11, 19) + ","); - for (int i = 0; attInfo.length > i; i++) { - System.out.print(mbsc.getAttribute(object, attInfo[i].getName()) + ","); - } - System.out.print("\n"); + if (_attribNames != null && _attribNames.size() != 0) + { + LinkedList tmpList = new LinkedList(); - // Include the "tmp_*" queues - } else if (name.indexOf("tmp") >= 0) { - System.out.print(Calendar.getInstance().getTime().toString().substring(11, 19) + ","); - for (int i = 0; attInfo.length > i; i++) { - System.out.print(mbsc.getAttribute(object, attInfo[i].getName()) + ","); + for (MBeanAttributeInfo attribute : allAttribs) + { + if (_attribNames.contains(attribute.getName())) + { + tmpList.add(attribute); } + } - // Output consumption rate calc - if (pause > 0) { - double timeDelta = (System.currentTimeMillis() - previousTimePoint) / 1000.0f; + _attribInfo = tmpList.toArray(new MBeanAttributeInfo[tmpList.size()]); + } + else + { + _attribInfo = allAttribs; + } + } + return _attribInfo; + } - long rmc2 = (Long) mbsc.getAttribute(object, "ReceivedMessageCount"); - long mc2 = (Integer) mbsc.getAttribute(object, "MessageCount"); + private static void processCommandLine(String arg) + { + if (arg.startsWith(QUEUE_ARGS)) + { + String[] queues = arg.substring(arg.indexOf("=") + 1).split(","); - long rmc1 = 0l; - if (previousRMC.get(name) != null) { - rmc1 = previousRMC.get(name); - } - long mc1 = 0l; - if (previousMC.get(name) != null) { - mc1 = previousMC.get(name); - } + _queueNames = new HashSet(); - if (rmc1 > 0) { - double consumptionRate = ((rmc2 - rmc1) - (mc2 - mc1)) / timeDelta; - System.out.print(consumptionRate); + for (String queue : queues) + { + if (queue.length() > 0) + { + _queueNames.add(queue); + } + } - System.out.print(","); + if (_queueNames.size() == 0) + { + System.out.println("No Queues specified on queue argument: '" + arg + "'"); + System.exit(1); + } - double buildupRate = (mc2 - mc1) / timeDelta; - System.out.print(buildupRate); - } else { - System.out.print("null"); - } + } + else if (arg.startsWith(ATTRIB_ARGS)) + { + String[] attribs = arg.substring(arg.indexOf("=") + 1).split(","); - previousRMC.put(name, rmc2); - previousMC.put(name, mc2); - } + _attribNames = new HashSet(); - System.out.print("\n"); + for (String attrib : attribs) + { + if (attrib.length() > 0) + { + _attribNames.add(attrib); } } + + if (_attribNames.size() == 0) + { + System.out.println("No Attributes specified on attribute argument: '" + arg + "'"); + System.exit(1); + } + } + else + { + System.out.println("Unknown argument '" + arg + "'"); + System.exit(1); } + } - private static JMXConnector getJMXConnection(int timeout, String host, int port, String username, String password) throws SSLException, IOException, Exception { + private static void getDetails(boolean printRates) throws Exception + { + for (ObjectName object : getMatchingObjects()) + { + try + { + + // There should normally be only one but allow queue Names such as tmp_* + // Line format is + //