use of org.opennms.netmgt.model.ResourcePath in project opennms by OpenNMS.
the class ThresholdingVisitorIT method runFileSystemDataTestWithCollectionSetBuilder.
private void runFileSystemDataTestWithCollectionSetBuilder(ThresholdingVisitor visitor, int resourceId, String fs, long value, long max) throws Exception {
SnmpCollectionAgent agent = createCollectionAgent();
NodeLevelResource nodeResource = new NodeLevelResource(agent.getNodeId());
// Creating Generic ResourceType
org.opennms.netmgt.config.datacollection.ResourceType indexResourceType = createIndexResourceType(agent, "hrStorageIndex");
GenericTypeResource genericResource = new GenericTypeResource(nodeResource, indexResourceType, Integer.toString(resourceId));
// Creating strings.properties file
ResourcePath path = ResourcePath.get("snmp", "1", "hrStorageIndex", Integer.toString(resourceId));
m_resourceStorageDao.setStringAttribute(path, "hrStorageType", ".1.3.6.1.2.1.25.2.1.4");
m_resourceStorageDao.setStringAttribute(path, "hrStorageDescr", fs);
// Build the collection set
CollectionSet collectionSet = new CollectionSetBuilder(agent).withNumericAttribute(genericResource, "hd-usage", "hrStorageUsed", value, AttributeType.GAUGE).withNumericAttribute(genericResource, "hd-usage", "hrStorageSize", max, AttributeType.GAUGE).withNumericAttribute(genericResource, "hd-usage", "hrStorageAllocUnits", 1, AttributeType.GAUGE).build();
// Run Visitor
collectionSet.visit(visitor);
EasyMock.verify(agent);
}
use of org.opennms.netmgt.model.ResourcePath in project opennms by OpenNMS.
the class ThresholdingVisitorIT method testInterfaceResourceWithStringAttributeFilter.
/*
* This test uses this files from src/test/resources:
* - threshd-configuration.xml
* - test-thresholds.xml
*
* Updated to reflect the fact that counter are treated as rates.
*/
@Test
public void testInterfaceResourceWithStringAttributeFilter() throws Exception {
Integer ifIndex = 1;
Long ifSpeed = 10000000l;
String ifName = "sis0";
addHighThresholdEvent(1, 90, 50, 120, ifName, ifIndex.toString(), "ifOutOctets", ifName, ifIndex.toString());
addHighThresholdEvent(1, 90, 50, 120, ifName, ifIndex.toString(), "ifInOctets", ifName, ifIndex.toString());
// Creating strings.properties file
ResourcePath path = ResourcePath.get("snmp", "1", ifName);
m_resourceStorageDao.setStringAttribute(path, "myMockParam", "myMockValue");
ThresholdingVisitor visitor = createVisitor();
visitor.visitCollectionSet(createAnonymousCollectionSet(new Date().getTime()));
// real value = (46000 - 10000)/300 = 120
runInterfaceResource(visitor, "127.0.0.1", ifName, ifSpeed, ifIndex, 10000, 46000);
verifyEvents(0);
}
Aggregations