Package com.jitlogic.zorka.core.integ

Examples of com.jitlogic.zorka.core.integ.NrpePacket


public class NagiosAgentUnitTest extends ZorkaFixture {


    @Test
    public void testReadAndDecodeNrpePacket() throws Exception {
        NrpePacket pkt = NrpePacket.fromStream(getClass().getResourceAsStream("/nagios/test_nrpe.bin"));

        assertEquals(2, pkt.getVersion());
        assertEquals(1, pkt.getType());
        assertEquals("zorka.version[]", pkt.getData());
    }
View Full Code Here


    }


    @Test
    public void testEncodeAndDecodePacket() throws Exception{
        NrpePacket pkt = NrpePacket.newInstance((short)2, (short)1, (short)1, "oja!");
        ByteArrayOutputStream os = new ByteArrayOutputStream(1036);

        pkt.encode(os);
        byte[] buf = os.toByteArray();
        assertEquals(1036, buf.length);

        NrpePacket pkt2 = NrpePacket.fromStream(new ByteArrayInputStream(buf));

        assertEquals(pkt.getVersion(), pkt2.getVersion());
        assertEquals(pkt.getType(), pkt2.getType());
        assertEquals(pkt.getResultCode(), pkt2.getResultCode());
        assertEquals(pkt.getData(), pkt2.getData());
    }
View Full Code Here

        assertEquals(pkt.getData(), pkt2.getData());
    }

    @Test
    public void testEncodeAndDecodeWithNegativeCrc() throws Exception {
        NrpePacket pkt = NrpePacket.newInstance(2, NrpePacket.QUERY_PACKET, 3, "zorka.version[]");

        ByteArrayOutputStream os = new ByteArrayOutputStream(1036);

        pkt.encode(os);
        byte[] buf = os.toByteArray();
        assertEquals(1036, buf.length);

        NrpePacket pkt2 = NrpePacket.fromStream(new ByteArrayInputStream(buf));

        assertEquals(pkt.getVersion(), pkt2.getVersion());
        assertEquals(pkt.getType(), pkt2.getType());
        assertEquals(pkt.getResultCode(), pkt2.getResultCode());
        assertEquals(pkt.getData(), pkt2.getData());
    }
View Full Code Here


    private String query(String query) throws Exception{
        Socket client = new Socket("127.0.0.1", 5669);

        NrpePacket request = NrpePacket.newInstance(2, NrpePacket.QUERY_PACKET, 3, "zorka.version[]");
        request.encode(client.getOutputStream());
        client.getOutputStream().flush();

        NrpePacket response = NrpePacket.fromStream(client.getInputStream());

        return response.getData();
    }
View Full Code Here

                .metric(perfmon.metric("TEST", "B"))
        ).withSummaryLine("TEST ${STATUS} - test item ${ATTR.name} ${LVAL0} ${UNIT0}; ")
         .withFirstResult().withLabel("${name}")
         .withPerfLine("${LABEL}=${LVAL0}${UNIT0};${LVAL0}");

        NrpePacket pkt = cmd.cmd();

        assertNotNull("should return some packet", pkt);
        assertEquals(NrpePacket.OK, pkt.getResultCode());
        assertEquals("TEST OK - test item bean1 10 B; | bean1=10B;10", pkt.getData());
    }
View Full Code Here

                ).withSummaryLine("TEST ${STATUS} - test items summary ${LVAL0} ${UNIT0}; ")
                 .withLabel("${name}").withSumResult("sum")
                 .withTextLine("${ATTR.name} ${LVAL0} ${UNIT0}; ")
                 .withPerfLine("${LABEL}=${LVAL0}${UNIT0};${LVAL0}");

        NrpePacket pkt = cmd.cmd();

        assertNotNull("should return some packet", pkt);
        assertEquals(NrpePacket.OK, pkt.getResultCode());
        assertEquals("TEST OK - test items summary 20 B; | sum=20B;20\n"
                   + "bean1 10 B; \n"
                   + "bean2 10 B; | bean1=10B;10\n"
                   + "bean2=10B;10"
                ,

                pkt.getData());

    }
View Full Code Here

                ).withSummaryLine("TEST ${STATUS} - test item ${ATTR.name} ${LVAL0} ${UNIT0}; ")
                        .withLabel("${name}").withFilterResult("name", "bean2")
                        .withTextLine("${ATTR.name} ${LVAL0} ${UNIT0}; ")
                        .withPerfLine("${LABEL}=${LVAL0}${UNIT0};${LVAL0}");

        NrpePacket pkt = cmd.cmd();

        assertNotNull("should return some packet", pkt);
        assertEquals(NrpePacket.OK, pkt.getResultCode());
        assertEquals("TEST OK - test item bean2 10 B; | bean2=10B;10\n"
                        + "bean1 10 B; | bean1=10B;10",
                pkt.getData());
    }
View Full Code Here

TOP

Related Classes of com.jitlogic.zorka.core.integ.NrpePacket

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.