Search in sources :

Example 11 with JmxProcess

use of com.googlecode.jmxtrans.model.JmxProcess in project jmxtrans by jmxtrans.

the class InfluxDbWriterTests method loadingFromFile.

@Test
public void loadingFromFile() throws URISyntaxException, IOException {
    File input = new File(InfluxDbWriterTests.class.getResource("/influxDB.json").toURI());
    Injector injector = JmxTransModule.createInjector(new JmxTransConfiguration());
    JsonUtils jsonUtils = injector.getInstance(JsonUtils.class);
    JmxProcess process = jsonUtils.parseProcess(input);
    assertThat(process.getName()).isEqualTo("influxDB.json");
}
Also used : JmxTransConfiguration(com.googlecode.jmxtrans.cli.JmxTransConfiguration) JsonUtils(com.googlecode.jmxtrans.util.JsonUtils) Injector(com.google.inject.Injector) JmxProcess(com.googlecode.jmxtrans.model.JmxProcess) File(java.io.File) Test(org.junit.Test)

Example 12 with JmxProcess

use of com.googlecode.jmxtrans.model.JmxProcess in project jmxtrans by jmxtrans.

the class InterestingInfo method main.

// this is an example, no need to make IP addresses configurable
@SuppressWarnings("squid:S1313")
public static void main(String[] args) throws Exception {
    Server.Builder serverBuilder = Server.builder().setHost("w2").setPort("1099").setNumQueryThreads(2);
    Map<String, Object> settings = newHashMap();
    settings.put(GraphiteWriter.HOST, "192.168.192.133");
    settings.put(GraphiteWriter.PORT, 2003);
    GraphiteWriter gw = GraphiteWriter.builder().setHost("192.168.192.133").setPort(2003).build();
    StdOutWriter sw = new StdOutWriter(ImmutableList.<String>of(), false, false, Collections.<String, Object>emptyMap());
    Query q = Query.builder().setObj("java.lang:type=Memory").addAttr("HeapMemoryUsage").addAttr("NonHeapMemoryUsage").addOutputWriterFactories(gw, sw).build();
    serverBuilder.addQuery(q);
    Query q2 = Query.builder().setObj("java.lang:type=Threading").addAttr("DaemonThreadCount").addAttr("PeakThreadCount").addAttr("ThreadCount").addOutputWriterFactories(gw, sw).build();
    serverBuilder.addQuery(q2);
    Query q3 = Query.builder().setObj("java.lang:name=ConcurrentMarkSweep,type=GarbageCollector").addAttr("LastGcInfo").addOutputWriterFactories(gw, sw).build();
    serverBuilder.addQuery(q3);
    Query q4 = Query.builder().setObj("java.lang:name=ParNew,type=GarbageCollector").addAttr("LastGcInfo").addOutputWriterFactories(gw, sw).build();
    serverBuilder.addQuery(q4);
    JmxProcess process = new JmxProcess(serverBuilder.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) 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) StdOutWriter(com.googlecode.jmxtrans.model.output.StdOutWriter)

Example 13 with JmxProcess

use of com.googlecode.jmxtrans.model.JmxProcess in project jmxtrans by jmxtrans.

the class Local method main.

public static void main(String[] args) throws Exception {
    Injector injector = JmxTransModule.createInjector(new JmxTransConfiguration());
    JsonUtils jsonUtils = injector.getInstance(JsonUtils.class);
    JmxProcess process = jsonUtils.parseProcess(new File("local.json"));
    new JsonPrinter(System.out).print(process);
    JmxTransformer transformer = injector.getInstance(JmxTransformer.class);
    transformer.executeStandalone(process);
}
Also used : JmxTransConfiguration(com.googlecode.jmxtrans.cli.JmxTransConfiguration) JmxTransformer(com.googlecode.jmxtrans.JmxTransformer) JsonUtils(com.googlecode.jmxtrans.util.JsonUtils) Injector(com.google.inject.Injector) JmxProcess(com.googlecode.jmxtrans.model.JmxProcess) File(java.io.File)

Example 14 with JmxProcess

use of com.googlecode.jmxtrans.model.JmxProcess in project jmxtrans by jmxtrans.

the class MemoryPool method main.

public static void main(String[] args) throws Exception {
    Injector injector = JmxTransModule.createInjector(new JmxTransConfiguration());
    JsonUtils jsonUtils = injector.getInstance(JsonUtils.class);
    JmxProcess process = jsonUtils.parseProcess(new File("memorypool.json"));
    new JsonPrinter(System.out).print(process);
    JmxTransformer transformer = injector.getInstance(JmxTransformer.class);
    transformer.executeStandalone(process);
}
Also used : JmxTransConfiguration(com.googlecode.jmxtrans.cli.JmxTransConfiguration) JmxTransformer(com.googlecode.jmxtrans.JmxTransformer) JsonUtils(com.googlecode.jmxtrans.util.JsonUtils) Injector(com.google.inject.Injector) JmxProcess(com.googlecode.jmxtrans.model.JmxProcess) File(java.io.File)

Example 15 with JmxProcess

use of com.googlecode.jmxtrans.model.JmxProcess in project jmxtrans by jmxtrans.

the class Tester method main.

/** */
public static void main(String[] args) throws Exception {
    Server server = Server.builder().setHost("w2").setPort("1099").setNumQueryThreads(2).addQuery(Query.builder().setObj("java.lang:type=Memory").addAttr("HeapMemoryUsage", "NonHeapMemoryUsage").addOutputWriterFactory(new StdOutWriter(ImmutableList.<String>of(), false, false, Collections.<String, Object>emptyMap())).build()).addQuery(Query.builder().setObj("java.lang:name=CMS Old Gen,type=MemoryPool").addAttr("Usage").addOutputWriterFactory(new StdOutWriter(ImmutableList.<String>of(), false, false, Collections.<String, Object>emptyMap())).build()).addQuery(Query.builder().setObj("java.lang:name=ConcurrentMarkSweep,type=GarbageCollector").addAttr("LastGcInfo").addOutputWriterFactory(new StdOutWriter(ImmutableList.<String>of(), false, false, Collections.<String, Object>emptyMap())).build()).build();
    JmxProcess process = new JmxProcess(server);
    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) Server(com.googlecode.jmxtrans.model.Server) Injector(com.google.inject.Injector) JmxProcess(com.googlecode.jmxtrans.model.JmxProcess) StdOutWriter(com.googlecode.jmxtrans.model.output.StdOutWriter)

Aggregations

JmxProcess (com.googlecode.jmxtrans.model.JmxProcess)15 JmxTransConfiguration (com.googlecode.jmxtrans.cli.JmxTransConfiguration)12 Injector (com.google.inject.Injector)11 JmxTransformer (com.googlecode.jmxtrans.JmxTransformer)10 File (java.io.File)8 JsonUtils (com.googlecode.jmxtrans.util.JsonUtils)5 Server (com.googlecode.jmxtrans.model.Server)4 Query (com.googlecode.jmxtrans.model.Query)3 GraphiteWriter (com.googlecode.jmxtrans.model.output.GraphiteWriter)2 StdOutWriter (com.googlecode.jmxtrans.model.output.StdOutWriter)2 Test (org.junit.Test)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 LifecycleException (com.googlecode.jmxtrans.exceptions.LifecycleException)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 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1