Search in sources :

Example 1 with SingleResourceCollectionSet

use of org.opennms.netmgt.collection.support.SingleResourceCollectionSet in project opennms by OpenNMS.

the class DefaultPollerBackEnd method saveResponseTimeData.

/**
 * <p>saveResponseTimeData</p>
 *
 * @param locationMonitorId a {@link java.lang.String} object.
 * @param monSvc a {@link org.opennms.netmgt.model.OnmsMonitoredService} object.
 * @param responseTime a double.
 * @param pkg a {@link org.opennms.netmgt.config.poller.Package} object.
 */
@Override
public void saveResponseTimeData(final String locationMonitorId, final OnmsMonitoredService monSvc, final double responseTime, final Package pkg) {
    final String svcName = monSvc.getServiceName();
    final Service svc = m_pollerConfig.getServiceInPackage(svcName, pkg);
    String dsName = getServiceParameter(svc, "ds-name");
    if (dsName == null) {
        dsName = PollStatus.PROPERTY_RESPONSE_TIME;
    }
    String rrdBaseName = getServiceParameter(svc, "rrd-base-name");
    if (rrdBaseName == null) {
        rrdBaseName = dsName;
    }
    final String rrdRepository = getServiceParameter(svc, "rrd-repository");
    if (rrdRepository == null) {
        return;
    }
    RrdRepository repository = new RrdRepository();
    repository.setStep(m_pollerConfig.getStep(pkg));
    repository.setHeartBeat(repository.getStep() * HEARTBEAT_STEP_MULTIPLIER);
    repository.setRraList(m_pollerConfig.getRRAList(pkg));
    repository.setRrdBaseDir(new File(rrdRepository));
    DistributedLatencyCollectionResource distributedLatencyResource = new DistributedLatencyCollectionResource(locationMonitorId, InetAddressUtils.toIpAddrString(monSvc.getIpAddress()));
    DistributedLatencyCollectionAttributeType distributedLatencyType = new DistributedLatencyCollectionAttributeType(rrdBaseName, dsName);
    distributedLatencyResource.addAttribute(new DistributedLatencyCollectionAttribute(distributedLatencyResource, distributedLatencyType, responseTime));
    ServiceParameters params = new ServiceParameters(Collections.emptyMap());
    CollectionSetVisitor persister = m_persisterFactory.createPersister(params, repository, false, true, true);
    SingleResourceCollectionSet collectionSet = new SingleResourceCollectionSet(distributedLatencyResource, new Date());
    collectionSet.setStatus(CollectionStatus.SUCCEEDED);
    collectionSet.visit(persister);
}
Also used : SingleResourceCollectionSet(org.opennms.netmgt.collection.support.SingleResourceCollectionSet) CollectionSetVisitor(org.opennms.netmgt.collection.api.CollectionSetVisitor) PolledService(org.opennms.netmgt.poller.remote.PolledService) OnmsMonitoredService(org.opennms.netmgt.model.OnmsMonitoredService) Service(org.opennms.netmgt.config.poller.Service) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) RrdRepository(org.opennms.netmgt.rrd.RrdRepository) File(java.io.File) Date(java.util.Date)

Example 2 with SingleResourceCollectionSet

use of org.opennms.netmgt.collection.support.SingleResourceCollectionSet in project opennms by OpenNMS.

the class LatencyStoringServiceMonitorAdaptor method persistLatencySamples.

private void persistLatencySamples(MonitoredService service, Map<String, Number> entries, File rrdRepositoryRoot, String rrdBaseName) {
    RrdRepository repository = new RrdRepository();
    repository.setStep(m_pollerConfig.getStep(m_pkg));
    repository.setRraList(m_pollerConfig.getRRAList(m_pkg));
    repository.setHeartBeat(repository.getStep() * HEARTBEAT_STEP_MULTIPLIER);
    repository.setRrdBaseDir(rrdRepositoryRoot);
    // When making calls directly to RrdUtils#createRrd() and RrdUtils#updateRrd(),
    // the behavior was as follows:
    // 1) All samples get written to response/${ipAddr}/${rrdBaseName}.rrd
    // This happens whether or not storeByGroup is enabled.
    // 2) If multiple entries are present, the DSs are created in the same order that they
    // appear in the map
    LatencyCollectionResource latencyResource = new LatencyCollectionResource(service.getSvcName(), service.getIpAddr(), service.getNodeLocation());
    for (final Entry<String, Number> entry : entries.entrySet()) {
        final String ds = entry.getKey();
        final Number value = entry.getValue() != null ? entry.getValue() : Double.NaN;
        LatencyCollectionAttributeType latencyType = new LatencyCollectionAttributeType(rrdBaseName, ds);
        latencyResource.addAttribute(new LatencyCollectionAttribute(latencyResource, latencyType, ds, value.doubleValue()));
    }
    ServiceParameters params = new ServiceParameters(Collections.emptyMap());
    CollectionSetVisitor persister = m_persisterFactory.createPersister(params, repository, false, true, true);
    SingleResourceCollectionSet collectionSet = new SingleResourceCollectionSet(latencyResource, new Date());
    collectionSet.setStatus(CollectionStatus.SUCCEEDED);
    collectionSet.visit(persister);
}
Also used : LatencyCollectionAttribute(org.opennms.netmgt.poller.LatencyCollectionAttribute) SingleResourceCollectionSet(org.opennms.netmgt.collection.support.SingleResourceCollectionSet) LatencyCollectionResource(org.opennms.netmgt.poller.LatencyCollectionResource) LatencyCollectionAttributeType(org.opennms.netmgt.poller.LatencyCollectionAttributeType) CollectionSetVisitor(org.opennms.netmgt.collection.api.CollectionSetVisitor) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) RrdRepository(org.opennms.netmgt.rrd.RrdRepository) Date(java.util.Date)

Aggregations

Date (java.util.Date)2 CollectionSetVisitor (org.opennms.netmgt.collection.api.CollectionSetVisitor)2 ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)2 SingleResourceCollectionSet (org.opennms.netmgt.collection.support.SingleResourceCollectionSet)2 RrdRepository (org.opennms.netmgt.rrd.RrdRepository)2 File (java.io.File)1 Service (org.opennms.netmgt.config.poller.Service)1 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)1 LatencyCollectionAttribute (org.opennms.netmgt.poller.LatencyCollectionAttribute)1 LatencyCollectionAttributeType (org.opennms.netmgt.poller.LatencyCollectionAttributeType)1 LatencyCollectionResource (org.opennms.netmgt.poller.LatencyCollectionResource)1 PolledService (org.opennms.netmgt.poller.remote.PolledService)1