Search in sources :

Example 56 with ResourcePath

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);
}
Also used : ResourcePath(org.opennms.netmgt.model.ResourcePath) CollectionSetBuilder(org.opennms.netmgt.collection.support.builder.CollectionSetBuilder) SnmpCollectionAgent(org.opennms.netmgt.collectd.SnmpCollectionAgent) GenericTypeResource(org.opennms.netmgt.collection.support.builder.GenericTypeResource) NodeLevelResource(org.opennms.netmgt.collection.support.builder.NodeLevelResource) CollectionSet(org.opennms.netmgt.collection.api.CollectionSet)

Example 57 with ResourcePath

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);
}
Also used : BigInteger(java.math.BigInteger) ResourcePath(org.opennms.netmgt.model.ResourcePath) Date(java.util.Date) Test(org.junit.Test)

Aggregations

ResourcePath (org.opennms.netmgt.model.ResourcePath)57 OnmsResource (org.opennms.netmgt.model.OnmsResource)19 OnmsAttribute (org.opennms.netmgt.model.OnmsAttribute)14 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)9 MockResourceType (org.opennms.netmgt.mock.MockResourceType)9 RrdGraphAttribute (org.opennms.netmgt.model.RrdGraphAttribute)8 HashSet (java.util.HashSet)6 Map (java.util.Map)6 CollectionResource (org.opennms.netmgt.collection.api.CollectionResource)6 Parameter (org.opennms.netmgt.config.datacollection.Parameter)6 Resource (org.opennms.newts.api.Resource)6 SnmpCollectionAgent (org.opennms.netmgt.collectd.SnmpCollectionAgent)5 CollectionSetBuilder (org.opennms.netmgt.collection.support.builder.CollectionSetBuilder)5 Sample (org.opennms.newts.api.Sample)5 Path (java.nio.file.Path)4 NodeLevelResource (org.opennms.netmgt.collection.support.builder.NodeLevelResource)4 IOException (java.io.IOException)3 ObjectNameStorageStrategy (org.opennms.netmgt.collection.support.ObjectNameStorageStrategy)3 OnmsNode (org.opennms.netmgt.model.OnmsNode)3