Package com.googlecode.jmxtrans.example

Source Code of com.googlecode.jmxtrans.example.Ganglia

package com.googlecode.jmxtrans.example;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.googlecode.jmxtrans.JmxTransformer;
import com.googlecode.jmxtrans.guice.JmxTransModule;
import com.googlecode.jmxtrans.model.JmxProcess;
import com.googlecode.jmxtrans.model.Query;
import com.googlecode.jmxtrans.model.Server;
import com.googlecode.jmxtrans.model.output.GangliaWriter;
import com.googlecode.jmxtrans.util.JsonPrinter;

/**
* This class hits a Graphite server running on port 2003 and sends the memory
* usage data to it for graphing.
*
* @author jon
*/
public class Ganglia {

  private static final JsonPrinter printer = new JsonPrinter(System.out);

  public static void main(String[] args) throws Exception {
    printer.prettyPrint(new JmxProcess(Server.builder()
        .setHost("w2")
        .setPort("1099")
        .setAlias("fooalias")
        .addQuery(Query.builder()
            .setObj("java.lang:type=GarbageCollector,name=ConcurrentMarkSweep")
            .addOutputWriter(GangliaWriter.builder()
              .setHost("10.0.3.16")
              .setPort(8649)
              .setDebugEnabled(true)
              .setGroupName("memory")
              .build())
          .build())
        .build()));

    Injector injector = Guice.createInjector(new JmxTransModule(null));
    JmxTransformer transformer = injector.getInstance(JmxTransformer.class);
    transformer.executeStandalone(new JmxProcess(Server.builder()
        .setHost("w2")
        .setPort("1099")
        .setAlias("fooalias")
        .addQuery(Query.builder()
            .setObj("java.lang:type=GarbageCollector,name=ConcurrentMarkSweep")
            .addOutputWriter(GangliaWriter.builder()
              .setHost("10.0.3.16")
              .setPort(8649)
              .setDebugEnabled(true)
              .setGroupName("memory")
              .build())
          .build())
        .build()));
  }

}
TOP

Related Classes of com.googlecode.jmxtrans.example.Ganglia

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.