/** * Handy method which runs the JmxProcess */ public void executeStandalone(JmxProcess process) throws Exception { this.masterServersList = process.getServers(); this.serverScheduler.start(); this.processServersIntoJobs(); // Sleep for 10 seconds to wait for jobs to complete. // There should be a better way, but it seems that way isn't working // right now. Thread.sleep(MILLISECONDS.convert(10, SECONDS)); }
/** * Uses jackson to load json configuration from a File into a full object * tree representation of that json. */ public JmxProcess parseProcess(File file) throws IOException { String fileName = file.getName(); ObjectMapper mapper = fileName.endsWith(".yml") || fileName.endsWith(".yaml") ? yamlMapper : jsonMapper; JsonNode jsonNode = mapper.readTree(file); JmxProcess jmx = mapper.treeToValue(jsonNode, JmxProcess.class); jmx.setName(fileName); return jmx; } }
public JmxProcess(ImmutableList<Server> servers) { this.setServers(servers); }
if (process.isServersMultiThreaded()) { ExecutorService service = null; try { service = Executors.newFixedThreadPool(process.getNumMultiThreadedServers()); for (Server server : process.getServers()) { if (server.getLocalMBeanServer() != null) { service.execute(new ProcessServerThread(server, null)); for (Server server : process.getServers()) { if (server.getLocalMBeanServer() != null) { processServer(server, null);
/** */ 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, null, 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, null, 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, null, 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); }
.build(); JmxProcess process = new JmxProcess(Server.builder() .setHost("w2") .setPort("1105")
public ImmutableList parseServers(Iterable<File> processConfigFiles, boolean continueOnJsonError) throws LifecycleException { ServerListBuilder serverListBuilder = new ServerListBuilder(); for (File processConfigFile : processConfigFiles) { try { JmxProcess process = processConfigUtils.parseProcess(processConfigFile); log.debug("Loaded file: {}", processConfigFile.getAbsolutePath()); serverListBuilder.add(process.getServers()); } catch (Exception ex) { String message = "Error parsing json: " + processConfigFile; // 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(); }
@SuppressWarnings("squid:S1313") // this is an example, no need to make IP addresses configurable public static void main(String[] args) throws Exception { printer.prettyPrint(new JmxProcess(Server.builder() .setHost("w2") .setPort("1099") .addQuery(Query.builder() .setObj("java.lang:type=GarbageCollector,name=ConcurrentMarkSweep") .addOutputWriterFactory(GraphiteWriter.builder() .setHost("192.168.192.133") .setPort(2003) .setDebugEnabled(true) .setRootPrefix("jon.foo.bar") .build()) .build()) .build())); }
/** * Uses jackson to load json configuration from a File into a full object * tree representation of that json. */ public static JmxProcess getJmxProcess(File file) throws JsonParseException, JsonMappingException, IOException { ObjectMapper mapper = new ObjectMapper(); JmxProcess jmx = mapper.readValue(file, JmxProcess.class); jmx.setName(file.getName()); return jmx; }
public JmxProcess(ImmutableList<Server> servers) { this.setServers(servers); }
/** * Handy method which runs the JmxProcess */ public void executeStandalone(JmxProcess process) throws Exception { this.masterServersList = process.getServers(); this.serverScheduler.start(); this.processServersIntoJobs(); // Sleep for 10 seconds to wait for jobs to complete. // There should be a better way, but it seems that way isn't working // right now. Thread.sleep(MILLISECONDS.convert(10, SECONDS)); }
serverBuilder.addQuery(q4); JmxProcess process = new JmxProcess(serverBuilder.build()); printer.prettyPrint(process); Injector injector = JmxTransModule.createInjector(new JmxTransConfiguration());
/** * Uses jackson to load json configuration from a File into a full object * tree representation of that json. */ public JmxProcess parseProcess(File file) throws IOException { String fileName = file.getName(); ObjectMapper mapper = fileName.endsWith(".yml") || fileName.endsWith(".yaml") ? yamlMapper : jsonMapper; JsonNode jsonNode = mapper.readTree(file); JmxProcess jmx = mapper.treeToValue(jsonNode, JmxProcess.class); jmx.setName(fileName); return jmx; } }
/** * Handy method which runs the JmxProcess */ public void executeStandalone(JmxProcess process) throws Exception { if (isRunning) { throw new LifecycleException("Process already started"); } this.masterServersList = process.getServers(); this.serverScheduler.start(); this.processServersIntoJobs(); // Ensure resources are free Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { try { JmxTransformerDynamic.this.stopServices(); } catch (LifecycleException e) { e.printStackTrace(); } } }); isRunning = true; // Sleep for 10 seconds to wait for jobs to complete. // There should be a better way, but it seems that way isn't working // right now. Thread.sleep(MILLISECONDS.convert(10, SECONDS)); }
JmxProcess process = new JmxProcess(Server.builder() .setHost("w2") .setPort("1099")
public static JmxProcess getJmxProcess(String name, InputStream in) throws JsonParseException, JsonMappingException, IOException { JmxProcess jmx = Json.readJsonValue(name, in, JmxProcess.class); jmx.setName(name); return jmx; }
public ImmutableList parseServers(Iterable<File> processConfigFiles, boolean continueOnJsonError) throws LifecycleException { ServerListBuilder serverListBuilder = new ServerListBuilder(); for (File processConfigFile : processConfigFiles) { try { JmxProcess process = processConfigUtils.parseProcess(processConfigFile); log.debug("Loaded file: {}", processConfigFile.getAbsolutePath()); serverListBuilder.add(process.getServers()); } catch (Exception ex) { String message = "Error parsing json: " + processConfigFile; // 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(); }
transformer.executeStandalone(new JmxProcess(Server.builder() .setHost("w2") .setPort("1099")
protected void loadProfile(Container container, Profile profile) throws IOException, LifecycleException { Map<String, byte[]> fileConfigurations = profile.getFileConfigurations(); byte[] bytes = fileConfigurations.get(GRAPH_JSON); if (bytes != null && bytes.length > 0) { JmxProcess process = getJmxProcess(GRAPH_JSON, new ByteArrayInputStream(bytes)); if (process != null) { List<Server> servers = process.getServers(); for (Server server : servers) { configureProfileServer(server, container, profile); } JmxUtils.mergeServerLists(this.masterServersList, servers); } } for (Profile p : profile.getParents()) { loadProfile(container, p); } }
public static void main(String[] args) throws Exception { JmxProcess process = new JmxProcess(Server.builder() .setHost("w2") .setPort("1099")