Search in sources :

Example 6 with ValueList

use of org.collectd.api.ValueList in project jcollectd by collectd.

the class ValueListTest method dummyValueList.

private ValueList dummyValueList() {
    ValueList vl = new ValueList();
    vl.setHost(HOST);
    vl.setInterval(interval);
    vl.setTime(now);
    vl.setPlugin(PLUGIN);
    vl.setPluginInstance(ValueListTest.class.getName());
    for (int i = 0; i < values.length; i++) {
        vl.addValue(new Double(values[i]));
    }
    return vl;
}
Also used : ValueList(org.collectd.api.ValueList)

Example 7 with ValueList

use of org.collectd.api.ValueList in project metrics by dropwizard.

the class CollectdReporterTest method sanitizesMetricName.

@Test
public void sanitizesMetricName() throws Exception {
    Counter counter = registry.counter("dash-illegal.slash/illegal");
    counter.inc();
    reporter.report();
    ValueList values = receiver.next();
    assertThat(values.getPlugin()).isEqualTo("dash_illegal.slash_illegal");
}
Also used : Counter(com.codahale.metrics.Counter) ValueList(org.collectd.api.ValueList) Test(org.junit.Test)

Example 8 with ValueList

use of org.collectd.api.ValueList in project metrics by dropwizard.

the class CollectdReporterTest method reportsBooleanGauges.

@Test
public void reportsBooleanGauges() throws Exception {
    reporter.report(map("gauge", (Gauge) () -> true), map(), map(), map(), map());
    ValueList data = receiver.next();
    assertThat(data.getValues()).containsExactly(1d);
    reporter.report(map("gauge", (Gauge) () -> false), map(), map(), map(), map());
    data = receiver.next();
    assertThat(data.getValues()).containsExactly(0d);
}
Also used : ValueList(org.collectd.api.ValueList) Gauge(com.codahale.metrics.Gauge) Test(org.junit.Test)

Example 9 with ValueList

use of org.collectd.api.ValueList in project metrics by dropwizard.

the class Receiver method before.

@Override
protected void before() throws Throwable {
    receiver = new UdpReceiver(new Dispatcher() {

        @Override
        public void dispatch(ValueList values) {
            queue.offer(new ValueList(values));
        }

        @Override
        public void dispatch(Notification notification) {
            throw new UnsupportedOperationException();
        }
    });
    receiver.setPort(port);
    new Thread(() -> {
        try {
            receiver.listen();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }).start();
}
Also used : ValueList(org.collectd.api.ValueList) UdpReceiver(org.collectd.protocol.UdpReceiver) Dispatcher(org.collectd.protocol.Dispatcher) Notification(org.collectd.api.Notification)

Example 10 with ValueList

use of org.collectd.api.ValueList in project jcollectd by collectd.

the class ValueListTest method testWriter.

public void testWriter() throws IOException {
    ValueList vl = dummyValueList();
    PacketWriter pw = new PacketWriter();
    pw.write(vl);
    UdpReceiver receiver = new UdpReceiver();
    TestPacketDispatcher dispatcher = new TestPacketDispatcher();
    receiver.setDispatcher(dispatcher);
    receiver.parse(pw.getBytes());
}
Also used : ValueList(org.collectd.api.ValueList)

Aggregations

ValueList (org.collectd.api.ValueList)12 Test (org.junit.Test)3 Counter (com.codahale.metrics.Counter)2 Gauge (com.codahale.metrics.Gauge)2 IOException (java.io.IOException)1 DataSource (org.collectd.api.DataSource)1 Notification (org.collectd.api.Notification)1 Dispatcher (org.collectd.protocol.Dispatcher)1 UdpReceiver (org.collectd.protocol.UdpReceiver)1