use of org.opennms.netmgt.collection.persistence.rrd.RrdPersisterFactory in project opennms by OpenNMS.
the class AbstractVTDXmlCollectorTest method setUp.
/**
* Sets the up.
*
* @throws Exception the exception
*/
@Before
public void setUp() throws Exception {
MockLogAppender.setupLogging();
m_rrdStrategy = new JRobinRrdStrategy();
m_resourceStorageDao = new FilesystemResourceStorageDao();
m_resourceStorageDao.setRrdDirectory(m_temporaryFolder.getRoot());
m_temporaryFolder.newFolder("snmp");
m_persisterFactory = new RrdPersisterFactory();
m_persisterFactory.setResourceStorageDao(m_resourceStorageDao);
m_persisterFactory.setRrdStrategy(m_rrdStrategy);
m_collectionAgent = new MockCollectionAgent(1, "mynode.local", InetAddrUtils.addr("127.0.0.1"));
m_eventProxy = EasyMock.createMock(EventProxy.class);
m_xmlCollectionDao = new XmlDataCollectionConfigDaoJaxb();
Resource resource = new FileSystemResource(getXmlConfigFileName());
m_xmlCollectionDao.setConfigResource(resource);
m_xmlCollectionDao.afterPropertiesSet();
MockDocumentBuilder.setXmlFileName(getXmlSampleFileName());
EasyMock.replay(m_eventProxy);
}
use of org.opennms.netmgt.collection.persistence.rrd.RrdPersisterFactory in project opennms by OpenNMS.
the class CollectableServiceTest method createCollectableService.
private void createCollectableService() throws CollectionInitializationException, IOException {
// Mock it all!
OnmsIpInterface iface = mock(OnmsIpInterface.class, RETURNS_DEEP_STUBS);
IpInterfaceDao ifaceDao = mock(IpInterfaceDao.class);
spec = mock(CollectionSpecification.class);
scheduler = mock(Scheduler.class);
SchedulingCompletedFlag schedulingCompletedFlag = mock(SchedulingCompletedFlag.class);
PlatformTransactionManager transMgr = mock(PlatformTransactionManager.class);
RrdPersisterFactory persisterFactory = new RrdPersisterFactory();
persisterFactory.setRrdStrategy(rrdStrategy);
ResourceStorageDao resourceStorageDao = mock(ResourceStorageDao.class);
// Disable thresholding
Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("thresholding-enabled", Boolean.FALSE.toString());
ServiceParameters params = new ServiceParameters(paramsMap);
when(iface.getNode().getId()).thenReturn(1);
when(spec.getServiceParameters()).thenReturn(params);
when(spec.getRrdRepository(any())).thenReturn(createRrdRepository());
when(ifaceDao.load(any())).thenReturn(iface);
when(iface.getIpAddress()).thenReturn(InetAddrUtils.getLocalHostAddress());
service = new CollectableService(iface, ifaceDao, spec, scheduler, schedulingCompletedFlag, transMgr, persisterFactory, resourceStorageDao);
}
use of org.opennms.netmgt.collection.persistence.rrd.RrdPersisterFactory in project opennms by OpenNMS.
the class SnmpAttributeTest method testPersisting.
@Ignore
private void testPersisting(String matchValue, SnmpValue snmpValue) throws Exception {
OnmsNode node = new OnmsNode();
node.setId(3);
OnmsIpInterface ipInterface = new OnmsIpInterface();
ipInterface.setId(1);
ipInterface.setNode(node);
ipInterface.setIpAddress(InetAddressUtils.addr("192.168.1.1"));
// It used to be 3, but I think it is more correct to use getStoreDir from DefaultCollectionAgentService on DefaultCollectionAgent (NMS-7516)
expect(m_ipInterfaceDao.load(1)).andReturn(ipInterface).times(5);
expect(m_rrdStrategy.getDefaultFileExtension()).andReturn(".myLittleEasyMockedStrategyAndMe").anyTimes();
expect(m_rrdStrategy.createDefinition(isA(String.class), isA(String.class), isA(String.class), anyInt(), isAList(RrdDataSource.class), isAList(String.class))).andReturn(new Object());
m_rrdStrategy.createFile(isA(Object.class));
expect(m_rrdStrategy.openFile(isA(String.class))).andReturn(new Object());
m_rrdStrategy.updateFile(isA(Object.class), isA(String.class), matches(".*:" + matchValue));
m_rrdStrategy.closeFile(isA(Object.class));
m_mocks.replayAll();
SnmpCollectionAgent agent = DefaultSnmpCollectionAgent.create(ipInterface.getId(), m_ipInterfaceDao, new MockPlatformTransactionManager());
OnmsSnmpCollection snmpCollection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), new MockDataCollectionConfig(), m_locationAwareSnmpClient);
NodeResourceType resourceType = new NodeResourceType(agent, snmpCollection);
NodeInfo nodeInfo = resourceType.getNodeInfo();
MibObject mibObject = new MibObject();
mibObject.setOid(".1.3.6.1.4.1.12238.55.9997.4.1.2.9.116.101.109.112.95.117.108.107.111");
mibObject.setInstance("1");
mibObject.setAlias("temp_ulko");
mibObject.setType("gauge");
NumericAttributeType attributeType = new NumericAttributeType(resourceType, snmpCollection.getName(), mibObject, new AttributeGroupType("foo", AttributeGroupType.IF_TYPE_IGNORE));
attributeType.storeResult(new SnmpCollectionSet(agent, snmpCollection, m_locationAwareSnmpClient), null, new SnmpResult(mibObject.getSnmpObjId(), new SnmpInstId(mibObject.getInstance()), snmpValue));
RrdRepository repository = createRrdRepository();
repository.setRraList(Collections.singletonList("RRA:AVERAGE:0.5:1:2016"));
RrdPersisterFactory persisterFactory = new RrdPersisterFactory();
persisterFactory.setRrdStrategy(m_rrdStrategy);
persisterFactory.setResourceStorageDao(m_resourceStorageDao);
CollectionSetVisitor persister = persisterFactory.createPersister(new ServiceParameters(Collections.emptyMap()), repository);
final AtomicInteger count = new AtomicInteger(0);
nodeInfo.visit(new CollectionSetVisitorWrapper(persister) {
@Override
public void visitAttribute(CollectionAttribute attribute) {
super.visitAttribute(attribute);
count.incrementAndGet();
}
});
assertEquals(1, count.get());
}
use of org.opennms.netmgt.collection.persistence.rrd.RrdPersisterFactory in project opennms by OpenNMS.
the class HttpDataCollectionIT method setUp.
/**
* Sets the up.
*
* @throws Exception the exception
*/
@Before
public void setUp() throws Exception {
MockLogAppender.setupLogging();
DefaultDataCollectionConfigDao dao = new DefaultDataCollectionConfigDao();
dao.setConfigDirectory("src/test/resources/etc/datacollection");
dao.setConfigResource(new FileSystemResource("src/test/resources/etc/datacollection-config.xml"));
dao.afterPropertiesSet();
DataCollectionConfigFactory.setInstance(dao);
m_rrdStrategy = new JRobinRrdStrategy();
m_resourceStorageDao = new FilesystemResourceStorageDao();
m_resourceStorageDao.setRrdDirectory(m_temporaryFolder.getRoot());
m_temporaryFolder.newFolder("snmp");
m_persisterFactory = new RrdPersisterFactory();
m_persisterFactory.setResourceStorageDao(m_resourceStorageDao);
m_persisterFactory.setRrdStrategy(m_rrdStrategy);
m_collectionAgent = new MockCollectionAgent(1, "mynode.local", InetAddrUtils.addr("127.0.0.1"));
m_nodeDao = EasyMock.createMock(NodeDao.class);
OnmsNode node = new OnmsNode();
node.setId(1);
node.setLabel("mynode.local");
node.setAssetRecord(new OnmsAssetRecord());
EasyMock.expect(m_nodeDao.get(1)).andReturn(node).anyTimes();
EasyMock.replay(m_nodeDao);
}
use of org.opennms.netmgt.collection.persistence.rrd.RrdPersisterFactory in project opennms by OpenNMS.
the class NodeLevelDataOnMultipleNodesTest method setUp.
/**
* Sets the up.
*
* @throws Exception the exception
*/
@Before
public void setUp() throws Exception {
MockLogAppender.setupLogging();
m_rrdStrategy = getRrdStrategy();
m_resourceStorageDao = new FilesystemResourceStorageDao();
m_resourceStorageDao.setRrdDirectory(m_temporaryFolder.getRoot());
m_temporaryFolder.newFolder("snmp");
m_persisterFactory = new RrdPersisterFactory();
m_persisterFactory.setResourceStorageDao(m_resourceStorageDao);
m_persisterFactory.setRrdStrategy(m_rrdStrategy);
m_eventProxy = EasyMock.createMock(EventProxy.class);
m_xmlCollectionDao = new XmlDataCollectionConfigDaoJaxb();
Resource resource = new FileSystemResource(getXmlConfigFileName());
m_xmlCollectionDao.setConfigResource(resource);
m_xmlCollectionDao.afterPropertiesSet();
m_collector = new XmlCollector();
m_collector.setXmlCollectionDao(m_xmlCollectionDao);
EasyMock.replay(m_eventProxy);
}
Aggregations