Search in sources :

Example 41 with SnmpAgentConfig

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

the class EnLinkdSnmpIT method testOspfIfTableWalk.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SWITCH1_IP, port = 161, resource = "classpath:/linkd/nms17216/switch1-walk.txt") })
public void testOspfIfTableWalk() throws Exception {
    SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(SWITCH1_IP));
    String trackerName = "ospfIfTable";
    final List<OspfLink> links = new ArrayList<>();
    OspfIfTableTracker ospfIfTableTracker = new OspfIfTableTracker() {

        public void processOspfIfRow(final OspfIfRow row) {
            links.add(row.getOspfLink());
        }
    };
    try {
        m_client.walk(config, ospfIfTableTracker).withDescription(trackerName).withLocation(null).execute().get();
    } catch (final InterruptedException e) {
        LOG.error("run: collection interrupted, exiting", e);
        return;
    }
    final OspfIpAddrTableGetter ipAddrTableGetter = new OspfIpAddrTableGetter(config, m_client, null, 0);
    for (OspfLink link : links) {
        link = ipAddrTableGetter.get(link);
        assertEquals(0, link.getOspfAddressLessIndex().intValue());
        if (link.getOspfIpAddr().equals(InetAddress.getByName("192.168.100.246"))) {
            assertEquals(10101, link.getOspfIfIndex().intValue());
            assertEquals(InetAddress.getByName("255.255.255.252"), link.getOspfIpMask());
        } else if (link.getOspfIpAddr().equals(InetAddress.getByName("172.16.10.1"))) {
            assertEquals(10, link.getOspfIfIndex().intValue());
            assertEquals(InetAddress.getByName("255.255.255.0"), link.getOspfIpMask());
        } else if (link.getOspfIpAddr().equals(InetAddress.getByName("172.16.20.1"))) {
            assertEquals(20, link.getOspfIfIndex().intValue());
            assertEquals(InetAddress.getByName("255.255.255.0"), link.getOspfIpMask());
        } else if (link.getOspfIpAddr().equals(InetAddress.getByName("172.16.30.1"))) {
            assertEquals(30, link.getOspfIfIndex().intValue());
            assertEquals(InetAddress.getByName("255.255.255.0"), link.getOspfIpMask());
        } else if (link.getOspfIpAddr().equals(InetAddress.getByName("172.16.40.1"))) {
            assertEquals(40, link.getOspfIfIndex().intValue());
            assertEquals(InetAddress.getByName("255.255.255.0"), link.getOspfIpMask());
        } else {
            assertEquals(false, true);
        }
    }
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) OspfIfTableTracker(org.opennms.netmgt.enlinkd.snmp.OspfIfTableTracker) ArrayList(java.util.ArrayList) OspfLink(org.opennms.netmgt.model.OspfLink) OspfIpAddrTableGetter(org.opennms.netmgt.enlinkd.snmp.OspfIpAddrTableGetter) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 42 with SnmpAgentConfig

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

the class EnLinkdSnmpIT method test3LldpRemoteTableWalk.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SWITCH2_IP, port = 161, resource = "classpath:/linkd/nms17216/switch2-walk.txt") })
public void test3LldpRemoteTableWalk() throws Exception {
    SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(SWITCH2_IP));
    final List<LldpLink> links = new ArrayList<>();
    LldpRemTableTracker lldpRemTable = new LldpRemTableTracker() {

        public void processLldpRemRow(final LldpRemRow row) {
            links.add(row.getLldpLink());
        }
    };
    try {
        m_client.walk(config, lldpRemTable).withDescription("lldpRemTable").withLocation(null).execute().get();
    } catch (ExecutionException e) {
        // pass
        LOG.error("run: collection failed, exiting", e);
        return;
    } catch (final InterruptedException e) {
        LOG.error("run: collection interrupted, exiting", e);
        return;
    }
    final LldpLocPortGetter lldpLocPort = new LldpLocPortGetter(config, m_client, null, 0);
    for (LldpLink link : links) {
        assertNotNull(link);
        assertNotNull(link.getLldpLocalPortNum());
        assertNull(link.getLldpPortId());
        assertNull(link.getLldpPortIdSubType());
        assertNull(link.getLldpPortDescr());
        LldpLink updated = lldpLocPort.getLldpLink(link);
        assertNotNull(updated.getLldpPortId());
        assertEquals(5, updated.getLldpPortIdSubType().getValue().intValue());
        assertNotNull(updated.getLldpPortDescr());
    }
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) LldpRemTableTracker(org.opennms.netmgt.enlinkd.snmp.LldpRemTableTracker) ArrayList(java.util.ArrayList) LldpLocPortGetter(org.opennms.netmgt.enlinkd.snmp.LldpLocPortGetter) LldpLink(org.opennms.netmgt.model.LldpLink) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 43 with SnmpAgentConfig

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

the class EnLinkdSnmpIT method testLldpDragonWaveLocalGroupWalk.

/**
 * This test is designed to test the issues in bug NMS-6921.
 *
 * @see http://issues.opennms.org/browse/NMS-6912
 *
 * @throws Exception
 */
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = DW_IP, port = 161, resource = DW_SNMP_RESOURCE) })
public void testLldpDragonWaveLocalGroupWalk() throws Exception {
    String trackerName = "lldpLocalGroup";
    SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(DW_IP));
    LldpLocalGroupTracker lldpLocalGroup = new LldpLocalGroupTracker();
    try {
        m_client.walk(config, lldpLocalGroup).withDescription(trackerName).withLocation(null).execute().get();
    } catch (final InterruptedException e) {
        LOG.error("run: collection interrupted, exiting", e);
        return;
    }
    LldpElement eiA = lldpLocalGroup.getLldpElement();
    System.err.println("local chassis type: " + LldpChassisIdSubType.getTypeString(eiA.getLldpChassisIdSubType().getValue()));
    System.err.println("local chassis id: " + eiA.getLldpChassisId());
    System.err.println("local sysname: " + eiA.getLldpSysname());
    assertEquals("cf", eiA.getLldpChassisId());
    assertEquals(LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_CHASSISCOMPONENT, eiA.getLldpChassisIdSubType());
    assertEquals("NuDesign", eiA.getLldpSysname());
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) LldpLocalGroupTracker(org.opennms.netmgt.enlinkd.snmp.LldpLocalGroupTracker) LldpElement(org.opennms.netmgt.model.LldpElement) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 44 with SnmpAgentConfig

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

the class EnLinkdSnmpIT method testDot1dTpFdbTableWalk.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = DLINK1_IP, port = 161, resource = DLINK1_SNMP_RESOURCE) })
public void testDot1dTpFdbTableWalk() throws Exception {
    String trackerName = "dot1dTpFdbTable";
    final List<BridgeMacLink> links = new ArrayList<>();
    SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(DLINK1_IP));
    Dot1dTpFdbTableTracker tracker = new Dot1dTpFdbTableTracker() {

        @Override
        public void processDot1dTpFdbRow(final Dot1dTpFdbRow row) {
            links.add(row.getLink());
        }
    };
    try {
        m_client.walk(config, tracker).withDescription(trackerName).withLocation(null).execute().get();
    } catch (final InterruptedException e) {
        LOG.error("run: collection interrupted, exiting", e);
        return;
    }
    assertEquals(17, links.size());
    for (BridgeMacLink link : links) {
        assertEquals(BridgeDot1qTpFdbStatus.DOT1D_TP_FDB_STATUS_LEARNED, link.getBridgeDot1qTpFdbStatus());
        System.out.println(link.getMacAddress());
        if (link.getMacAddress().equals("000c29dcc076")) {
            assertEquals(24, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("000ffeb10d1e")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("000ffeb10e26")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("001a4b802790")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("001d6004acbc")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("001e58865d0f")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("0021913b5108")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("002401ad3416")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("00248c4c8bd0")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("0024d608693e")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("000ffeb10d1e")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("1caff737cc33")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("1caff7443339")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("1cbdb9b56160")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("5cd998667abb")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("e0cb4e3e7fc0")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("f07d68711f89")) {
            assertEquals(24, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("f07d6876c565")) {
            assertEquals(24, link.getBridgePort().intValue());
        } else {
            assertEquals(false, true);
        }
    }
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) ArrayList(java.util.ArrayList) Dot1dTpFdbTableTracker(org.opennms.netmgt.enlinkd.snmp.Dot1dTpFdbTableTracker) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 45 with SnmpAgentConfig

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

the class SnmpPeerFactoryTest method testGetMaxRepetitions.

public void testGetMaxRepetitions() throws UnknownHostException {
    SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr("77.5.5.255"));
    assertEquals("ipmatch", agentConfig.getReadCommunity());
    assertEquals(7, agentConfig.getMaxRepetitions());
    agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr("10.0.0.1"));
    assertEquals("specificv1", agentConfig.getReadCommunity());
    assertEquals(2, agentConfig.getMaxRepetitions());
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig)

Aggregations

SnmpAgentConfig (org.opennms.netmgt.snmp.SnmpAgentConfig)120 InetAddress (java.net.InetAddress)31 Test (org.junit.Test)31 JUnitSnmpAgents (org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)23 ArrayList (java.util.ArrayList)22 SnmpObjId (org.opennms.netmgt.snmp.SnmpObjId)21 SnmpValue (org.opennms.netmgt.snmp.SnmpValue)21 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)5 LldpLocPortGetter (org.opennms.netmgt.enlinkd.snmp.LldpLocPortGetter)4 LldpRemTableTracker (org.opennms.netmgt.enlinkd.snmp.LldpRemTableTracker)4