package com.googlecode.jmxtrans.example;

import com.googlecode.jmxtrans.model.Query;
import com.googlecode.jmxtrans.model.Server;
import com.googlecode.jmxtrans.model.output.StdOutWriter;
import com.googlecode.jmxtrans.util.JmxUtils;

/**
 * This example shows how to query an ActiveMQ server for some information.
 * 
 * The point of this example is to show that * works as part of the objectName.
 * It also shows that you don't have to set an attribute to get for a query.
 * jmxtrans will get all attributes on an object if you don't specify any.
 * 
 * @author jon
 */
public class ActiveMQ {

    /** */
    public static void main(String[] args) throws Exception {

        Server server = new Server("localhost", "1099");

        Query q = new Query();
        q.setObj("org.apache.activemq:BrokerName=localhost,Connection=*,ConnectorName=openwire,Type=Connection");
        q.addOutputWriter(new StdOutWriter());
        server.addQuery(q);

        JmxUtils.processServer(server);
    }
}

@@ -76,56 +76,165 @@
 del.
-Query;%0Aimport com.googlecode.jmxtrans.model.Serv
+JmxProcess;%0Aimport com.googlecode.jmxtrans.model.Query;%0Aimport com.googlecode.jmxtrans.model.Server;%0Aimport com.googlecode.jmxtrans.model.output.GraphiteWrit
 er;%0A
@@ -816,26 +816,175 @@
 er(%22
-localhost%22, %221099%22
+w2%22, %221105%22);%0A        GraphiteWriter gw = new GraphiteWriter();%0A        gw.addSetting(GraphiteWriter.HOST, %22graphite%22);%0A        gw.addSetting(GraphiteWriter.PORT, 2003
 );%0A%0A
@@ -1077,59 +1077,19 @@
 ost,
-Connection=*,ConnectorName=openwire,Type=Connection
+Type=Broker
 %22);%0A
@@ -1147,68 +1147,291 @@
     
-server.addQuery(q);%0A%0A        JmxUtils.processServer(server);
+q.addOutputWriter(gw);%0A        server.addQuery(q);%0A        JmxProcess process = new JmxProcess(server);%0A%0A        JmxUtils.prettyPrintJson(process);%0A        %0A        for (int i = 0; i %3C 160; i++) %7B%0A            JmxUtils.processServer(server);%0A            Thread.sleep(1000);%0A        %7D%0A
 %0A   

send data to graphite.