Search in sources :

Example 1 with MetricSetDto

use of ee.ria.xroad.monitor.common.dto.MetricSetDto in project X-Road by nordic-institute.

the class MetricsProviderActorTest method testLimitedSystemMetricsRequest.

@Test
public void testLimitedSystemMetricsRequest() throws Exception {
    final Props props = Props.create(MetricsProviderActor.class);
    final TestActorRef<MetricsProviderActor> ref = TestActorRef.create(actorSystem, props, "testActorRef");
    Future<Object> future = Patterns.ask(ref, new SystemMetricsRequest(null, false), Timeout.apply(1, TimeUnit.MINUTES));
    Object result = Await.result(future, Duration.apply(1, TimeUnit.MINUTES));
    assertTrue(future.isCompleted());
    assertTrue(result instanceof SystemMetricsResponse);
    SystemMetricsResponse response = (SystemMetricsResponse) result;
    MetricSetDto metricSetDto = response.getMetrics();
    Set<MetricDto> dtoSet = metricSetDto.getMetrics();
    log.info("metricSetDto: " + metricSetDto);
    for (MetricDto metricDto : dtoSet) {
        // Order of entries is undefined -> Must handle by name
        switch(metricDto.getName()) {
            case HISTOGRAM_NAME:
                Assert.fail("Should not have histrogram.");
                break;
            case GAUGE_NAME:
                Assert.fail("Should not have histrogram gauge.");
                break;
            default:
                Assert.fail("Unknown metric found in response.");
                break;
        }
    }
}
Also used : SystemMetricsResponse(ee.ria.xroad.monitor.common.SystemMetricsResponse) MetricDto(ee.ria.xroad.monitor.common.dto.MetricDto) SystemMetricsRequest(ee.ria.xroad.monitor.common.SystemMetricsRequest) MetricSetDto(ee.ria.xroad.monitor.common.dto.MetricSetDto) Props(akka.actor.Props) Test(org.junit.Test)

Example 2 with MetricSetDto

use of ee.ria.xroad.monitor.common.dto.MetricSetDto in project X-Road by nordic-institute.

the class MetricsProviderActor method onReceive.

@Override
public void onReceive(Object o) throws Exception {
    if (o instanceof SystemMetricsRequest) {
        final SystemMetricsRequest req = (SystemMetricsRequest) o;
        log.info("Received SystemMetricsRequest: " + req);
        if (req.getMetricNames() != null && req.getMetricNames().size() > 0) {
            log.info("Specified metrics requested: " + req.getMetricNames());
            log.info("Is owner of security server: " + req.isClientOwner());
        }
        MetricRegistry metrics = MetricRegistryHolder.getInstance().getMetrics();
        final MetricSetDto.Builder builder = new MetricSetDto.Builder("systemMetrics");
        collectMetrics(builder, metrics, req.getMetricNames(), req.isClientOwner());
        if (req.isClientOwner() || !SystemProperties.getEnvMonitorLimitRemoteDataSet()) {
            collectOwnerMetrics(builder, metrics, req.getMetricNames());
        }
        MetricSetDto metricSet = builder.build();
        final SystemMetricsResponse response = new SystemMetricsResponse(metricSet);
        getSender().tell(response, getSelf());
    } else {
        unhandled(o);
    }
}
Also used : SystemMetricsResponse(ee.ria.xroad.monitor.common.SystemMetricsResponse) SystemMetricsRequest(ee.ria.xroad.monitor.common.SystemMetricsRequest) MetricRegistry(com.codahale.metrics.MetricRegistry) MetricSetDto(ee.ria.xroad.monitor.common.dto.MetricSetDto)

Example 3 with MetricSetDto

use of ee.ria.xroad.monitor.common.dto.MetricSetDto in project X-Road by nordic-institute.

the class MetricsProviderActor method toProcessMetricSetDto.

private MetricSetDto toProcessMetricSetDto(String name, Gauge<JmxStringifiedData<ProcessInfo>> processSensor) {
    JmxStringifiedData<ProcessInfo> p = processSensor.getValue();
    MetricSetDto.Builder mainBuilder = new MetricSetDto.Builder(name);
    for (ProcessInfo process : p.getDtoData()) {
        MetricSetDto.Builder processBuilder = new MetricSetDto.Builder(process.getProcessId());
        mainBuilder.withMetric(processBuilder.withSimpleMetric("processId", process.getProcessId()).withSimpleMetric("command", process.getCommand()).withSimpleMetric("cpuLoad", process.getCpuLoad()).withSimpleMetric("memUsed", process.getMemUsed()).withSimpleMetric("startTime", process.getStartTime()).withSimpleMetric("userId", process.getUserId()).build());
    }
    return mainBuilder.build();
}
Also used : MetricSetDto(ee.ria.xroad.monitor.common.dto.MetricSetDto) ProcessInfo(ee.ria.xroad.monitor.executablelister.ProcessInfo)

Example 4 with MetricSetDto

use of ee.ria.xroad.monitor.common.dto.MetricSetDto in project X-Road by nordic-institute.

the class MetricsProviderActor method toPackageMetricSetDto.

private MetricSetDto toPackageMetricSetDto(String name, Gauge<JmxStringifiedData<PackageInfo>> packageSensor) {
    JmxStringifiedData<PackageInfo> p = packageSensor.getValue();
    MetricSetDto.Builder mainBuilder = new MetricSetDto.Builder(name);
    for (PackageInfo pac : p.getDtoData()) {
        mainBuilder.withSimpleMetric(pac.getName(), pac.getVersion());
    }
    return mainBuilder.build();
}
Also used : PackageInfo(ee.ria.xroad.monitor.executablelister.PackageInfo) MetricSetDto(ee.ria.xroad.monitor.common.dto.MetricSetDto)

Example 5 with MetricSetDto

use of ee.ria.xroad.monitor.common.dto.MetricSetDto in project X-Road by nordic-institute.

the class MetricTypes method of.

/**
 * MetricSetType factory
 */
public static MetricSetType of(MetricSetDto metrics) {
    final MetricSetType metricSet = new MetricSetType();
    metricSet.setName(metrics.getName());
    for (MetricDto metricDto : metrics.getMetrics()) {
        if (metricDto instanceof MetricSetDto) {
            metricSet.getMetrics().add(of((MetricSetDto) metricDto));
        } else if (metricDto instanceof HistogramDto) {
            metricSet.getMetrics().add(toMetricType((HistogramDto) metricDto));
        } else if (metricDto instanceof SimpleMetricDto) {
            metricSet.getMetrics().add(toMetricType((SimpleMetricDto<?>) metricDto));
        }
    }
    return metricSet;
}
Also used : HistogramDto(ee.ria.xroad.monitor.common.dto.HistogramDto) MetricDto(ee.ria.xroad.monitor.common.dto.MetricDto) SimpleMetricDto(ee.ria.xroad.monitor.common.dto.SimpleMetricDto) SimpleMetricDto(ee.ria.xroad.monitor.common.dto.SimpleMetricDto) MetricSetDto(ee.ria.xroad.monitor.common.dto.MetricSetDto) MetricSetType(ee.ria.xroad.proxymonitor.message.MetricSetType)

Aggregations

MetricSetDto (ee.ria.xroad.monitor.common.dto.MetricSetDto)7 SystemMetricsRequest (ee.ria.xroad.monitor.common.SystemMetricsRequest)4 SystemMetricsResponse (ee.ria.xroad.monitor.common.SystemMetricsResponse)4 MetricDto (ee.ria.xroad.monitor.common.dto.MetricDto)4 Props (akka.actor.Props)3 HistogramDto (ee.ria.xroad.monitor.common.dto.HistogramDto)3 Test (org.junit.Test)3 MetricRegistry (com.codahale.metrics.MetricRegistry)1 SimpleMetricDto (ee.ria.xroad.monitor.common.dto.SimpleMetricDto)1 PackageInfo (ee.ria.xroad.monitor.executablelister.PackageInfo)1 ProcessInfo (ee.ria.xroad.monitor.executablelister.ProcessInfo)1 MetricSetType (ee.ria.xroad.proxymonitor.message.MetricSetType)1