use of com.googlecode.jmxtrans.model.output.StdOutWriter 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);
}
use of com.googlecode.jmxtrans.model.output.StdOutWriter 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);
}
use of com.googlecode.jmxtrans.model.output.StdOutWriter in project jmxtrans by jmxtrans.
the class TreeWalker2 method walkTree.
public void walkTree(MBeanServerConnection connection, Server server) throws Exception {
// key here is null, null returns everything!
Set<ObjectName> mbeans = connection.queryNames(null, null);
for (ObjectName name : mbeans) {
MBeanInfo info = connection.getMBeanInfo(name);
MBeanAttributeInfo[] attrs = info.getAttributes();
Query.Builder queryBuilder = Query.builder().setObj(name.getCanonicalName()).addOutputWriterFactory(new StdOutWriter(ImmutableList.<String>of(), false, false, Collections.<String, Object>emptyMap()));
for (MBeanAttributeInfo attrInfo : attrs) {
queryBuilder.addAttr(attrInfo.getName());
}
Query query = queryBuilder.build();
try {
Iterable<Result> results = server.execute(query);
query.runOutputWritersForQuery(server, results);
} catch (AttributeNotFoundException anfe) {
log.error("Error", anfe);
}
}
}
Aggregations