Search in sources :

Example 1 with CdpGlobalGroupTracker

use of org.opennms.netmgt.enlinkd.snmp.CdpGlobalGroupTracker in project opennms by OpenNMS.

the class EnLinkdSnmpIT method testCdpGlobalGroupCollection.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = RPict001_IP, port = 161, resource = RPict001_SNMP_RESOURCE) })
public void testCdpGlobalGroupCollection() throws Exception {
    SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(RPict001_IP));
    String trackerName = "cdpGlobalGroup";
    final CdpGlobalGroupTracker cdpGlobalGroup = new CdpGlobalGroupTracker();
    try {
        m_client.walk(config, cdpGlobalGroup).withDescription(trackerName).withLocation(null).execute().get();
    } catch (final InterruptedException e) {
        LOG.error("run: Cdp Linkd collection interrupted, exiting", e);
        return;
    }
    assertEquals("r-ro-suce-pict-001.infra.u-ssi.net", cdpGlobalGroup.getCdpDeviceId());
    assertEquals(1, cdpGlobalGroup.getCdpGlobalRun().intValue());
    assertNull(cdpGlobalGroup.getCdpGlobalDeviceFormat());
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) CdpGlobalGroupTracker(org.opennms.netmgt.enlinkd.snmp.CdpGlobalGroupTracker) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 2 with CdpGlobalGroupTracker

use of org.opennms.netmgt.enlinkd.snmp.CdpGlobalGroupTracker in project opennms by OpenNMS.

the class EnLinkdSnmpIT method testCdpGlobalGroupCollectionWithGlobalIdFormat.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = CISCO_WS_C2948_IP, port = 161, resource = CISCO_WS_C2948_SNMP_RESOURCE) })
public void testCdpGlobalGroupCollectionWithGlobalIdFormat() throws Exception {
    SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(CISCO_WS_C2948_IP));
    String trackerName = "cdpGlobalGroup";
    final CdpGlobalGroupTracker cdpGlobalGroup = new CdpGlobalGroupTracker();
    try {
        m_client.walk(config, cdpGlobalGroup).withDescription(trackerName).withLocation(null).execute().get();
    } catch (final InterruptedException e) {
        LOG.error("run: Cdp Linkd collection interrupted, exiting", e);
        return;
    }
    assertEquals("JAB043408B7", cdpGlobalGroup.getCdpDeviceId());
    assertEquals(1, cdpGlobalGroup.getCdpGlobalRun().intValue());
    assertEquals(3, cdpGlobalGroup.getCdpGlobalDeviceFormat().intValue());
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) CdpGlobalGroupTracker(org.opennms.netmgt.enlinkd.snmp.CdpGlobalGroupTracker) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 3 with CdpGlobalGroupTracker

use of org.opennms.netmgt.enlinkd.snmp.CdpGlobalGroupTracker in project opennms by OpenNMS.

the class NodeDiscoveryCdp method runCollection.

protected void runCollection() {
    final Date now = new Date();
    final CdpGlobalGroupTracker cdpGlobalGroup = new CdpGlobalGroupTracker();
    SnmpAgentConfig peer = m_linkd.getSnmpAgentConfig(getPrimaryIpAddress(), getLocation());
    try {
        m_linkd.getLocationAwareSnmpClient().walk(peer, cdpGlobalGroup).withDescription("cdpGlobalGroup").withLocation(getLocation()).execute().get();
    } catch (ExecutionException e) {
        LOG.info("run: node [{}]: ExecutionException: cdpGlobalGroup: {}", getNodeId(), e.getMessage());
        return;
    } catch (final InterruptedException e) {
        LOG.info("run: node [{}]: InterruptedException: cdpGlobalGroup: {}", getNodeId(), e.getMessage());
        return;
    }
    if (cdpGlobalGroup.getCdpDeviceId() == null) {
        LOG.info("run: node [{}]: CDP_MIB not supported", getNodeId());
        return;
    }
    CdpElement cdpElement = cdpGlobalGroup.getCdpElement();
    m_linkd.getQueryManager().store(getNodeId(), cdpElement);
    if (cdpElement.getCdpGlobalRun() == TruthValue.FALSE) {
        LOG.info("run: node [{}]. CDP disabled.", getNodeId());
        return;
    }
    List<CdpLink> links = new ArrayList<>();
    CdpCacheTableTracker cdpCacheTable = new CdpCacheTableTracker() {

        public void processCdpCacheRow(final CdpCacheRow row) {
            links.add(row.getLink());
        }
    };
    try {
        m_linkd.getLocationAwareSnmpClient().walk(peer, cdpCacheTable).withDescription("cdpCacheTable").withLocation(getLocation()).execute().get();
    } catch (ExecutionException e) {
        LOG.info("run: node [{}]: ExecutionException: cdpCacheTable: {}", getNodeId(), e.getMessage());
        return;
    } catch (final InterruptedException e) {
        LOG.info("run: node [{}]: InterruptedException: cdpCacheTable: {}", getNodeId(), e.getMessage());
        return;
    }
    final CdpInterfacePortNameGetter cdpInterfacePortNameGetter = new CdpInterfacePortNameGetter(peer, m_linkd.getLocationAwareSnmpClient(), getLocation(), getNodeId());
    for (CdpLink link : links) m_linkd.getQueryManager().store(getNodeId(), cdpInterfacePortNameGetter.get(link));
    m_linkd.getQueryManager().reconcileCdp(getNodeId(), now);
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) CdpInterfacePortNameGetter(org.opennms.netmgt.enlinkd.snmp.CdpInterfacePortNameGetter) CdpCacheTableTracker(org.opennms.netmgt.enlinkd.snmp.CdpCacheTableTracker) ArrayList(java.util.ArrayList) CdpGlobalGroupTracker(org.opennms.netmgt.enlinkd.snmp.CdpGlobalGroupTracker) ExecutionException(java.util.concurrent.ExecutionException) CdpLink(org.opennms.netmgt.model.CdpLink) Date(java.util.Date) CdpElement(org.opennms.netmgt.model.CdpElement)

Aggregations

CdpGlobalGroupTracker (org.opennms.netmgt.enlinkd.snmp.CdpGlobalGroupTracker)3 SnmpAgentConfig (org.opennms.netmgt.snmp.SnmpAgentConfig)3 Test (org.junit.Test)2 JUnitSnmpAgents (org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ExecutionException (java.util.concurrent.ExecutionException)1 CdpCacheTableTracker (org.opennms.netmgt.enlinkd.snmp.CdpCacheTableTracker)1 CdpInterfacePortNameGetter (org.opennms.netmgt.enlinkd.snmp.CdpInterfacePortNameGetter)1 CdpElement (org.opennms.netmgt.model.CdpElement)1 CdpLink (org.opennms.netmgt.model.CdpLink)1