Search in sources :

Example 1 with JmxTransConfiguration

use of com.googlecode.jmxtrans.cli.JmxTransConfiguration in project jmxtrans by jmxtrans.

the class JsonUtilsTest method setupJsonUtils.

@Before
public void setupJsonUtils() {
    Injector injector = JmxTransModule.createInjector(new JmxTransConfiguration());
    jsonUtils = injector.getInstance(JsonUtils.class);
    closer.register(ResetableSystemProperty.setSystemProperty("server.port", "1099"));
    closer.register(ResetableSystemProperty.setSystemProperty("server.attribute", "HeapMemoryUsage"));
    closer.register(ResetableSystemProperty.setSystemProperty("server.thread", "2"));
}
Also used : JmxTransConfiguration(com.googlecode.jmxtrans.cli.JmxTransConfiguration) Injector(com.google.inject.Injector) Before(org.junit.Before)

Example 2 with JmxTransConfiguration

use of com.googlecode.jmxtrans.cli.JmxTransConfiguration in project jmxtrans by jmxtrans.

the class ActiveMQ method main.

public static void main(String[] args) throws Exception {
    Server.Builder serverBuilder = Server.builder().setHost("w2").setPort("1105").setAlias("w2_activemq_1105");
    GraphiteWriter gw = GraphiteWriter.builder().addTypeName("destinationName").addTypeName("Destination").setDebugEnabled(true).setHost(GW_HOST).setPort(2003).build();
    Query q = Query.builder().setObj("org.apache.activemq:BrokerName=localhost,Type=Subscription,clientId=*,consumerId=*,destinationName=*,destinationType=Queue,persistentMode=Non-Durable").addAttr("PendingQueueSize").addAttr("DispatchedQueueSize").addAttr("EnqueueCounter").addAttr("DequeueCounter").addAttr("MessageCountAwaitingAcknowledge").addAttr("DispachedCounter").addOutputWriterFactory(gw).build();
    serverBuilder.addQuery(q);
    Query q2 = Query.builder().setObj("org.apache.activemq:BrokerName=localhost,Destination=ActiveMQ.Advisory.Consumer.Queue.*,Type=Topic").addAttr("QueueSize").addAttr("MaxEnqueueTime").addAttr("MinEnqueueTime").addAttr("AverageEnqueueTime").addAttr("InFlightCount").addAttr("ConsumerCount").addAttr("ProducerCount").addAttr("DispatchCount").addAttr("DequeueCount").addAttr("EnqueueCount").addAttr("Subscriptions").addOutputWriterFactory(gw).build();
    serverBuilder.addQuery(q2);
    Query q3 = Query.builder().setObj("org.apache.activemq:BrokerName=localhost,Destination=*,Type=Queue").addAttr("QueueSize").addAttr("MaxEnqueueTime").addAttr("MinEnqueueTime").addAttr("AverageEnqueueTime").addAttr("InFlightCount").addAttr("ConsumerCount").addAttr("ProducerCount").addAttr("DispatchCount").addAttr("DequeueCount").addAttr("EnqueueCount").addAttr("Subscriptions").addOutputWriterFactory(gw).build();
    serverBuilder.addQuery(q3);
    Query q4 = Query.builder().setObj("org.apache.activemq:BrokerName=localhost,Destination=*,Type=Topic").addAttr("QueueSize").addAttr("MaxEnqueueTime").addAttr("MinEnqueueTime").addAttr("AverageEnqueueTime").addAttr("InFlightCount").addAttr("ConsumerCount").addAttr("ProducerCount").addAttr("DispatchCount").addAttr("DequeueCount").addAttr("EnqueueCount").addAttr("Subscriptions").addOutputWriterFactory(gw).build();
    serverBuilder.addQuery(q4);
    Query q5 = Query.builder().setObj("org.apache.activemq:BrokerName=localhost,Type=Broker").addOutputWriterFactory(gw).build();
    serverBuilder.addQuery(q5);
    Query q6 = Query.builder().setObj("java.lang:type=Memory").addAttr("HeapMemoryUsage").addAttr("NonHeapMemoryUsage").addOutputWriterFactory(gw).build();
    serverBuilder.addQuery(q6);
    Query q7 = Query.builder().setObj("java.lang:type=Threading").addAttr("DaemonThreadCount").addAttr("PeakThreadCount").addAttr("ThreadCount").addAttr("CurrentThreadCpuTime").addAttr("CurrentThreadUserTime").addAttr("TotalStartedThreadCount").addOutputWriterFactory(gw).build();
    serverBuilder.addQuery(q7);
    Query q8 = Query.builder().setObj("java.lang:name=*,type=GarbageCollector").addKey("committed").addKey("init").addKey("max").addKey("used").addKey("duration").addKey("CollectionCount").addKey("CollectionTime").addOutputWriterFactory(gw).build();
    serverBuilder.addQuery(q8);
    Query q9 = Query.builder().setObj("java.lang:type=MemoryPool,name=*").addOutputWriterFactory(GraphiteWriter.builder().addTypeName("name").setDebugEnabled(true).setHost(GW_HOST).setPort(2003).build()).build();
    serverBuilder.addQuery(q9);
    JmxProcess process = new JmxProcess(serverBuilder.build());
    new JsonPrinter(System.out).prettyPrint(process);
    Injector injector = JmxTransModule.createInjector(new JmxTransConfiguration());
    JmxTransformer transformer = injector.getInstance(JmxTransformer.class);
    transformer.executeStandalone(process);
}
Also used : JmxTransConfiguration(com.googlecode.jmxtrans.cli.JmxTransConfiguration) JmxTransformer(com.googlecode.jmxtrans.JmxTransformer) GraphiteWriter(com.googlecode.jmxtrans.model.output.GraphiteWriter) Server(com.googlecode.jmxtrans.model.Server) Query(com.googlecode.jmxtrans.model.Query) Injector(com.google.inject.Injector) JmxProcess(com.googlecode.jmxtrans.model.JmxProcess)

Example 3 with JmxTransConfiguration

use of com.googlecode.jmxtrans.cli.JmxTransConfiguration in project jmxtrans by jmxtrans.

the class ActiveMQ2 method main.

@SuppressFBWarnings(value = "DMI_HARDCODED_ABSOLUTE_FILENAME", justification = "Path to RRD binary is hardcoded as this is example code")
public static void main(String[] args) throws Exception {
    File outputFile = new File("target/w2-TEST.rrd");
    if (!outputFile.exists() && !outputFile.createNewFile()) {
        throw new IOException("Could not create output file");
    }
    RRDToolWriter gw = RRDToolWriter.builder().setTemplateFile(new File("memorypool-rrd-template.xml")).setOutputFile(outputFile).setBinaryPath(new File("/opt/local/bin")).setDebugEnabled(true).setGenerate(true).addTypeName("Destination").build();
    JmxProcess process = new JmxProcess(Server.builder().setHost("w2").setPort("1105").setAlias("w2_activemq_1105").addQuery(Query.builder().setObj("org.apache.activemq:BrokerName=localhost,Type=Queue,Destination=*").addAttr("QueueSize").addAttr("MaxEnqueueTime").addAttr("MinEnqueueTime").addAttr("AverageEnqueueTime").addAttr("InFlightCount").addAttr("ConsumerCount").addAttr("ProducerCount").addAttr("DispatchCount").addAttr("DequeueCount").addAttr("EnqueueCount").addOutputWriterFactory(gw).build()).addQuery(Query.builder().setObj("org.apache.activemq:BrokerName=localhost,Type=Topic,Destination=*").addAttr("QueueSize").addAttr("MaxEnqueueTime").addAttr("MinEnqueueTime").addAttr("AverageEnqueueTime").addAttr("InFlightCount").addAttr("ConsumerCount").addAttr("ProducerCount").addAttr("DispatchCount").addAttr("DequeueCount").addAttr("EnqueueCount").addOutputWriterFactory(gw).build()).build());
    jsonPrinter.prettyPrint(process);
    Injector injector = JmxTransModule.createInjector(new JmxTransConfiguration());
    JmxTransformer transformer = injector.getInstance(JmxTransformer.class);
    transformer.executeStandalone(process);
}
Also used : JmxTransConfiguration(com.googlecode.jmxtrans.cli.JmxTransConfiguration) JmxTransformer(com.googlecode.jmxtrans.JmxTransformer) Injector(com.google.inject.Injector) JmxProcess(com.googlecode.jmxtrans.model.JmxProcess) IOException(java.io.IOException) RRDToolWriter(com.googlecode.jmxtrans.model.output.RRDToolWriter) File(java.io.File) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 4 with JmxTransConfiguration

use of com.googlecode.jmxtrans.cli.JmxTransConfiguration in project jmxtrans by jmxtrans.

the class Ehcache method main.

/** */
public static void main(String[] args) throws Exception {
    JmxProcess process = new JmxProcess(Server.builder().setHost("w2").setPort("1099").setAlias("w2_ehcache_1099").addQuery(Query.builder().setObj("net.sf.ehcache:CacheManager=net.sf.ehcache.CacheManager@*,name=*,type=CacheStatistics").addAttr("CacheHits").addAttr("InMemoryHits").addAttr("OnDiskHits").addAttr("CacheMisses").addAttr("ObjectCount").addAttr("MemoryStoreObjectCount").addAttr("DiskStoreObjectCount").addOutputWriterFactory(GraphiteWriter.builder().addTypeName("name").setDebugEnabled(true).setHost(GW_HOST).setPort(2003).build()).build()).build());
    printer.prettyPrint(process);
    Injector injector = JmxTransModule.createInjector(new JmxTransConfiguration());
    JmxTransformer transformer = injector.getInstance(JmxTransformer.class);
    transformer.executeStandalone(process);
}
Also used : JmxTransConfiguration(com.googlecode.jmxtrans.cli.JmxTransConfiguration) JmxTransformer(com.googlecode.jmxtrans.JmxTransformer) Injector(com.google.inject.Injector) JmxProcess(com.googlecode.jmxtrans.model.JmxProcess)

Example 5 with JmxTransConfiguration

use of com.googlecode.jmxtrans.cli.JmxTransConfiguration in project jmxtrans by jmxtrans.

the class Ganglia method main.

// this is an example, no need to make IP addresses configurable
@SuppressWarnings("squid:S1313")
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").addOutputWriterFactory(GangliaWriter.builder().setHost("10.0.3.16").setPort(8649).setDebugEnabled(true).setGroupName("memory").build()).build()).build()));
    Injector injector = JmxTransModule.createInjector(new JmxTransConfiguration());
    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").addOutputWriterFactory(GangliaWriter.builder().setHost("10.0.3.16").setPort(8649).setDebugEnabled(true).setGroupName("memory").build()).build()).build()));
}
Also used : JmxTransConfiguration(com.googlecode.jmxtrans.cli.JmxTransConfiguration) JmxTransformer(com.googlecode.jmxtrans.JmxTransformer) Injector(com.google.inject.Injector) JmxProcess(com.googlecode.jmxtrans.model.JmxProcess)

Aggregations

JmxTransConfiguration (com.googlecode.jmxtrans.cli.JmxTransConfiguration)18 Injector (com.google.inject.Injector)15 JmxProcess (com.googlecode.jmxtrans.model.JmxProcess)12 JmxTransformer (com.googlecode.jmxtrans.JmxTransformer)10 File (java.io.File)7 JsonUtils (com.googlecode.jmxtrans.util.JsonUtils)6 Before (org.junit.Before)4 Server (com.googlecode.jmxtrans.model.Server)3 Test (org.junit.Test)3 Query (com.googlecode.jmxtrans.model.Query)2 GraphiteWriter (com.googlecode.jmxtrans.model.output.GraphiteWriter)2 StdOutWriter (com.googlecode.jmxtrans.model.output.StdOutWriter)2 ConfigurationParser (com.googlecode.jmxtrans.ConfigurationParser)1 ClassLoaderEnricher (com.googlecode.jmxtrans.classloader.ClassLoaderEnricher)1 JCommanderArgumentParser (com.googlecode.jmxtrans.cli.JCommanderArgumentParser)1 RRDToolWriter (com.googlecode.jmxtrans.model.output.RRDToolWriter)1 IntegrationTest (com.googlecode.jmxtrans.test.IntegrationTest)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 IOException (java.io.IOException)1 Date (java.util.Date)1