use of org.opennms.netmgt.enlinkd.snmp.CdpInterfacePortNameGetter 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);
}
use of org.opennms.netmgt.enlinkd.snmp.CdpInterfacePortNameGetter 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, 0);
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());
}
Aggregations