public static IpInterfaceTopologyEntity create(OnmsIpInterface ipInterface) { return new IpInterfaceTopologyEntity( ipInterface.getId(), ipInterface.getIpAddress(), ipInterface.getIsManaged(), ipInterface.getIsSnmpPrimary(), Optional.ofNullable(ipInterface.getNode()).map(OnmsNode::getId).orElse(null), Optional.ofNullable(ipInterface.getSnmpInterface()).map(OnmsSnmpInterface::getId).orElse(null)); }
Set<OnmsMonitoredService> getExisting() { return m_iface.getMonitoredServices(); }
/** * <p>updateSnmpInterface</p> * * @param scannedIface a {@link org.opennms.netmgt.model.OnmsIpInterface} object. */ public void updateSnmpInterface(OnmsIpInterface scannedIface) { if (!hasNewValue(scannedIface.getIfIndex(), getIfIndex())) { /* no ifIndex in currently scanned interface so don't bother * we must have failed to collect data */ return; } if (scannedIface.getSnmpInterface() == null) { // there is no longer an snmpInterface associated with the ipInterface setSnmpInterface(null); } else { // locate the snmpInterface on this node that has the new ifIndex and set it // into the interface OnmsSnmpInterface snmpIface = getNode().getSnmpInterfaceWithIfIndex(scannedIface.getIfIndex()); setSnmpInterface(snmpIface); } }
private OnmsIpInterface createIpInterface(OnmsSnmpInterface snmp, InetAddress inetAddress) { OnmsIpInterface ip = new OnmsIpInterface(); ip.setSnmpInterface(snmp); ip.setIpLastCapsdPoll(new Date()); ip.setNode(snmp.getNode()); ip.setIpAddress(inetAddress); return ip; }
if (hasNewValue(scannedIface.getIfIndex(), getIfIndex())) { setIfIndex(scannedIface.getIfIndex()); if (hasNewValue(scannedIface.getNetMask(), getNetMask())) { setNetMask(scannedIface.getNetMask()); if (hasNewValue(scannedIface.getIsManaged(), getIsManaged())) { setIsManaged(scannedIface.getIsManaged()); if (hasNewCollectionTypeValue(scannedIface.getIsSnmpPrimary(), getIsSnmpPrimary())) { setIsSnmpPrimary(scannedIface.getIsSnmpPrimary()); if (hasNewValue(scannedIface.getIpHostName(), getIpHostName())) { setIpHostName(scannedIface.getIpHostName()); if (hasNewValue(scannedIface.getIpLastCapsdPoll(), getIpLastCapsdPoll())) { setIpLastCapsdPoll(scannedIface.getIpLastCapsdPoll());
/** * <p>getIpAddress</p> * * @return a {@link java.lang.String} object. */ @XmlTransient @Transient @JsonIgnore public InetAddress getIpAddress() { return m_ipInterface.getIpAddress(); }
OnmsIpInterface ipIf = node.getIpInterfaceByIpAddress(ipAddr); if (ipIf == null) { ipIf = new OnmsIpInterface(ipAddr, node); InetAddress inetAddr = ipIf.getIpAddress(); Integer ifIndex = getIfIndex(inetAddr); ipIf.setNetMask(mask); ipIf.setSnmpInterface(snmpIf); ipIf.setIpHostName(ipAddr);
public OpennmsModelProtos.IpInterface.Builder toIpInterface(OnmsIpInterface ipInterface) { if (ipInterface == null) { return null; } final OpennmsModelProtos.IpInterface.Builder builder = OpennmsModelProtos.IpInterface.newBuilder() .setId(ipInterface.getId()) .setIpAddress(InetAddressUtils.toIpAddrString(ipInterface.getIpAddress())); final OnmsSnmpInterface snmpInterface = ipInterface.getSnmpInterface(); if (snmpInterface != null && snmpInterface.getIfIndex() != null) { builder.setIfIndex(snmpInterface.getIfIndex()); } final PrimaryType primaryType = ipInterface.getIsSnmpPrimary(); if (PrimaryType.PRIMARY.equals(primaryType)) { builder.setPrimaryType(OpennmsModelProtos.IpInterface.PrimaryType.PRIMARY); } else if (PrimaryType.SECONDARY.equals(primaryType)) { builder.setPrimaryType(OpennmsModelProtos.IpInterface.PrimaryType.SECONDARY); } else if (PrimaryType.NOT_ELIGIBLE.equals(primaryType)) { builder.setPrimaryType(OpennmsModelProtos.IpInterface.PrimaryType.NOT_ELIGIBLE); } ipInterface.getMonitoredServices().forEach(svc -> builder.addService(svc.getServiceName())); return builder; }
/** * <p>createNodeGainedInterfaceEvent</p> * * @param iface a {@link org.opennms.netmgt.model.OnmsIpInterface} object. * @return a {@link org.opennms.netmgt.xml.event.Event} object. */ protected Event createNodeGainedInterfaceEvent(OnmsIpInterface iface) { return EventUtils.createNodeGainedInterfaceEvent(m_eventSource, iface.getNode().getId(), iface.getIpAddress()); }
/** * <p>createNodeGainedServiceEvent</p> * * @param monSvc a {@link org.opennms.netmgt.model.OnmsMonitoredService} object. * @return a {@link org.opennms.netmgt.xml.event.Event} object. */ protected Event createNodeGainedServiceEvent(final OnmsMonitoredService monSvc) { final OnmsIpInterface iface = monSvc.getIpInterface(); final OnmsNode node = iface.getNode(); LOG.debug("ipinterface = {}", iface); LOG.debug("snmpinterface = {}", iface.getSnmpInterface()); LOG.debug("node = {}", node); return EventUtils.createNodeGainedServiceEvent(m_eventSource, monSvc.getNodeId(), iface.getIpAddress(), monSvc.getServiceType().getName(), node.getLabel(), node.getLabelSource(), node.getSysName(), node.getSysDescription()); }
final String o1ip = InetAddressUtils.str(o1.getIpAddress()); final String o2ip = InetAddressUtils.str(o2.getIpAddress()); if (!"0.0.0.0".equals(o1ip) && !"0.0.0.0".equals(o2ip)) { return new ByteArrayComparator().compare(InetAddressUtils.toIpAddrBytes(o1ip), InetAddressUtils.toIpAddrBytes(o2ip)); if (o1.getSnmpInterface() == null || o2.getSnmpInterface() == null) { if (o1.getSnmpInterface() != null) { return -1; } else { return o1.getId().compareTo(o2.getId()); if (o1.getSnmpInterface().getIfName() == null || o2.getSnmpInterface().getIfName() == null) { if (o1.getSnmpInterface().getIfName() != null) { return -1; } else if (o2.getSnmpInterface().getIfName() != null) { return 1; } else if ((diff = o1.getSnmpInterface().getIfName().compareTo(o2.getSnmpInterface().getIfName())) != 0) { return diff; if (o1.getSnmpInterface().getIfDescr() == null || o2.getSnmpInterface().getIfDescr() == null) { if (o1.getSnmpInterface().getIfDescr() != null) { return -1; } else if (o2.getSnmpInterface().getIfDescr() != null) { return 1; } else if ((diff = o1.getSnmpInterface().getIfDescr().compareTo(o2.getSnmpInterface().getIfDescr())) != 0) { return diff;
public AvailabilityIpInterface(final OnmsIpInterface iface, final double availability) { m_id = iface.getId(); m_address = str(iface.getIpAddress()); m_availability = availability; }
private void dataSourceSyncWithinTransaction() { m_lock.writeLock().lock(); try { /* * Make a new list with which we'll replace the existing one, that way * if something goes wrong with the DB we won't lose whatever was already * in there */ final SortedSetMultimap<Key, Value> newAlreadyDiscovered = Multimaps.newSortedSetMultimap(Maps.newHashMap(), TreeSet::new); // Fetch all non-deleted nodes final CriteriaBuilder builder = new CriteriaBuilder(OnmsNode.class); builder.ne("type", String.valueOf(NodeType.DELETED.value())); for (OnmsNode node : m_nodeDao.findMatching(builder.toCriteria())) { for (final OnmsIpInterface iface : node.getIpInterfaces()) { // Skip deleted interfaces // TODO: Refactor the 'D' value with an enumeration if ("D".equals(iface.getIsManaged())) { continue; } LOG.debug("Adding entry: {}:{} -> {}", node.getLocation().getLocationName(), iface.getIpAddress(), node.getId()); newAlreadyDiscovered.put(new Key(node.getLocation().getLocationName(), iface.getIpAddress()), new Value(node.getId(), iface.getIsSnmpPrimary())); } } m_managedAddresses.clear(); m_managedAddresses.putAll(newAlreadyDiscovered); LOG.info("dataSourceSync: initialized list of managed IP addresses with {} members", m_managedAddresses.size()); } finally { m_lock.writeLock().unlock(); } }
void updateIpInterface(final BatchTask currentPhase, final OnmsIpInterface iface) { getProvisionService().updateIpInterfaceAttributes(getNodeId(), iface); if (iface.isManaged()) { currentPhase.add(new IpInterfaceScan(getNodeId(), iface.getIpAddress(), getForeignSource(), getLocation(), getProvisionService())); } }
public OnmsIpInterface createInterfaceFromRow() { final Integer ifIndex = getIfIndex(); final String ipAddr = getIpAddress(); final InetAddress netMask = getNetMask(); LOG.debug("createInterfaceFromRow: ifIndex = {}, ipAddress = {}, netmask = {}", ifIndex, ipAddr, netMask); if (ipAddr == null) { return null; } final InetAddress inetAddress = InetAddressUtils.addr(ipAddr); final OnmsIpInterface iface = new OnmsIpInterface(inetAddress, null); iface.setNetMask(netMask); if (ifIndex != null) { final OnmsSnmpInterface snmpIface = new OnmsSnmpInterface(null, ifIndex); snmpIface.setCollectionEnabled(true); iface.setSnmpInterface(snmpIface); iface.setIfIndex(ifIndex); } String hostName = null; if (inetAddress != null) hostName = inetAddress.getHostName(); if (hostName == null) hostName = InetAddressUtils.normalize(ipAddr); iface.setIpHostName(hostName == null? ipAddr : hostName); return iface; }
protected void createAgent(int ifIndex, PrimaryType ifCollType) { m_node = new OnmsNode(); m_node.setSysObjectId(".1.2.3.4.5.6.7"); OnmsSnmpInterface snmpIface = new OnmsSnmpInterface(m_node, ifIndex); m_iface = new OnmsIpInterface(); m_iface.setId(123); m_iface.setIpAddress(myLocalHost()); m_iface.setIsSnmpPrimary(ifCollType); m_iface.setSnmpInterface(snmpIface); m_node.addIpInterface(m_iface); EasyMock.expect(m_ifaceDao.load(m_iface.getId())).andReturn(m_iface).anyTimes(); m_easyMockUtils.replayAll(); m_agent = DefaultSnmpCollectionAgent.create(m_iface.getId(), m_ifaceDao, new MockPlatformTransactionManager()); }
@Override protected Integer getId(final OnmsIpInterface iface) { return iface.getId(); }
private void update(OnmsIpInterface imported, OnmsIpInterface iface, List<Event> events) { if (!nullSafeEquals(iface.getIsManaged(), imported.getIsManaged())) iface.setIsManaged(imported.getIsManaged()); if (!nullSafeEquals(iface.getIsSnmpPrimary(), imported.getIsSnmpPrimary())) { iface.setIsSnmpPrimary(imported.getIsSnmpPrimary()); // TODO: send snmpPrimary event } if (isSnmpDataForInterfacesUpToDate()) { updateSnmpInterface(imported, iface); } if (!nullSafeEquals(iface.getIpHostName(), imported.getIpHostName())) iface.setIpHostName(imported.getIpHostName()); updateServices(iface, imported, events); }
final InetAddress inetAddr = ipIf.getIpAddress(); final String ipAddr = InetAddressUtils.str(inetAddr); ipIf.setSnmpInterface(snmpIf);