Search in sources :

Example 96 with SnmpAgentConfig

use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.

the class SnmpPeerFactoryTest method testDefaultMaxVarsPerPdu.

public void testDefaultMaxVarsPerPdu() throws UnknownHostException {
    SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr(myLocalHost()));
    assertEquals(23, agentConfig.getMaxVarsPerPdu());
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig)

Example 97 with SnmpAgentConfig

use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.

the class SnmpPeerFactoryTest method testReversedRange.

/**
     * This tests for ranges configured for a v2 node and community string
     * 
     * @throws UnknownHostException
     */
public void testReversedRange() throws UnknownHostException {
    SnmpPeerFactory.setInstance(new SnmpPeerFactory(new ByteArrayResource(getBadRangeSnmpConfig().getBytes())));
    SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr("10.7.23.100"));
    assertNotNull(agentConfig);
    assertEquals(SnmpAgentConfig.VERSION2C, agentConfig.getVersion());
    assertEquals("rangev2c", agentConfig.getReadCommunity());
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) ByteArrayResource(org.springframework.core.io.ByteArrayResource)

Example 98 with SnmpAgentConfig

use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.

the class SnmpPeerFactoryTest method testGetTargetFromPatterns.

public void testGetTargetFromPatterns() throws UnknownHostException {
    SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr("77.5.5.255"));
    assertEquals("ipmatch", agentConfig.getReadCommunity());
    assertEquals(128, agentConfig.getMaxVarsPerPdu());
    agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr("77.15.80.255"));
    assertEquals("ipmatch", agentConfig.getReadCommunity());
    assertEquals(7, agentConfig.getMaxRepetitions());
    //should be default community "public" because of 4
    agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr("77.4.5.255"));
    assertEquals("public", agentConfig.getReadCommunity());
    //should be default community because of 0
    agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr("77.6.0.255"));
    assertEquals("public", agentConfig.getReadCommunity());
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig)

Example 99 with SnmpAgentConfig

use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.

the class SnmpPeerFactoryTest method testNoMatchedDefinitionWithLocationMatch.

public void testNoMatchedDefinitionWithLocationMatch() throws UnknownHostException {
    SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr("192.160.0.50"), "MINION");
    assertNotNull(agentConfig);
    assertEquals(agentConfig.getVersion(), SnmpAgentConfig.VERSION1);
    assertEquals("public", agentConfig.getReadCommunity());
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig)

Example 100 with SnmpAgentConfig

use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.

the class SnmpPeerFactoryTest method testGetV2cConfig.

/**
     * This tests for a specifically defined v2c agentConfig
     * 
     * @throws UnknownHostException
     */
public void testGetV2cConfig() throws UnknownHostException {
    SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr("192.168.0.50"));
    assertNotNull(agentConfig);
    assertEquals(agentConfig.getVersion(), SnmpAgentConfig.VERSION2C);
    assertEquals("specificv2c", agentConfig.getReadCommunity());
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig)

Aggregations

SnmpAgentConfig (org.opennms.netmgt.snmp.SnmpAgentConfig)117 Test (org.junit.Test)31 InetAddress (java.net.InetAddress)30 JUnitSnmpAgents (org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)23 ArrayList (java.util.ArrayList)22 SnmpValue (org.opennms.netmgt.snmp.SnmpValue)21 SnmpObjId (org.opennms.netmgt.snmp.SnmpObjId)20 SnmpInstId (org.opennms.netmgt.snmp.SnmpInstId)16 PollStatus (org.opennms.netmgt.poller.PollStatus)14 Map (java.util.Map)11 ExecutionException (java.util.concurrent.ExecutionException)9 ParameterMap (org.opennms.core.utils.ParameterMap)9 SnmpWalker (org.opennms.netmgt.snmp.SnmpWalker)8 Date (java.util.Date)7 LldpLink (org.opennms.netmgt.model.LldpLink)7 OnmsNode (org.opennms.netmgt.model.OnmsNode)7 HashMap (java.util.HashMap)6 List (java.util.List)4 LldpLocPortGetter (org.opennms.netmgt.enlinkd.snmp.LldpLocPortGetter)4 LldpRemTableTracker (org.opennms.netmgt.enlinkd.snmp.LldpRemTableTracker)4