private Set<OnmsSnmpInterface> getExistingInterfaces() { return m_dbNode.getSnmpInterfaces(); }
/** * <p>Constructor for OnmsSnmpInterface.</p> * @param node a {@link org.opennms.netmgt.model.OnmsNode} object. * @param ifIndex a {@link java.lang.Integer} object. */ public OnmsSnmpInterface(OnmsNode node, Integer ifIndex) { m_ifIndex = ifIndex; m_node = node; if (node != null) { node.getSnmpInterfaces().add(this); } }
public NodeBean(OnmsNode node) { this.node = Objects.requireNonNull(node); this.snmpInterfaces = node.getSnmpInterfaces().stream() .map(SnmpInterfaceBean::new) .collect(Collectors.toList()); }
private Set<OnmsSnmpInterface> getSnmpInterfaces() { OnmsNode node = getNode(); Set<OnmsSnmpInterface> snmpIfs = node.getSnmpInterfaces(); if (snmpIfs.size() == 0) { LOG.debug("no known SNMP interfaces for node {}", node); } return snmpIfs; }
/** * <p>addSnmpInterface</p> * * @param snmpIface a {@link org.opennms.netmgt.model.OnmsSnmpInterface} object. */ public void addSnmpInterface(OnmsSnmpInterface snmpIface) { snmpIface.setNode(this); getSnmpInterfaces().add(snmpIface); }
public SnmpInterfaceUpdater(OnmsNode db, OnmsNode imported) { m_dbNode = db; m_ifIndexToSnmpInterface = mapIfIndexToSnmpInterface(imported.getSnmpInterfaces()); }
/** * <p>getSnmpInterfaceWithIfIndex</p> * * @param ifIndex a int. * @return a {@link org.opennms.netmgt.model.OnmsSnmpInterface} object. */ @Transient @JsonIgnore public OnmsSnmpInterface getSnmpInterfaceWithIfIndex(int ifIndex) { for (OnmsSnmpInterface dbSnmpIface : getSnmpInterfaces()) { if (dbSnmpIface.getIfIndex().equals(ifIndex)) { return dbSnmpIface; } } return null; }
/** * This method computes the utilization of a given interface resource. The method returns two double values * encapsulated in a list. It uses the HC attributes for the computation and non-HC as fallback attributes. * * @param node the node to be used * @param ifName the inteface of the node * @return the in/out percentage utilization encapsulated in a list */ public List<Double> computeUtilization(final OnmsNode node, final String ifName) throws MeasurementException { long end = System.currentTimeMillis(); long start = end - (15 * 60 * 1000); for(OnmsSnmpInterface snmpInterface : node.getSnmpInterfaces()) { if (ifName.equals(snmpInterface.getIfName())) { String resourceId = "node[" + node.getId() + "].interfaceSnmp[" + snmpInterface.computeLabelForRRD() + "]"; return computeUtilization(resourceId, start, end, 300000, "AVERAGE"); } } return Arrays.asList(Double.NaN, Double.NaN); }
/** * This method computes the utilization of a given interface resource. The method returns two double values * encapsulated in a list. It uses the HC attributes for the computation and non-HC as fallback attributes. * * @param node the node to be used * @param ifName the inteface of the node * @return the in/out percentage utilization encapsulated in a list */ public List<Double> computeUtilization(final OnmsNode node, final String ifName) throws MeasurementException { long end = System.currentTimeMillis(); long start = end - (15 * 60 * 1000); for(OnmsSnmpInterface snmpInterface : node.getSnmpInterfaces()) { if (ifName.equals(snmpInterface.getIfName())) { String resourceId = "node[" + node.getId() + "].interfaceSnmp[" + snmpInterface.computeLabelForRRD() + "]"; return computeUtilization(resourceId, start, end, 300000, "AVERAGE"); } } return Arrays.asList(Double.NaN, Double.NaN); }
public List<OnmsSnmpInterface> findObsoleteSnmpInterfaces(final Integer nodeId, final Date scanStamp) { final List<OnmsSnmpInterface> ifaces = new ArrayList<>(); final OnmsNode node = get(nodeId); if (node == null) return ifaces; for (final OnmsSnmpInterface iface : node.getSnmpInterfaces()) { if (truncateMillis(iface.getLastCapsdPoll()) < truncateMillis(scanStamp)) { LOG.debug("findObsoleteSnmpInterfaces: {} < {}", truncateMillis(iface.getLastCapsdPoll()), truncateMillis(scanStamp)); ifaces.add(iface); } } return ifaces; }
public List<OnmsSnmpInterface> findObsoleteSnmpInterfaces(final Integer nodeId, final Date scanStamp) { final List<OnmsSnmpInterface> ifaces = new ArrayList<>(); final OnmsNode node = get(nodeId); if (node == null) return ifaces; for (final OnmsSnmpInterface iface : node.getSnmpInterfaces()) { if (truncateMillis(iface.getLastCapsdPoll()) < truncateMillis(scanStamp)) { LOG.debug("findObsoleteSnmpInterfaces: {} < {}", truncateMillis(iface.getLastCapsdPoll()), truncateMillis(scanStamp)); ifaces.add(iface); } } return ifaces; }
@Override public void deleteObsoleteInterfaces(final Integer nodeId, final Date scanStamp) { final OnmsNode node = get(nodeId); if (node == null) return; for (final OnmsIpInterface iface : findObsoleteIpInterfaces(nodeId, scanStamp)) { LOG.debug("Deleting obsolete IP interface: {}", iface); node.getIpInterfaces().remove(iface); getIpInterfaceDao().delete(iface.getId()); } for (final OnmsSnmpInterface iface : findObsoleteSnmpInterfaces(nodeId, scanStamp)) { LOG.debug("Deleting obsolete SNMP interface: {}", iface); node.getSnmpInterfaces().remove(iface); getSnmpInterfaceDao().delete(iface.getId()); } }
@Override public void deleteObsoleteInterfaces(final Integer nodeId, final Date scanStamp) { final OnmsNode node = get(nodeId); if (node == null) return; for (final OnmsIpInterface iface : findObsoleteIpInterfaces(nodeId, scanStamp)) { LOG.debug("Deleting obsolete IP interface: {}", iface); node.getIpInterfaces().remove(iface); getIpInterfaceDao().delete(iface.getId()); } for (final OnmsSnmpInterface iface : findObsoleteSnmpInterfaces(nodeId, scanStamp)) { LOG.debug("Deleting obsolete SNMP interface: {}", iface); node.getSnmpInterfaces().remove(iface); getSnmpInterfaceDao().delete(iface.getId()); } }
/** {@inheritDoc} */ @Override public void visit(EntityVisitor visitor) { visitor.visitNode(this); for (OnmsIpInterface iface : getIpInterfaces()) { iface.visit(visitor); } for (OnmsSnmpInterface snmpIface : getSnmpInterfaces()) { snmpIface.visit(visitor); } visitor.visitNodeComplete(this); }
/** {@inheritDoc} */ @Override public OnmsNode getHierarchy(Integer id) { OnmsNode node = findUnique( "select distinct n from OnmsNode as n " + "left join fetch n.assetRecord " + "where n.id = ?", id); initialize(node.getIpInterfaces()); for (OnmsIpInterface i : node.getIpInterfaces()) { initialize(i.getMonitoredServices()); } initialize(node.getSnmpInterfaces()); for (OnmsSnmpInterface i : node.getSnmpInterfaces()) { initialize(i.getIpInterfaces()); } return node; }
@Override public void delete(final OnmsNode node) { for (final OnmsIpInterface iface : node.getIpInterfaces()) { getIpInterfaceDao().delete(iface); } for (final OnmsSnmpInterface iface : node.getSnmpInterfaces()) { getSnmpInterfaceDao().delete(iface); } super.delete(node); }
@Override public void delete(final OnmsNode node) { for (final OnmsIpInterface iface : node.getIpInterfaces()) { getIpInterfaceDao().delete(iface); } for (final OnmsSnmpInterface iface : node.getSnmpInterfaces()) { getSnmpInterfaceDao().delete(iface); } super.delete(node); }
private void updateParent(final OnmsSnmpInterface iface) { OnmsNode node = null; if (iface.getNodeId() != null) { node = getNodeDao().get(iface.getNodeId()); } else if (iface.getNode() != null) { node = getNodeDao().findByForeignId(iface.getNode().getForeignSource(), iface.getNode().getForeignId()); } if (node != null && node != iface.getNode()) { LOG.debug("merging node {} into node {}", iface.getNode(), node); node.mergeNode(iface.getNode(), new NullEventForwarder(), false); iface.setNode(node); } if (!iface.getNode().getSnmpInterfaces().contains(iface)) { LOG.debug("adding SNMP interface to node {}: {}", iface.getNode().getId(), iface); iface.getNode().addSnmpInterface(iface); } }
private void updateParent(final OnmsSnmpInterface iface) { OnmsNode node = null; if (iface.getNodeId() != null) { node = getNodeDao().get(iface.getNodeId()); } else if (iface.getNode() != null) { node = getNodeDao().findByForeignId(iface.getNode().getForeignSource(), iface.getNode().getForeignId()); } if (node != null && node != iface.getNode()) { LOG.debug("merging node {} into node {}", iface.getNode(), node); node.mergeNode(iface.getNode(), new NullEventForwarder(), false); iface.setNode(node); } if (!iface.getNode().getSnmpInterfaces().contains(iface)) { LOG.debug("adding SNMP interface to node {}: {}", iface.getNode().getId(), iface); iface.getNode().addSnmpInterface(iface); } }
node.getSnmpInterfaces().forEach(s -> builder.addSnmpInterface(toSnmpInterface(s))); node.getIpInterfaces().forEach(i -> builder.addIpInterface(toIpInterface(i)));