Search in sources :

Example 6 with JmxProcess

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

Example 7 with JmxProcess

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

the class HeapMemory 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("heapmemory.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 8 with JmxProcess

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

the class Hibernate method main.

public static void main(String[] args) throws Exception {
    JmxProcess process = new JmxProcess(Server.builder().setHost("w2").setPort("1099").setAlias("w2_hibernate_1099").addQuery(Query.builder().setObj("org.hibernate.jmx:name=*,type=StatisticsService").addAttr("EntityDeleteCount").addAttr("EntityInsertCount").addAttr("EntityLoadCount").addAttr("EntityFetchCount").addAttr("EntityUpdateCount").addAttr("QueryExecutionCount").addAttr("QueryCacheHitCount").addAttr("QueryExecutionMaxTime").addAttr("QueryCacheMissCount").addAttr("QueryCachePutCount").addAttr("FlushCount").addAttr("ConnectCount").addAttr("SecondLevelCacheHitCount").addAttr("SecondLevelCacheMissCount").addAttr("SecondLevelCachePutCount").addAttr("SessionCloseCount").addAttr("SessionOpenCount").addAttr("CollectionLoadCount").addAttr("CollectionFetchCount").addAttr("CollectionUpdateCount").addAttr("CollectionRemoveCount").addAttr("CollectionRecreateCount").addAttr("SuccessfulTransactionCount").addAttr("TransactionCount").addAttr("CloseStatementCount").addAttr("PrepareStatementCount").addAttr("OptimisticFailureCount").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 9 with JmxProcess

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

the class ConfigurationParser method parseServers.

public ImmutableList parseServers(Iterable<File> jsonFiles, boolean continueOnJsonError) throws LifecycleException {
    ServerListBuilder serverListBuilder = new ServerListBuilder();
    for (File jsonFile : jsonFiles) {
        try {
            JmxProcess process = jsonUtils.parseProcess(jsonFile);
            log.debug("Loaded file: {}", jsonFile.getAbsolutePath());
            serverListBuilder.add(process.getServers());
        } catch (Exception ex) {
            String message = "Error parsing json: " + jsonFile;
            // error parsing one file should not prevent the startup of JMXTrans
            if (continueOnJsonError)
                log.error(message, ex);
            else
                throw new LifecycleException(message, ex);
        }
    }
    return serverListBuilder.build();
}
Also used : LifecycleException(com.googlecode.jmxtrans.exceptions.LifecycleException) JmxProcess(com.googlecode.jmxtrans.model.JmxProcess) File(java.io.File) LifecycleException(com.googlecode.jmxtrans.exceptions.LifecycleException)

Example 10 with JmxProcess

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

the class CloudWatchWriterIT method loadingFromFile.

@Test
public void loadingFromFile() throws URISyntaxException, IOException {
    JsonUtils jsonUtils = createInjector(new JmxTransConfiguration()).getInstance(JsonUtils.class);
    File input = new File(CloudWatchWriterIT.class.getResource("/cloud-watch.json").toURI());
    JmxProcess process = jsonUtils.parseProcess(input);
    assertThat(process.getName()).isEqualTo("cloud-watch.json");
}
Also used : JmxTransConfiguration(com.googlecode.jmxtrans.cli.JmxTransConfiguration) JsonUtils(com.googlecode.jmxtrans.util.JsonUtils) JmxProcess(com.googlecode.jmxtrans.model.JmxProcess) File(java.io.File) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) IntegrationTest(com.googlecode.jmxtrans.test.IntegrationTest) Test(org.junit.Test)

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