Package org.jmxtrans.embedded

Examples of org.jmxtrans.embedded.QueryResult


            String[] parts = myname.split(delims);
            if( parts.length > 0 ) {
                String p1 = parts[0];
                if( (jmxtrans_metric_groupID != null) && (p1.equals("jmxtrans")) )  {
                    QueryResult new_result = new QueryResult(myname, pidHost, myval, epochInMillis);
                    jmxtrans_counters.add(new_result);
                } else if( p1.equals("jvm") ) {
                    if( parts[1].equals("os")) {
                        if (parts[2].equals("OpenFileDescriptorCount")) {
                            QueryResult new_result = new QueryResult(myname, pidHost, myval, epochInMillis);
                            jvm_os_counters.add(new_result);
                        } else if (parts[2].equals("CommittedVirtualMemorySize")){
                            float fval = Float.parseFloat(valstr);
                            try {
                                fval = fval/(1024.0f*1024.0f)
                            } catch (Exception e) {
                                exceptionCounter.incrementAndGet();
                                logger.info("Exception doing Float: ", e);
                            }
                            QueryResult new_result = new QueryResult(myname, pidHost, fval, epochInMillis);
                            jvm_os_counters.add(new_result);
                        } else if (parts[2].equals("ProcessCpuTime")) {
                            float fval = Float.parseFloat(valstr);
                            try {
                                fval = fval/(1000.0f*1000.0f*1000.0f)
                            } catch (Exception e) {
                                exceptionCounter.incrementAndGet();
                                logger.warn("Exception doing Float: ", e);
                            }
                            QueryResult new_result = new QueryResult(myname, pidHost, fval, epochInMillis);
                            jvm_os_counters.add(new_result);
                        }
                    } else if( (parts[1].equals("runtime")) && (parts[2].equals("Uptime")) ) {
                        float fval = Float.parseFloat(valstr);
                        try {
                            fval = fval/(1000.0f*60.0f)
                        } catch (Exception e) {
                            exceptionCounter.incrementAndGet();
                            logger.warn("Exception doing Float: ", e);
                        }
                        QueryResult new_result = new QueryResult(myname, pidHost, fval, epochInMillis);
                        jvm_runtime_counters.add(new_result);
                    } else if( (parts[1].equals("loadedClasses")) && (parts[2].equals("LoadedClassCount")) ) {
                        // jvm.loadedClasses.LoadedClassCount 5099 1374549969
                        QueryResult new_result = new QueryResult(myname, pidHost, myval, epochInMillis);
                        jvm_class_counters.add(new_result);
                    } else if( (parts[1].equals("thread")) && (parts[2].equals("ThreadCount")) ){
                        // jvm.thread.ThreadCount 13 1374549940
                        QueryResult new_result = new QueryResult(myname, pidHost, myval, epochInMillis);
                        jvm_thread_counters.add(new_result);
                    } else if( (parts[1].equals("gc")) &&
                        ( (parts[2].equals("Copy")) ||  (parts[2].equals("MarkSweepCompact")) ) &&
                        ( (parts[3].equals("CollectionCount")) ||  (parts[3].equals("CollectionTime")) ) ) {
                        // jvm.gc.Copy.CollectionCount 68 1374549940
                        QueryResult new_result = new QueryResult(myname, pidHost, myval, epochInMillis);
                        jvm_gc_counters.add(new_result);
                    } else if( parts[1].equals("memorypool") ){
                        if( ( (parts[2].equals("Perm_Gen")) || (parts[2].equals("Code_Cache")) ) &&
                            ( (parts[4].equals("committed")) || (parts[4].equals("used"))  ) ) {    
                            myname = "jvmNonHeapMemoryUsage";
                            String fullID = pidHost + "." + parts[2] + "." + parts[4];
                            float fval = Float.parseFloat(valstr);
                            try {
                                fval = fval/(1024.0f*1024.0f);
                            } catch (Exception e) {
                                exceptionCounter.incrementAndGet();
                                logger.warn("Exception doing Float: ", e);
                            }
                            QueryResult new_result = new QueryResult(myname, fullID, fval, epochInMillis);
                            nonheap_counters.add(new_result);
                        } else if( ( (parts[2].equals("Eden_Space")) ||
                                     (parts[2].equals("Survivor_Space")) ||
                                     (parts[2].equals("Tenured_Gen"))
                                    ) && (  (parts[4].equals("committed")) ||  (parts[4].equals("used"))  ) ) {   
                            myname = "jvmHeapMemoryUsage";
                            String fullID = pidHost + "." + parts[2] + "." + parts[4];
                            float fval = Float.parseFloat(valstr);
                            try {
                                fval = fval/(1024.0f*1024.0f);
                            } catch (Exception e) {
                                exceptionCounter.incrementAndGet();
                                logger.warn("Exception doingFloat: ", e);
                            }
                            QueryResult new_result = new QueryResult(myname, fullID, fval, epochInMillis);
                            heap_counters.add(new_result);
                        }
                    }
                } else if( p1.equals("tomcat") ) {
                    if( (parts[1].equals("thread-pool")) && 
                         ( (parts[3].equals("currentThreadsBusy")) || (parts[3].equals("currentThreadCount")) ) ){
                        // tomcat.thread_pool.http-bio-8080.currentThreadCount 0 1374549955
                        String connector = parts[2];
                        myname = parts[0] + "." + parts[1] + "." + parts[3];
                        String fullID = pidHost + "." + connector;
                        QueryResult new_result = new QueryResult(myname, fullID, myval, epochInMillis);
                        tomcat_thread_pool_counters.add(new_result);
                   } else if( (parts[1].equals("global-request-processor")) ) {
                        // tomcat.global-request-processor.http-bio-8080.bytesSent
                        String connector = parts[2];
                        myname = parts[0] + "." + parts[1] + "." + parts[3];
                        String fullID = pidHost + "." + connector;
                        if( parts[3].equals("processingTime")) {
                            float fval = Float.parseFloat(valstr);
                            try {
                                fval = fval/(1024.0f);
                            } catch (Exception e) {
                                exceptionCounter.incrementAndGet();
                                logger.warn("Exception doingFloat: ", e);
                            }
                            QueryResult new_result = new QueryResult(myname, fullID, fval, epochInMillis);
                            tomcat_grp_counters.add(new_result);
                        } else {
                            QueryResult new_result = new QueryResult(myname, fullID, myval, epochInMillis);
                            tomcat_grp_counters.add(new_result);
                        }
                    } else if( (parts[1].equals("manager"))  && (parts[4].equals("activeSessions")) ){
                        //  tomcat.manager.localhost._docs.activeSessions 0 1374549955
                        String myhost = parts[2];
                        String mycontext = parts[3];
                        myname = parts[0] + "." + parts[1] + "." + parts[4];
                        String fullID = pidHost + "." + myhost + "." + mycontext;
                        QueryResult new_result = new QueryResult(myname, fullID, myval, epochInMillis);
                        tomcat_manager_counters.add(new_result);
                    } else if( (parts[1].equals("servlet")) &&
                          ( (parts[4].equals("processingTime")) ||
                            (parts[4].equals("errorCount")) ||
                            (parts[4].equals("requestCount")) ) ){
                        // tomcat.servlet.__localhost_cocktail-app-1_0_9-SNAPSHOT.spring-mvc.processingTime
                        String myWebmodule = parts[2];
                        String myServletname = parts[3];
                        myname = parts[0] + "." + parts[1] + "." + parts[4];
                        String fullID = pidHost + "." + myWebmodule + "." + myServletname;
                        QueryResult new_result = new QueryResult(myname, fullID, myval, epochInMillis);
                        tomcat_servlet_counters.add(new_result);
                    } else if( (tomcat_db_groupID != null) && (parts[1].equals("data-source")) ) {                  
                        String myhost = parts[2];
                        String mycontext = parts[3];
                        String mydbname = parts[4];
                        myname = parts[0] + "." + parts[1] + "." + parts[5];
                        String fullID = pidHost + "." + myhost + "." + mycontext + "." + mydbname;
                        QueryResult new_result = new QueryResult(myname, fullID, myval, epochInMillis);
                        tomcat_db_counters.add(new_result);
                    }
                } else if( (app_groupID != null) && (p1.equals("cocktail")) ) {
                    if( !(parts[1].equals("CreatedCocktailCount")) &&  !(parts[1].equals("UpdatedCocktailCount")) ) {
                        QueryResult new_result = new QueryResult(myname, pidHost, myval, epochInMillis);
                        app_counters.add(new_result);
                    }
                } else if( ( (app_sales_groupID != null) && (p1.equals("sales")) ) &&
                      ( (parts[1].equals("ordersCounter")) ||
                        (parts[1].equals("itemsCounter")) ||
                        (parts[1].equals("revenueInCentsCounter")) ) ){
                        QueryResult new_result = new QueryResult(myname, pidHost, myval, epochInMillis);
                        app_sales_counters.add(new_result);
                }
            } else {
                logger.warn("parts return NULL!!!");
            }
View Full Code Here


        graphitePickleWriter.stop();
    }

    @Test
    public void testWithOneResult() throws Exception {
        QueryResult queryResult = new QueryResult("testwithoneresult.singleresult", 10, System.currentTimeMillis());
        graphitePickleWriter.write(Collections.singleton(queryResult));
    }
View Full Code Here

    }

    @Test
    public void testWithTwoResult() throws Exception {

        QueryResult queryResult1 = new QueryResult("testwithtworesult.first", 10, System.currentTimeMillis());
        QueryResult queryResult2 = new QueryResult("testwithtworesult.second", 20, System.currentTimeMillis());
        List<QueryResult> results = Arrays.asList(queryResult1, queryResult2);

        graphitePickleWriter.write(results);
    }
View Full Code Here

public class CopperEggWriterTest {
    @Test
    public void testCUESerialize() throws Exception {

        List<QueryResult> counters = Arrays.asList(
                new QueryResult("counter1", "counter", 10, System.currentTimeMillis()),
                new QueryResult("counter2", "counter", 11.11, System.currentTimeMillis() - 1000),
                new QueryResult("counter2", "counter", 12.12, System.currentTimeMillis())

        );

        List<QueryResult> gauges = Arrays.asList(
                new QueryResult("gauge1", "gauge", 9.9, System.currentTimeMillis()),
                new QueryResult("gauge2", "gauge", 12.12, System.currentTimeMillis() - 1000),
                new QueryResult("gauge2", "gauge", 12.12, System.currentTimeMillis())
        );

        CopperEggWriter writer = new CopperEggWriter();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

    }

    @Test
    public void testWithOneCounter() throws Exception {
        List<QueryResult> results = Arrays.asList(
                new QueryResult("test-with-one-counter.singleresult", "counter", 10, System.currentTimeMillis()));
        libratoWriter.write(results);

        Assert.assertThat(libratoWriter.getExceptionCounter(), equalTo(0));
    }
View Full Code Here

    }

    @Test
    public void testWithOneGauge() throws Exception {
        List<QueryResult> results = Arrays.asList(
                new QueryResult("test-with-one-gauge.singleresult", "gauge", 10, System.currentTimeMillis()));
        libratoWriter.write(results);

        Assert.assertThat(libratoWriter.getExceptionCounter(), equalTo(0));
    }
View Full Code Here

    @Test
    public void testWithTwoCounters() throws Exception {

        List<QueryResult> results = Arrays.asList(
                new QueryResult("test-with-two-counters.first", "counter", 10, System.currentTimeMillis()),
                new QueryResult("test-with-two-counters.second", "counter", 20, System.currentTimeMillis()));

        libratoWriter.write(results);

        Assert.assertThat(libratoWriter.getExceptionCounter(), equalTo(0));
    }
View Full Code Here

    @Test
    public void testWithTwoGauges() throws Exception {

        List<QueryResult> results = Arrays.asList(
                new QueryResult("test-with-two-gauges.first", "gauge", 10, System.currentTimeMillis()),
                new QueryResult("test-with-two-gauges.second", "gauge", 20, System.currentTimeMillis()));

        libratoWriter.write(results);

        Assert.assertThat(libratoWriter.getExceptionCounter(), equalTo(0));
    }
View Full Code Here

    @Test
    public void testWithThreeCounters() throws Exception {

        List<QueryResult> results = Arrays.asList(
                new QueryResult("test-with-three-counters.first", "counter", 10, System.currentTimeMillis() - 1000),
                new QueryResult("test-with-three-counters.first", "counter", 20, System.currentTimeMillis()),
                new QueryResult("test-with-three-counters.second", "counter", 30, System.currentTimeMillis()));

        libratoWriter.write(results);

        Assert.assertThat(libratoWriter.getExceptionCounter(), equalTo(0));
    }
View Full Code Here

public class StackdriverWriterTest {
    @Test
    public void testSerialize() throws Exception {

        List<QueryResult> metrics = Arrays.asList(
                new QueryResult("metric1", "counter", 10, System.currentTimeMillis()),
                new QueryResult("metric2", "counter", 11.11, System.currentTimeMillis() - 1000),
                new QueryResult("metric2", "counter", 12.12, System.currentTimeMillis()),
                new QueryResult("metric3", "gauge", 9.9, System.currentTimeMillis()),
                new QueryResult("metric3", "gauge", 12.12, System.currentTimeMillis() - 1000),
                new QueryResult("metric4", "gauge", 12.12, System.currentTimeMillis())

        );
       
        StackdriverWriter writer = new StackdriverWriter();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

TOP

Related Classes of org.jmxtrans.embedded.QueryResult

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.