Search in sources :

Example 91 with SnmpAgentConfig

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

the class EnLinkdSnmpIT method testIsisCircTableWalk.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SIEGFRIE_IP, port = 161, resource = SIEGFRIE_SNMP_RESOURCE) })
public void testIsisCircTableWalk() throws Exception {
    final List<IsIsLink> links = new ArrayList<IsIsLink>();
    String trackerName = "isisCircTable";
    SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(SIEGFRIE_IP));
    IsisCircTableTracker tracker = new IsisCircTableTracker() {

        public void processIsisCircRow(final IsIsCircRow row) {
            assertEquals(2, row.getColumnCount());
            links.add(row.getIsisLink());
        }
    };
    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(12, links.size());
    for (final IsIsLink link : links) {
        if (link.getIsisCircIndex().intValue() == 533) {
            assertEquals(533, link.getIsisCircIfIndex().intValue());
            assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
        } else if (link.getIsisCircIndex().intValue() == 552) {
            assertEquals(552, link.getIsisCircIfIndex().intValue());
            assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
        } else if (link.getIsisCircIndex().intValue() == 13) {
            assertEquals(13, link.getIsisCircIfIndex().intValue());
            assertEquals(IsisAdminState.off, link.getIsisCircAdminState());
        } else if (link.getIsisCircIndex().intValue() == 16) {
            assertEquals(16, link.getIsisCircIfIndex().intValue());
            assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
        } else if (link.getIsisCircIndex().intValue() == 504) {
            assertEquals(504, link.getIsisCircIfIndex().intValue());
            assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
        } else if (link.getIsisCircIndex().intValue() == 507) {
            assertEquals(507, link.getIsisCircIfIndex().intValue());
            assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
        } else if (link.getIsisCircIndex().intValue() == 508) {
            assertEquals(508, link.getIsisCircIfIndex().intValue());
            assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
        } else if (link.getIsisCircIndex().intValue() == 512) {
            assertEquals(512, link.getIsisCircIfIndex().intValue());
            assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
        } else if (link.getIsisCircIndex().intValue() == 514) {
            assertEquals(514, link.getIsisCircIfIndex().intValue());
            assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
        } else if (link.getIsisCircIndex().intValue() == 531) {
            assertEquals(531, link.getIsisCircIfIndex().intValue());
            assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
        } else if (link.getIsisCircIndex().intValue() == 572) {
            assertEquals(572, link.getIsisCircIfIndex().intValue());
            assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
        } else if (link.getIsisCircIndex().intValue() == 573) {
            assertEquals(573, link.getIsisCircIfIndex().intValue());
            assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
        } else {
            assertEquals(true, false);
        }
    }
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) IsIsLink(org.opennms.netmgt.model.IsIsLink) ArrayList(java.util.ArrayList) IsisCircTableTracker(org.opennms.netmgt.enlinkd.snmp.IsisCircTableTracker) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 92 with SnmpAgentConfig

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

the class EnLinkdSnmpIT method testLldpRemTableWalk.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SWITCH1_IP, port = 161, resource = "classpath:/linkd/nms17216/switch1-walk.txt") })
public void testLldpRemTableWalk() throws Exception {
    final SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(SWITCH1_IP));
    LldpRemTableTracker lldpRemTable = new LldpRemTableTracker() {

        public void processLldpRemRow(final LldpRemRow row) {
            System.err.println("----------lldp rem----------------");
            System.err.println("columns number in the row: " + row.getColumnCount());
            assertEquals(6, row.getColumnCount());
            LldpLink link = row.getLldpLink();
            System.err.println("local port number: " + row.getLldpRemLocalPortNum());
            System.err.println("remote chassis: " + link.getLldpRemChassisId());
            System.err.println("remote chassis type: " + LldpChassisIdSubType.getTypeString(link.getLldpRemChassisIdSubType().getValue()));
            assertEquals(LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_MACADDRESS, link.getLldpRemChassisIdSubType());
            System.err.println("remote port id: " + link.getLldpRemPortId());
            System.err.println("remote port type: " + LldpPortIdSubType.getTypeString(link.getLldpRemPortIdSubType().getValue()));
            assertEquals(LldpPortIdSubType.LLDP_PORTID_SUBTYPE_INTERFACENAME, link.getLldpRemPortIdSubType());
        }
    };
    try {
        m_client.walk(config, lldpRemTable).withDescription("lldpRemTable").withLocation(null).execute().get();
    } catch (final InterruptedException e) {
        assertEquals(false, true);
    }
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) LldpRemTableTracker(org.opennms.netmgt.enlinkd.snmp.LldpRemTableTracker) LldpLink(org.opennms.netmgt.model.LldpLink) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 93 with SnmpAgentConfig

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

the class EnLinkdSnmpIT method testCdpInterfaceGetter.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = RPict001_IP, port = 161, resource = RPict001_SNMP_RESOURCE) })
public void testCdpInterfaceGetter() throws Exception {
    SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(RPict001_IP));
    CdpInterfacePortNameGetter get = new CdpInterfacePortNameGetter(config, m_client, null);
    assertEquals("FastEthernet0", get.getInterfaceNameFromCiscoCdpMib(1).toDisplayString());
    assertEquals("FastEthernet1", get.getInterfaceNameFromCiscoCdpMib(2).toDisplayString());
    assertEquals("FastEthernet2", get.getInterfaceNameFromCiscoCdpMib(3).toDisplayString());
    assertEquals("FastEthernet3", get.getInterfaceNameFromCiscoCdpMib(4).toDisplayString());
    assertEquals("FastEthernet4", get.getInterfaceNameFromCiscoCdpMib(5).toDisplayString());
    assertEquals("Tunnel0", get.getInterfaceNameFromCiscoCdpMib(9).toDisplayString());
    assertEquals("Tunnel3", get.getInterfaceNameFromCiscoCdpMib(10).toDisplayString());
    assertEquals("FastEthernet0", get.getInterfaceNameFromMib2(1).toDisplayString());
    assertEquals("FastEthernet1", get.getInterfaceNameFromMib2(2).toDisplayString());
    assertEquals("FastEthernet2", get.getInterfaceNameFromMib2(3).toDisplayString());
    assertEquals("FastEthernet3", get.getInterfaceNameFromMib2(4).toDisplayString());
    assertEquals("FastEthernet4", get.getInterfaceNameFromMib2(5).toDisplayString());
    assertEquals("Tunnel0", get.getInterfaceNameFromMib2(9).toDisplayString());
    assertEquals("Tunnel3", get.getInterfaceNameFromMib2(10).toDisplayString());
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) CdpInterfacePortNameGetter(org.opennms.netmgt.enlinkd.snmp.CdpInterfacePortNameGetter) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 94 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)

Example 95 with SnmpAgentConfig

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

the class SnmpPeerFactoryTest method testProxiedAgent.

public void testProxiedAgent() throws UnknownHostException {
    SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr("10.0.0.3"));
    assertEquals("10.0.0.3", InetAddressUtils.str(agentConfig.getProxyFor()));
    assertEquals("127.0.0.1", InetAddressUtils.str(agentConfig.getAddress()));
    agentConfig.toString();
}
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