use of com.googlecode.jmxtrans.model.Server in project jmxtrans by jmxtrans.
the class TreeWalker method main.
public static void main(String[] args) throws Exception {
Server server = Server.builder().setHost("localhost").setPort("1099").build();
JMXConnector conn = null;
try {
conn = server.getServerConnection();
MBeanServerConnection mbeanServer = conn.getMBeanServerConnection();
TreeWalker tw = new TreeWalker();
tw.walkTree(mbeanServer);
} catch (IOException e) {
log.error("Problem processing queries for server: " + server.getHost() + ":" + server.getPort(), e);
} finally {
if (conn != null) {
conn.close();
}
}
}
use of com.googlecode.jmxtrans.model.Server in project jmxtrans by jmxtrans.
the class TreeWalker2 method main.
/** */
public static void main(String[] args) throws Exception {
Server server = Server.builder().setHost("localhost").setPort("1099").build();
JMXConnector conn = null;
try {
conn = server.getServerConnection();
MBeanServerConnection mbeanServer = conn.getMBeanServerConnection();
TreeWalker2 tw = new TreeWalker2();
tw.walkTree(mbeanServer, server);
} catch (IOException e) {
log.error("Problem processing queries for server: " + server.getHost() + ":" + server.getPort(), e);
} finally {
if (conn != null) {
conn.close();
}
}
}
use of com.googlecode.jmxtrans.model.Server in project jmxtrans by jmxtrans.
the class TreeWalker3 method main.
/** */
public static void main(String[] args) throws Exception {
Server server = Server.builder().setHost("w2").setPort("1105").build();
JMXConnector conn = null;
try {
conn = server.getServerConnection();
MBeanServerConnection mbeanServer = conn.getMBeanServerConnection();
TreeWalker3 tw = new TreeWalker3();
tw.walkTree(mbeanServer, server);
} catch (IOException e) {
log.error("Problem processing queries for server: " + server.getHost() + ":" + server.getPort(), e);
} finally {
if (conn != null) {
conn.close();
}
}
}
use of com.googlecode.jmxtrans.model.Server in project jmxtrans by jmxtrans.
the class GraphiteWriterFactoryIT method canParseConfigurationFile.
@Test
public void canParseConfigurationFile() throws LifecycleException, URISyntaxException {
ImmutableList<Server> servers = configurationParser.parseServers(ImmutableList.of(file("/graphite-writer-factory-example.json")), false);
assertThat(servers).hasSize(1);
Server server = servers.get(0);
assertThat(server.getNumQueryThreads()).isEqualTo(2);
assertThat(server.getQueries()).hasSize(1);
Query query = server.getQueries().iterator().next();
assertThat(query.getOutputWriterInstances()).hasSize(1);
OutputWriter outputWriter = query.getOutputWriterInstances().iterator().next();
assertThat(outputWriter).isInstanceOf(ResultTransformerOutputWriter.class);
}
use of com.googlecode.jmxtrans.model.Server in project jmxtrans by jmxtrans.
the class BaseOutputWriterTests method booleanValuesAreTransformedToNumber.
@Test
public void booleanValuesAreTransformedToNumber() throws Exception {
final ArrayList<Result> processedResults = Lists.newArrayList();
BaseOutputWriter outputWriter = new BaseOutputWriter(ImmutableList.<String>of(), true, false, Maps.<String, Object>newHashMap()) {
@Override
protected void internalWrite(Server server, Query query, ImmutableList<Result> results) throws Exception {
processedResults.addAll(results);
}
@Override
public void validateSetup(Server server, Query query) throws ValidationException {
}
};
Result result = new Result(0, "", "", "", "", "", ImmutableMap.<String, Object>of("true", true, "false", false));
outputWriter.doWrite(null, null, ImmutableList.of(result));
assertThat(processedResults).hasSize(1);
Result processedResult = processedResults.get(0);
assertThat(processedResult.getValues().get("true")).isEqualTo(1);
assertThat(processedResult.getValues().get("false")).isEqualTo(0);
}
Aggregations