use of org.opennms.core.collection.test.JUnitCollector in project opennms by OpenNMS.
the class SnmpCollectorIT method testBug2447_GenericIndexedOnlyCollect.
@Test
@Transactional
@JUnitCollector(datacollectionConfig = "/org/opennms/netmgt/config/datacollection-brocade-no-ifaces-config.xml", datacollectionType = "snmp", anticipateRrds = { "1/brocadeFCPortIndex/1/swFCPortTxWords", "1/brocadeFCPortIndex/1/swFCPortRxWords", "1/brocadeFCPortIndex/2/swFCPortTxWords", "1/brocadeFCPortIndex/2/swFCPortRxWords", "1/brocadeFCPortIndex/3/swFCPortTxWords", "1/brocadeFCPortIndex/3/swFCPortRxWords", "1/brocadeFCPortIndex/4/swFCPortTxWords", "1/brocadeFCPortIndex/4/swFCPortRxWords", "1/brocadeFCPortIndex/5/swFCPortTxWords", "1/brocadeFCPortIndex/5/swFCPortRxWords", "1/brocadeFCPortIndex/6/swFCPortTxWords", "1/brocadeFCPortIndex/6/swFCPortRxWords", "1/brocadeFCPortIndex/7/swFCPortTxWords", "1/brocadeFCPortIndex/7/swFCPortRxWords", "1/brocadeFCPortIndex/8/swFCPortTxWords", "1/brocadeFCPortIndex/8/swFCPortRxWords" }, anticipateFiles = { "1", "1/brocadeFCPortIndex", "1/brocadeFCPortIndex/1/strings.properties", "1/brocadeFCPortIndex/1", "1/brocadeFCPortIndex/2/strings.properties", "1/brocadeFCPortIndex/2", "1/brocadeFCPortIndex/3/strings.properties", "1/brocadeFCPortIndex/3", "1/brocadeFCPortIndex/4/strings.properties", "1/brocadeFCPortIndex/4", "1/brocadeFCPortIndex/5/strings.properties", "1/brocadeFCPortIndex/5", "1/brocadeFCPortIndex/6/strings.properties", "1/brocadeFCPortIndex/6", "1/brocadeFCPortIndex/7/strings.properties", "1/brocadeFCPortIndex/7", "1/brocadeFCPortIndex/8/strings.properties", "1/brocadeFCPortIndex/8" })
@JUnitSnmpAgent(resource = "/org/opennms/netmgt/snmp/brocadeTestData1.properties")
public void testBug2447_GenericIndexedOnlyCollect() throws Exception {
// now do the actual collection
CollectionSet collectionSet = m_collectionSpecification.collect(m_collectionAgent);
assertEquals("collection status", CollectionStatus.SUCCEEDED, collectionSet.getStatus());
CollectorTestUtils.persistCollectionSet(m_rrdStrategy, m_resourceStorageDao, m_collectionSpecification, collectionSet);
System.err.println("FIRST COLLECTION FINISHED");
// need a one second time elapse to update the RRD
Thread.sleep(1000);
// try collecting again
assertEquals("collection status", CollectionStatus.SUCCEEDED, m_collectionSpecification.collect(m_collectionAgent).getStatus());
System.err.println("SECOND COLLECTION FINISHED");
}
use of org.opennms.core.collection.test.JUnitCollector in project opennms by OpenNMS.
the class SnmpCollectorMinMaxValIT method testPersist.
@Test
@JUnitCollector(datacollectionConfig = "/org/opennms/netmgt/config/datacollection-minmax-persistTest-config.xml", datacollectionType = "snmp", anticipateFiles = { "1", "1/fw0" }, anticipateRrds = { "1/tcpCurrEstab", "1/fw0/ifInOctets" })
@JUnitSnmpAgent(host = TEST_HOST_ADDRESS, resource = "/org/opennms/netmgt/snmp/snmpTestData1.properties")
public void testPersist() throws Exception {
final File snmpRrdDirectory = (File) m_context.getAttribute("rrdDirectory");
// node level collection
final File nodeDir = new File(snmpRrdDirectory, "1");
final File rrdFile = new File(nodeDir, rrd("tcpCurrEstab"));
// interface level collection
final File ifDir = new File(nodeDir, "fw0");
final File ifRrdFile = new File(ifDir, rrd("ifInOctets"));
final int numUpdates = 2;
final int stepSizeInSecs = 1;
final int stepSizeInMillis = stepSizeInSecs * 1000;
final int rangeSizeInMillis = stepSizeInMillis + 20000;
CollectorTestUtils.collectNTimes(m_rrdStrategy, m_resourceStorageDao, m_collectionSpecification, m_collectionAgent, numUpdates);
// This is the value from snmpTestData1.properties
// .1.3.6.1.2.1.6.9.0 = Gauge32: 123
assertEquals(Double.valueOf(123.0), m_rrdStrategy.fetchLastValueInRange(rrdFile.getAbsolutePath(), "tcpCurrEstab", stepSizeInMillis, rangeSizeInMillis));
// This is the value from snmpTestData1.properties
// .1.3.6.1.2.1.2.2.1.10.6 = Counter32: 1234567
assertEquals(Double.valueOf(1234567.0), m_rrdStrategy.fetchLastValueInRange(ifRrdFile.getAbsolutePath(), "ifInOctets", stepSizeInMillis, rangeSizeInMillis));
// now update the data in the agent
SnmpUtils.set(m_agentConfig, SnmpObjId.get(".1.3.6.1.2.1.6.9.0"), SnmpUtils.getValueFactory().getInt32(456));
SnmpUtils.set(m_agentConfig, SnmpObjId.get(".1.3.6.1.2.1.2.2.1.10.6"), SnmpUtils.getValueFactory().getCounter32(7654321));
CollectorTestUtils.collectNTimes(m_rrdStrategy, m_resourceStorageDao, m_collectionSpecification, m_collectionAgent, numUpdates);
// by now the values should be the new values
assertEquals(Double.valueOf(456.0), m_rrdStrategy.fetchLastValueInRange(rrdFile.getAbsolutePath(), "tcpCurrEstab", stepSizeInMillis, rangeSizeInMillis));
assertEquals(Double.valueOf(1234567.0), m_rrdStrategy.fetchLastValueInRange(ifRrdFile.getAbsolutePath(), "ifInOctets", stepSizeInMillis, rangeSizeInMillis));
// now update the data in the agent
SnmpUtils.set(m_agentConfig, SnmpObjId.get(".1.3.6.1.2.1.6.9.0"), SnmpUtils.getValueFactory().getInt32(456));
SnmpUtils.set(m_agentConfig, SnmpObjId.get(".1.3.6.1.2.1.2.2.1.10.6"), SnmpUtils.getValueFactory().getCounter32(1234567));
CollectorTestUtils.collectNTimes(m_rrdStrategy, m_resourceStorageDao, m_collectionSpecification, m_collectionAgent, numUpdates);
// by now the values should be the new values
assertEquals(Double.valueOf(456.0), m_rrdStrategy.fetchLastValueInRange(rrdFile.getAbsolutePath(), "tcpCurrEstab", stepSizeInMillis, rangeSizeInMillis));
assertEquals(Double.valueOf(1234567.0), m_rrdStrategy.fetchLastValueInRange(ifRrdFile.getAbsolutePath(), "ifInOctets", stepSizeInMillis, rangeSizeInMillis));
}
use of org.opennms.core.collection.test.JUnitCollector in project opennms by OpenNMS.
the class HttpCollectorIT method testPersistApacheStats.
@Test
@JUnitHttpServer(port = 10342, vhosts = { "127.0.0.1" })
@JUnitCollector(datacollectionConfig = "/org/opennms/netmgt/config/http-datacollection-persist-apache-stats.xml", datacollectionType = "http", anticipateRrds = { "1/TotalAccesses", "1/TotalkBytes", "1/CPULoad", "1/Uptime", "1/ReqPerSec", "1/BytesPerSec", "1/BytesPerReq", "1/BusyWorkers", "1/IdleWorkers" })
public final void testPersistApacheStats() throws Exception {
File snmpRrdDirectory = (File) m_context.getAttribute("rrdDirectory");
FileAnticipator anticipator = (FileAnticipator) m_context.getAttribute("fileAnticipator");
int numUpdates = 2;
int stepSizeInSecs = 1;
int stepSizeInMillis = stepSizeInSecs * 1000;
final int rangeSizeInMillis = stepSizeInMillis + 20000;
CollectorTestUtils.collectNTimes(m_rrdStrategy, m_resourceStorageDao, m_collectionSpecification, m_collectionAgent, numUpdates);
// node level collection
File nodeDir = CollectorTestUtils.anticipatePath(anticipator, snmpRrdDirectory, "1");
File documentCountRrdFile = new File(nodeDir, CollectorTestUtils.rrd(m_rrdStrategy, "TotalAccesses"));
File someNumberRrdFile = new File(nodeDir, CollectorTestUtils.rrd(m_rrdStrategy, "IdleWorkers"));
File cpuLoadRrdFile = new File(nodeDir, CollectorTestUtils.rrd(m_rrdStrategy, "CPULoad"));
// Total Accesses: 175483
assertEquals("TotalAccesses", Double.valueOf(175483.0), m_rrdStrategy.fetchLastValueInRange(documentCountRrdFile.getAbsolutePath(), "TotalAccesses", stepSizeInMillis, rangeSizeInMillis));
// IdleWorkers: 12
assertEquals("IdleWorkers", Double.valueOf(12.0), m_rrdStrategy.fetchLastValueInRange(someNumberRrdFile.getAbsolutePath(), "IdleWorkers", stepSizeInMillis, rangeSizeInMillis));
// CPU Load: .497069
assertEquals("CPULoad", Double.valueOf(0.497069), m_rrdStrategy.fetchLastValueInRange(cpuLoadRrdFile.getAbsolutePath(), "CPULoad", stepSizeInMillis, rangeSizeInMillis));
}
use of org.opennms.core.collection.test.JUnitCollector in project opennms by OpenNMS.
the class SnmpCollectorWithMibPropertiesIT method testCollect.
/**
* Test collection with MibObj Properties.
*
* @throws Exception the exception
*/
@Test
@JUnitCollector(datacollectionType = "snmp", datacollectionConfig = "/org/opennms/netmgt/config/datacollection-config-NMS8484.xml")
@JUnitSnmpAgent(resource = "/org/opennms/netmgt/snmp/airespace.properties")
public void testCollect() throws Exception {
System.setProperty("org.opennms.netmgt.collectd.SnmpCollector.limitCollectionToInstances", "true");
CollectionSet collectionSet = m_collectionSpecification.collect(m_collectionAgent);
assertEquals("collection status", CollectionStatus.SUCCEEDED, collectionSet.getStatus());
CollectorTestUtils.persistCollectionSet(m_rrdStrategy, m_resourceStorageDao, m_collectionSpecification, collectionSet);
Map<String, String> slot0 = m_resourceStorageDao.getStringAttributes(ResourcePath.get("snmp", "1", "bsnAPIfLoadParametersEntry", "132.178.97.20.31.224.0"));
assertEquals("AP84b2.6111.29ac", slot0.get("bsnAPName"));
assertEquals("0", slot0.get("slotNumber"));
Map<String, String> slot1 = m_resourceStorageDao.getStringAttributes(ResourcePath.get("snmp", "1", "bsnAPIfLoadParametersEntry", "132.178.97.20.31.224.1"));
assertEquals("AP84b2.6111.29ac", slot1.get("bsnAPName"));
assertEquals("1", slot1.get("slotNumber"));
}
use of org.opennms.core.collection.test.JUnitCollector in project opennms by OpenNMS.
the class SnmpCollectorWithMibPropertiesIT method testCollectCiscoQoS.
/**
* Test collection for Cisco QoS with MibObj Properties.
*
* @throws Exception the exception
*/
@Test
@JUnitCollector(datacollectionType = "snmp", datacollectionConfig = "/org/opennms/netmgt/config/datacollection-config-cisco-qos.xml")
@JUnitSnmpAgent(resource = "/org/opennms/netmgt/snmp/cisco-qos.properties")
public void testCollectCiscoQoS() throws Exception {
System.setProperty("org.opennms.netmgt.collectd.SnmpCollector.limitCollectionToInstances", "true");
CollectionSet collectionSet = m_collectionSpecification.collect(m_collectionAgent);
assertEquals("collection status", CollectionStatus.SUCCEEDED, collectionSet.getStatus());
CollectorTestUtils.persistCollectionSet(m_rrdStrategy, m_resourceStorageDao, m_collectionSpecification, collectionSet);
Map<String, String> map = m_resourceStorageDao.getStringAttributes(ResourcePath.get("snmp", "1", "cbQosCMStatsEntry", "290.508801"));
assertEquals("OUTBOUND-LLQ", map.get("cbQosClassMapPolicy"));
assertEquals("GESTION-ROUTING", map.get("cbQosClassMapName"));
assertEquals("Conexion Valencia", map.get("ifAlias"));
}
Aggregations