use of org.opennms.netmgt.rrd.RrdRepository 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);
}
use of org.opennms.netmgt.rrd.RrdRepository in project opennms by OpenNMS.
the class WsManCollector method getRrdRepository.
@Override
public RrdRepository getRrdRepository(String collectionName) {
LOG.debug("getRrdRepository({})", collectionName);
WsmanDatacollectionConfig config = m_wsManDataCollectionConfigDao.getConfig();
Collection collection = m_wsManDataCollectionConfigDao.getCollectionByName(collectionName);
if (collection == null) {
throw new IllegalArgumentException("No configuration found for collection with name: " + collectionName);
}
RrdRepository rrdRepository = new RrdRepository();
rrdRepository.setStep(collection.getRrd().getStep());
rrdRepository.setHeartBeat(2 * rrdRepository.getStep());
rrdRepository.setRraList(collection.getRrd().getRra());
rrdRepository.setRrdBaseDir(new File(config.getRrdRepository()));
LOG.debug("Using RRD repository: {} for collection: {}", rrdRepository, collectionName);
return rrdRepository;
}
use of org.opennms.netmgt.rrd.RrdRepository in project opennms by OpenNMS.
the class MockServiceCollector method getRrdRepository.
@Override
public RrdRepository getRrdRepository(String collectionName) {
RrdRepository repo = new RrdRepository();
repo.setRrdBaseDir(new File("target"));
repo.setRraList(Collections.singletonList("RRA:AVERAGE:0.5:1:8928"));
repo.setStep(300);
repo.setHeartBeat(2 * 300);
return repo;
}
use of org.opennms.netmgt.rrd.RrdRepository in project opennms by OpenNMS.
the class RrdPersistOperationBuilderTest method testCommitWithDeclaredAttributeAndNullValue.
@Test
public void testCommitWithDeclaredAttributeAndNullValue() throws Exception {
RrdRepository repository = createRrdRepository();
SnmpCollectionAgent agent = getCollectionAgent();
MockDataCollectionConfig dataCollectionConfig = new MockDataCollectionConfig();
OnmsSnmpCollection collection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), dataCollectionConfig, m_locationAwareSnmpClient);
NodeResourceType resourceType = new NodeResourceType(agent, collection);
CollectionResource resource = new NodeInfo(resourceType, agent);
MibObject mibObject = new MibObject();
mibObject.setOid(".1.1.1.1");
mibObject.setAlias("mibObjectAlias");
mibObject.setType("string");
mibObject.setInstance("0");
mibObject.setMaxval(null);
mibObject.setMinval(null);
SnmpCollectionSet collectionSet = new SnmpCollectionSet(agent, collection, m_locationAwareSnmpClient);
SnmpAttributeType attributeType = new StringAttributeType(resourceType, "some-collection", mibObject, new AttributeGroupType("mibGroup", AttributeGroupType.IF_TYPE_IGNORE));
attributeType.storeResult(collectionSet, null, new SnmpResult(mibObject.getSnmpObjId(), new SnmpInstId(mibObject.getInstance()), SnmpUtils.getValueFactory().getOctetString("hello".getBytes())));
RrdPersistOperationBuilder builder = new RrdPersistOperationBuilder(m_rrdStrategy, repository, resource, "rrdName", false);
builder.declareAttribute(attributeType);
builder.setAttributeValue(attributeType, null);
builder.commit();
}
use of org.opennms.netmgt.rrd.RrdRepository in project opennms by OpenNMS.
the class RrdPersistOperationBuilderTest method testCommitWithDeclaredAttributeAndValue.
@Test
public void testCommitWithDeclaredAttributeAndValue() throws Exception {
File nodeDir = m_fileAnticipator.expecting(getSnmpRrdDirectory(), m_node.getId().toString());
m_fileAnticipator.expecting(nodeDir, "rrdName" + m_rrdStrategy.getDefaultFileExtension());
m_fileAnticipator.expecting(nodeDir, "rrdName" + ".meta");
RrdRepository repository = createRrdRepository();
SnmpCollectionAgent agent = getCollectionAgent();
MockDataCollectionConfig dataCollectionConfig = new MockDataCollectionConfig();
OnmsSnmpCollection collection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), dataCollectionConfig, m_locationAwareSnmpClient);
NodeResourceType resourceType = new NodeResourceType(agent, collection);
CollectionResource resource = new NodeInfo(resourceType, agent);
MibObject mibObject = new MibObject();
mibObject.setOid(".1.1.1.1");
mibObject.setAlias("mibObjectAlias");
mibObject.setType("counter");
mibObject.setInstance("0");
mibObject.setMaxval(null);
mibObject.setMinval(null);
SnmpCollectionSet collectionSet = new SnmpCollectionSet(agent, collection, m_locationAwareSnmpClient);
SnmpAttributeType attributeType = new NumericAttributeType(resourceType, "some-collection", mibObject, new AttributeGroupType("mibGroup", AttributeGroupType.IF_TYPE_IGNORE));
attributeType.storeResult(collectionSet, null, new SnmpResult(mibObject.getSnmpObjId(), new SnmpInstId(mibObject.getInstance()), SnmpUtils.getValueFactory().getOctetString("hello".getBytes())));
RrdPersistOperationBuilder builder = new RrdPersistOperationBuilder(m_rrdStrategy, repository, resource, "rrdName", false);
builder.declareAttribute(attributeType);
builder.setAttributeValue(attributeType, 6.022E23d);
builder.commit();
}
Aggregations