use of org.opennms.netmgt.provision.service.snmp.IfXTable in project opennms by OpenNMS.
the class ScanManager method updateSnmpData.
void updateSnmpData(final OnmsNode node) {
try {
m_systemGroup = new SystemGroup(m_address);
final Set<SnmpInstId> ipAddrs = new TreeSet<SnmpInstId>();
final Set<InetAddress> ipAddresses = new HashSet<InetAddress>();
for (final OnmsIpInterface iface : node.getIpInterfaces()) {
final InetAddress addr = iface.getIpAddress();
if (addr != null && addr instanceof Inet4Address) {
ipAddrs.add(new SnmpInstId(InetAddressUtils.toOid(addr)));
}
ipAddresses.add(addr);
}
m_ipAddrTable = new IpAddrTable(m_address, ipAddrs);
m_ipAddressTable = IpAddressTable.createTable(m_address, ipAddresses);
AggregateTracker tracker = new AggregateTracker(Lists.newArrayList(m_systemGroup, m_ipAddrTable, m_ipAddressTable));
final SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(m_address, MonitoringLocationUtils.getLocationNameOrNullIfDefault(node));
try {
m_locationAwareSnmpClient.walk(agentConfig, tracker).withDescription("system/ipAddrTable/ipAddressTable").withLocation(node.getLocation() == null ? null : node.getLocation().getLocationName()).execute().get();
} catch (ExecutionException e) {
// pass
}
final Set<SnmpInstId> ifIndices = new TreeSet<SnmpInstId>();
for (final Integer ifIndex : m_ipAddrTable.getIfIndices()) {
ifIndices.add(new SnmpInstId(ifIndex));
}
m_ifTable = new IfTable(m_address, ifIndices);
m_ifXTable = new IfXTable(m_address, ifIndices);
tracker = new AggregateTracker(Lists.newArrayList(m_systemGroup, m_ifTable, m_ifXTable));
try {
m_locationAwareSnmpClient.walk(agentConfig, tracker).withDescription("ifTable/ifXTable").withLocation(node.getLocation() == null ? null : node.getLocation().getLocationName()).execute().get();
} catch (ExecutionException e) {
// pass
}
m_systemGroup.updateSnmpDataForNode(node);
for (final SnmpInstId ifIndex : ifIndices) {
m_ifTable.updateSnmpInterfaceData(node, ifIndex.toInt());
}
for (final SnmpInstId ifIndex : ifIndices) {
m_ifXTable.updateSnmpInterfaceData(node, ifIndex.toInt());
}
for (final SnmpInstId ipAddr : ipAddrs) {
m_ipAddrTable.updateIpInterfaceData(node, ipAddr.toString());
}
for (final InetAddress addr : ipAddresses) {
m_ipAddressTable.updateIpInterfaceData(node, InetAddressUtils.str(addr));
}
} catch (final InterruptedException e) {
LOG.info("thread interrupted while updating SNMP data", e);
Thread.currentThread().interrupt();
}
}
Aggregations