@Test @JUnitCollector( datacollectionConfig = "/org/opennms/netmgt/config/datacollection-config.xml", datacollectionType = "snmp", anticipateFiles = { "1", "1/fw0" }, anticipateRrds = { "1/tcpActiveOpens", "1/tcpAttemptFails", "1/tcpPassiveOpens", "1/tcpRetransSegs", "1/tcpCurrEstab", "1/tcpEstabResets", "1/tcpInErrors", "1/tcpInSegs", "1/tcpOutRsts", "1/tcpOutSegs", "1/fw0/ifInDiscards", "1/fw0/ifInErrors", "1/fw0/ifInNUcastpkts", "1/fw0/ifInOctets", "1/fw0/ifInUcastpkts", "1/fw0/ifOutErrors", "1/fw0/ifOutNUcastPkts", "1/fw0/ifOutOctets", "1/fw0/ifOutUcastPkts" } ) @JUnitSnmpAgent(resource = "/org/opennms/netmgt/snmp/snmpTestData1.properties") public void testCollect() throws Exception { System.setProperty("org.opennms.netmgt.collectd.SnmpCollector.limitCollectionToInstances", "true"); m_collectionSpecification.initialize(m_collectionAgent); CollectionSet collectionSet = m_collectionSpecification.collect(m_collectionAgent); assertEquals("collection status", ServiceCollector.COLLECTION_SUCCEEDED, collectionSet.getStatus()); CollectorTestUtils.persistCollectionSet(m_collectionSpecification, collectionSet); System.err.println("FIRST COLLECTION FINISHED"); Thread.sleep(1000); assertEquals("collection status", ServiceCollector.COLLECTION_SUCCEEDED, m_collectionSpecification.collect(m_collectionAgent).getStatus()); System.err.println("SECOND COLLECTION FINISHED"); m_collectionSpecification.release(m_collectionAgent); }
public CollectionSet collect(CollectionAgent agent, EventProxy eventProxy, Map<String, Object> parameters) throws CollectionException { try { final ServiceParameters params = new ServiceParameters(parameters); params.logIfAliasConfig(); OnmsSnmpCollection snmpCollection = new OnmsSnmpCollection(agent, params); final ForceRescanState forceRescanState = new ForceRescanState(agent, eventProxy); SnmpCollectionSet collectionSet = snmpCollection.createCollectionSet(agent); collectionSet.setCollectionTimestamp(new Date()); if (!collectionSet.hasDataToCollect()) { logNoDataToCollect(agent); } Collectd.instrumentation().beginCollectingServiceData(collectionSet.getCollectionAgent().getNodeId(), collectionSet.getCollectionAgent().getHostAddress(), serviceName()); try { collectionSet.collect(); if (System.getProperty("org.opennms.netmgt.collectd.SnmpCollector.forceRescan", "false").equalsIgnoreCase("true") && collectionSet.rescanNeeded()) { forceRescanState.rescanIndicated(); } return collectionSet; } finally { Collectd.instrumentation().endCollectingServiceData(collectionSet.getCollectionAgent().getNodeId(), collectionSet.getCollectionAgent().getHostAddress(), serviceName()); } } catch (CollectionException e) { Collectd.instrumentation().reportCollectionException(agent.getNodeId(), agent.getHostAddress(), serviceName(), e); throw e; } catch (Throwable t) { throw new CollectionException("Unexpected error during node SNMP collection for: " + agent.getHostAddress() + ": " + t, t); } }
SnmpCollector implements ServiceCollector { public CollectionSet collect(CollectionAgent agent, EventProxy eventProxy, Map<String, Object> parameters) throws CollectionException { try { final ServiceParameters params = new ServiceParameters(parameters); params.logIfAliasConfig(); OnmsSnmpCollection snmpCollection = new OnmsSnmpCollection(agent, params); final ForceRescanState forceRescanState = new ForceRescanState(agent, eventProxy); SnmpCollectionSet collectionSet = snmpCollection.createCollectionSet(agent); collectionSet.setCollectionTimestamp(new Date()); if (!collectionSet.hasDataToCollect()) { logNoDataToCollect(agent); } Collectd.instrumentation().beginCollectingServiceData(collectionSet.getCollectionAgent().getNodeId(), collectionSet.getCollectionAgent().getHostAddress(), serviceName()); try { collectionSet.collect(); if (System.getProperty("org.opennms.netmgt.collectd.SnmpCollector.forceRescan", "false").equalsIgnoreCase("true") && collectionSet.rescanNeeded()) { forceRescanState.rescanIndicated(); } return collectionSet; } finally { Collectd.instrumentation().endCollectingServiceData(collectionSet.getCollectionAgent().getNodeId(), collectionSet.getCollectionAgent().getHostAddress(), serviceName()); } } catch (CollectionException e) { Collectd.instrumentation().reportCollectionException(agent.getNodeId(), agent.getHostAddress(), serviceName(), e); throw e; } catch (Throwable t) { throw new CollectionException("Unexpected error during node SNMP collection for: " + agent.getHostAddress() + ": " + t, t); } } }
SnmpCollector implements ServiceCollector { public CollectionSet collect(CollectionAgent agent, EventProxy eventProxy, Map<String, Object> parameters) throws CollectionException { try { final ServiceParameters params = new ServiceParameters(parameters); params.logIfAliasConfig(); OnmsSnmpCollection snmpCollection = new OnmsSnmpCollection(agent, params); final ForceRescanState forceRescanState = new ForceRescanState(agent, eventProxy); SnmpCollectionSet collectionSet = snmpCollection.createCollectionSet(agent); collectionSet.setCollectionTimestamp(new Date()); if (!collectionSet.hasDataToCollect()) { logNoDataToCollect(agent); } Collectd.instrumentation().beginCollectingServiceData(collectionSet.getCollectionAgent().getNodeId(), collectionSet.getCollectionAgent().getHostAddress(), serviceName()); try { collectionSet.collect(); if (System.getProperty("org.opennms.netmgt.collectd.SnmpCollector.forceRescan", "false").equalsIgnoreCase("true") && collectionSet.rescanNeeded()) { forceRescanState.rescanIndicated(); } return collectionSet; } finally { Collectd.instrumentation().endCollectingServiceData(collectionSet.getCollectionAgent().getNodeId(), collectionSet.getCollectionAgent().getHostAddress(), serviceName()); } } catch (CollectionException e) { Collectd.instrumentation().reportCollectionException(agent.getNodeId(), agent.getHostAddress(), serviceName(), e); throw e; } catch (Throwable t) { throw new CollectionException("Unexpected error during node SNMP collection for: " + agent.getHostAddress() + ": " + t, t); } }  }
SnmpCollector implements ServiceCollector { public CollectionSet collect(CollectionAgent agent, EventProxy eventProxy, Map<String, Object> parameters) throws CollectionException { try { final ServiceParameters params = new ServiceParameters(parameters); params.logIfAliasConfig(); OnmsSnmpCollection snmpCollection = new OnmsSnmpCollection(agent, params); final ForceRescanState forceRescanState = new ForceRescanState(agent, eventProxy); SnmpCollectionSet collectionSet = snmpCollection.createCollectionSet(agent); collectionSet.setCollectionTimestamp(new Date()); if (!collectionSet.hasDataToCollect()) { logNoDataToCollect(agent); } Collectd.instrumentation().beginCollectingServiceData(collectionSet.getCollectionAgent().getNodeId(), collectionSet.getCollectionAgent().getHostAddress(), serviceName()); try { collectionSet.collect(); if (System.getProperty("org.opennms.netmgt.collectd.SnmpCollector.forceRescan", "false").equalsIgnoreCase("true") && collectionSet.rescanNeeded()) { forceRescanState.rescanIndicated(); } return collectionSet; } finally { Collectd.instrumentation().endCollectingServiceData(collectionSet.getCollectionAgent().getNodeId(), collectionSet.getCollectionAgent().getHostAddress(), serviceName()); } } catch (CollectionException e) { Collectd.instrumentation().reportCollectionException(agent.getNodeId(), agent.getHostAddress(), serviceName(), e); throw e; } catch (Throwable t) { throw new CollectionException("Unexpected error during node SNMP collection for: " + agent.getHostAddress() + ": " + t, t); } }  String serviceName(); void initialize(Map<String, String> parameters); void release(); void initialize(CollectionAgent agent, Map<String, Object> parameters); void release(CollectionAgent agent); CollectionSet collect(CollectionAgent agent, EventProxy eventProxy, Map<String, Object> parameters); RrdRepository getRrdRepository(String collectionName); }
SnmpCollector implements ServiceCollector { public CollectionSet collect(CollectionAgent agent, EventProxy eventProxy, Map<String, Object> parameters) throws CollectionException { try { final ServiceParameters params = new ServiceParameters(parameters); params.logIfAliasConfig(); OnmsSnmpCollection snmpCollection = new OnmsSnmpCollection(agent, params); final ForceRescanState forceRescanState = new ForceRescanState(agent, eventProxy); SnmpCollectionSet collectionSet = snmpCollection.createCollectionSet(agent); collectionSet.setCollectionTimestamp(new Date()); if (!collectionSet.hasDataToCollect()) { logNoDataToCollect(agent); } Collectd.instrumentation().beginCollectingServiceData(collectionSet.getCollectionAgent().getNodeId(), collectionSet.getCollectionAgent().getHostAddress(), serviceName()); try { collectionSet.collect(); if (System.getProperty("org.opennms.netmgt.collectd.SnmpCollector.forceRescan", "false").equalsIgnoreCase("true") && collectionSet.rescanNeeded()) { forceRescanState.rescanIndicated(); } return collectionSet; } finally { Collectd.instrumentation().endCollectingServiceData(collectionSet.getCollectionAgent().getNodeId(), collectionSet.getCollectionAgent().getHostAddress(), serviceName()); } } catch (CollectionException e) { Collectd.instrumentation().reportCollectionException(agent.getNodeId(), agent.getHostAddress(), serviceName(), e); throw e; } catch (Throwable t) { throw new CollectionException("Unexpected error during node SNMP collection for: " + agent.getHostAddress() + ": " + t, t); } }  String serviceName(); void initialize(Map<String, String> parameters); void release(); void initialize(CollectionAgent agent, Map<String, Object> parameters); void release(CollectionAgent agent); CollectionSet collect(CollectionAgent agent, EventProxy eventProxy, Map<String, Object> parameters); RrdRepository getRrdRepository(String collectionName); static String SNMP_STORAGE_PRIMARY; }