Package com.googlecode.jmxtrans.model

Examples of com.googlecode.jmxtrans.model.Server


        logger.info("Exchange Metric Collector started");
        while(true) {
            JmxProcess jmxProcess = new JmxProcess();
            for(Broker broker : brokerFarm.getAllBrokers().values()) {
                if(broker.getStatus() == Broker.Status.ONLINE) {
                    Server server = new Server();
                    server.setHost(broker.getHost());
                    server.setUsername("admin");
                    server.setPassword("admin");
                    String jmxurl = getJMXUrl(broker.getHost());
                    if(jmxurl == null) {
                        logger.error("cannot obtain JMX URL from broker {}", broker.getHost());
                        continue;
                    }
                    server.setUrl(jmxurl);

                    try {
                        server.addQuery(createMonitorQuery());
                        server.addQuery(createConfigQuery());
                    }
                    catch(ValidationException e) {
                        e.printStackTrace();
                    }
                    jmxProcess.addServer(server);
View Full Code Here


    }
  }

  private JmxProcess standardProcess() {
    List<Server> servers = new ArrayList<Server>();
    Server server = Server.builder()
        .setAlias("alias")
        .setHost("example.org")
        .setPort("123")
        .addQuery(Query.builder()
          .setObj("obj")
View Full Code Here

  }

  @Test
  public void writeSingleResult() throws Exception {
    // a lot of setup for not much of a test ...
    Server server = Server.builder().setHost("host").setPort("123").build();
    Query query = Query.builder().build();
    Result result = new Result("attributeName", "className", "classNameAlias", "typeName", ImmutableMap.of("key", (Object)1));

    GenericKeyedObjectPool<InetSocketAddress, Socket> pool = mock(GenericKeyedObjectPool.class);
    Socket socket = mock(Socket.class);
View Full Code Here

    File input = new File(JsonUtilsTest.class.getResource("/example.json").toURI());

    JmxProcess process = JsonUtils.getJmxProcess(input);
    assertThat(process.getName()).isEqualTo("example.json");

    Server server = process.getServers().get(0);
    assertThat(server.getNumQueryThreads()).isEqualTo(2);

    Optional<Query> queryOptional = from(server.getQueries()).firstMatch(new ByObj("java.lang:type=Memory"));
    assertThat(queryOptional.isPresent()).isTrue();
    assertThat(queryOptional.get().getAttr().get(0)).isEqualTo("HeapMemoryUsage");
  }
View Full Code Here

    public void testValidationMinimalSettings() throws ValidationException {
    GangliaWriter writer = GangliaWriter.builder().setHost("192.168.1.144").build();
        Query test = Query.builder()
        .setObj("test")
        .build();
    Server server = Server.builder().setHost("localhost").setPort("123").build();
    writer.validateSetup(server, test);
        assertEquals("192.168.1.144", writer.getHost());
        assertEquals(GangliaWriter.DEFAULT_PORT, writer.getPort());
        assertEquals(GangliaWriter.DEFAULT_ADDRESSING_MODE.name(), writer.getAddressingMode());
        assertEquals(GangliaWriter.DEFAULT_TTL, writer.getTtl());
View Full Code Here

        .build();

        Query test = Query.builder()
        .setObj("test")
        .build();
    Server server = Server.builder().setHost("localhost").setPort("123").build();
    writer.validateSetup(server, test);
        assertEquals("192.168.1.144", writer.getHost());
        assertEquals(25654, writer.getPort());
        assertEquals(GMetric.UDPAddressingMode.MULTICAST.name(), writer.getAddressingMode());
        assertEquals(4, writer.getTtl());
View Full Code Here

  private static final Logger log = LoggerFactory.getLogger(TreeWalker3.class);

  /** */
  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);
    } catch (IOException e) {
      log.error("Problem processing queries for server: " + server.getHost() + ":" + server.getPort(), e);
    } finally {
      if (conn != null) {
        conn.close();
      }
    }
View Full Code Here

  private static final JsonPrinter printer = new JsonPrinter(System.out);

  /** */
  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")
View Full Code Here

  private static final Logger log = LoggerFactory.getLogger(TreeWalker2.class);

  /** */
  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);
    } catch (IOException e) {
      log.error("Problem processing queries for server: " + server.getHost() + ":" + server.getPort(), e);
    } finally {
      if (conn != null) {
        conn.close();
      }
    }
View Full Code Here

    this.jmxUtils = jmxUtils;
  }

  public void execute(JobExecutionContext context) throws JobExecutionException {
    JobDataMap map = context.getMergedJobDataMap();
    Server server = (Server) map.get(Server.class.getName());

    log.debug("+++++ Started server job: {}", server);

    JMXConnector conn = null;
    JMXConnectionParams connectionParams = null;
    try {
      connectionParams = new JMXConnectionParams(server.getJmxServiceURL(), server.getEnvironment());
      if (!server.isLocal()) {
        conn = jmxPool.borrowObject(connectionParams);
      }
      jmxUtils.processServer(server, conn);
    } catch (Exception e) {
      log.error("Error in job for server: " + server, e);
View Full Code Here

TOP

Related Classes of com.googlecode.jmxtrans.model.Server

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.