Search in sources :

Example 1 with RRDToolWriter

use of com.googlecode.jmxtrans.model.output.RRDToolWriter 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)

Aggregations

Injector (com.google.inject.Injector)1 JmxTransformer (com.googlecode.jmxtrans.JmxTransformer)1 JmxTransConfiguration (com.googlecode.jmxtrans.cli.JmxTransConfiguration)1 JmxProcess (com.googlecode.jmxtrans.model.JmxProcess)1 RRDToolWriter (com.googlecode.jmxtrans.model.output.RRDToolWriter)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 File (java.io.File)1 IOException (java.io.IOException)1