@Override public String getIfDescr() { return snmpInterface.getIfDescr(); }
protected static String[] getKeysFor(OnmsSnmpInterface snmpInterface) { /* * When Cisco Express Forwarding (CEF) or some ATM encapsulations * (AAL5) are used on Cisco routers, an additional entry might be * in the ifTable for these sub-interfaces, but there is no * performance data available for collection. This check excludes * ifTable entries where ifDescr contains "-cef". See bug #803. */ if (snmpInterface.getIfDescr() != null) { if (Pattern.matches(".*-cef.*", snmpInterface.getIfDescr())) { return new String[0]; } } String replacedIfName = AlphaNumeric.parseAndReplace(snmpInterface.getIfName(), '_'); String replacedIfDescr = AlphaNumeric.parseAndReplace(snmpInterface.getIfDescr(), '_'); return new String[] { replacedIfName + "-", replacedIfDescr + "-", replacedIfName + "-" + snmpInterface.getPhysAddr(), replacedIfDescr + "-" + snmpInterface.getPhysAddr() }; }
private static void logInitializeSnmpIf(OnmsSnmpInterface snmpIface) { LOG.debug("initialize: snmpifindex = {}, snmpifname = {}, snmpifdescr = {}, snmpphysaddr = -{}-", snmpIface.getIfIndex(), snmpIface.getIfName(), snmpIface.getIfDescr(), snmpIface.getPhysAddr()); LOG.debug("initialize: ifLabel = '{}'", snmpIface.computeLabelForRRD()); }
if (o1.getIfDescr() == null || o2.getIfDescr() == null) { if (o1.getIfDescr() != null) { return -1; } else if (o2.getIfDescr() != null) { return 1; } else if ((diff = o1.getIfDescr().compareTo(o2.getIfDescr())) != 0) { return diff;
if (o1.getIfDescr() == null || o2.getIfDescr() == null) { if (o1.getIfDescr() != null) { return -1; } else if (o2.getIfDescr() != null) { return 1; } else if ((diff = o1.getIfDescr().compareTo(o2.getIfDescr())) != 0) { return diff;
@Override public FlowNodeDetails getFlowExporter(Integer nodeId) { final List<FlowSnmpInterface> ifaces = transactionOperations.execute(status -> this.snmpInterfaceDao.findAllHavingFlows(nodeId)).stream() .map(iface -> new FlowSnmpInterface(iface.getIfIndex(), iface.getIfName(), iface.getIfAlias(), iface.getIfDescr())) .collect(Collectors.toList()); return new FlowNodeDetails(nodeId, ifaces); }
/** * <p>computeLabelForRRD</p> * * @return a {@link java.lang.String} object. */ public String computeLabelForRRD() { return RrdLabelUtils.computeLabelForRRD(getIfName(), getIfDescr(), getPhysAddr()); }
/** * <p>computeNameForRRD</p> * * @return a {@link java.lang.String} object. */ public String computeNameForRRD() { /* * Determine the label for this interface. The label will be used to * create the RRD file name which holds SNMP data retreived from the * remote agent. If available ifName is used to generate the label * since it is guaranteed to be unique. Otherwise ifDescr is used. In * either case, all non alpha numeric characters are converted to * underscores to ensure that the resuling string will make a decent * file name and that RRD won't have any problems using it */ String firstChoice = RrdLabelUtils.PREFER_IFDESCR ? getIfDescr() : getIfName(); String secondChoice = RrdLabelUtils.PREFER_IFDESCR ? getIfName() : getIfDescr(); String label = null; if (firstChoice != null) { label = RrdLabelUtils.DONT_SANITIZE_IFNAME ? firstChoice : AlphaNumeric.parseAndReplace(firstChoice, '_'); } else if (secondChoice != null) { label = RrdLabelUtils.DONT_SANITIZE_IFNAME ? secondChoice : AlphaNumeric.parseAndReplace(secondChoice, '_'); } else { // TODO: Use IfLabel.NO_IFLABEL instead of "no_ifLabel" LOG.info("Interface ({}) has no ifName and no ifDescr...setting to label to 'no_ifLabel'.", this); label = "no_ifLabel"; } return label; }
@Override public FlowNodeDetails getFlowExporter(Integer nodeId) { final List<FlowSnmpInterface> ifaces = transactionOperations.execute(status -> this.snmpInterfaceDao.findAllHavingFlows(nodeId)).stream() .map(iface -> new FlowSnmpInterface(iface.getIfIndex(), iface.getIfName(), iface.getIfAlias(), iface.getIfDescr())) .collect(Collectors.toList()); return new FlowNodeDetails(nodeId, ifaces); }
public ReverseDnsRecord(OnmsIpInterface ipInterface, int level) { OnmsSnmpInterface snmpInterface = ipInterface.getSnmpInterface(); if (snmpInterface == null) { LOG.debug("Constructor: no SnmpInterface found"); m_hostname=ipInterface.getNode().getLabel()+"."; } else if ( snmpInterface.getIfName() != null ) { LOG.debug("Constructor: SnmpInterface found: ifname: {}", snmpInterface.getIfName()); m_hostname=AlphaNumeric.parseAndReplace(snmpInterface.getIfName(),'-')+"-"+ipInterface.getNode().getLabel()+"."; } else if (snmpInterface.getIfDescr() != null ) { LOG.debug("Constructor: SnmpInterface found: ifdescr: {}", snmpInterface.getIfDescr()); m_hostname=AlphaNumeric.parseAndReplace(snmpInterface.getIfDescr(),'-')+"-"+ipInterface.getNode().getLabel()+"."; } else { LOG.debug("Constructor: SnmpInterface found: ifindex: {}", snmpInterface.getIfDescr()); m_hostname="ifindex-"+snmpInterface.getIfIndex()+"-"+ipInterface.getNode().getLabel()+"."; } LOG.debug("Constructor: set hostname: {}", m_hostname); m_ip = ipInterface.getIpAddress(); LOG.debug("Constructor: set ip address: {}", m_ip); if (level == 1) m_zone = ReverseDnsRecord.firstLevelZonefromInet4Address(m_ip.getAddress()); else if (level == 2) m_zone = ReverseDnsRecord.secondLevelZonefromInet4Address(m_ip.getAddress()); else m_zone=ReverseDnsRecord.thirdLevelZonefromInet4Address(m_ip.getAddress()); LOG.debug("Constructor: set zone: {}", m_zone); }
/** * <p>toString</p> * * @return a {@link java.lang.String} object. */ @Override public String toString() { return MoreObjects.toStringHelper(this) .add("snmpphysaddr", getPhysAddr()) .add("snmpifindex", getIfIndex()) .add("snmpifdescr", getIfDescr()) .add("snmpiftype", getIfType()) .add("snmpifname", getIfName()) .add("snmpifspeed", getIfSpeed()) .add("snmpifadminstatus", getIfAdminStatus()) .add("snmpifoperstatus", getIfOperStatus()) .add("snmpifalias", getIfAlias()) .add("snmpCollect", getCollect()) .add("snmpPoll", getPoll()) .add("nodeId", getNode() == null ? null : getNode().getId()) .add("lastCapsdPoll", getLastCapsdPoll()) .add("lastSnmpPoll", getLastSnmpPoll()) .add("hasFlows", getHasFlows()) .toString(); }
/** * Return the ifLabel as a string for the given node and ifIndex. Intended for * use with non-ip interfaces. * * @return String * @param nodeId a int. * @param ifIndex a int. */ @Override public String getIfLabelfromSnmpIfIndex(final int nodeId, final int ifIndex) { OnmsSnmpInterface iface = m_snmpInterfaceDao.findByNodeIdAndIfIndex(nodeId, ifIndex); String name = iface.getIfName(); String descr = iface.getIfDescr(); String physAddr = iface.getPhysAddr(); if (name != null || descr != null) { return getIfLabel(name, descr, physAddr); } else { LOG.warn("Interface (nodeId/ifIndex={}/{}) has no ifName and no ifDescr...setting to label to '{}'.", nodeId, ifIndex, IfLabel.NO_IFLABEL); return IfLabel.NO_IFLABEL; } } }
/** * <p>Constructor for SnmpIfData.</p> * * @param snmpIface a {@link org.opennms.netmgt.model.OnmsSnmpInterface} object. */ public SnmpIfData(OnmsSnmpInterface snmpIface) { m_nodeId = nullSafeUnbox(snmpIface.getNode().getId(), -1); m_collectionEnabled = snmpIface.isCollectionEnabled(); m_ifIndex = nullSafeUnbox(snmpIface.getIfIndex(), -1); m_ifType = nullSafeUnbox(snmpIface.getIfType(), -1); m_rrdLabel = snmpIface.computeLabelForRRD(); m_ifAlias = snmpIface.getIfAlias(); m_attributes.put("snmpphysaddr", snmpIface.getPhysAddr()); m_attributes.put("snmpifindex", Integer.toString(m_ifIndex)); m_attributes.put("snmpifdescr", snmpIface.getIfDescr()); m_attributes.put("snmpiftype", Integer.toString(m_ifType)); m_attributes.put("snmpifname", snmpIface.getIfName()); m_attributes.put("snmpifadminstatus", Integer.toString(nullSafeUnbox(snmpIface.getIfAdminStatus(), -1))); m_attributes.put("snmpifoperstatus", Integer.toString(nullSafeUnbox(snmpIface.getIfOperStatus(), -1))); m_attributes.put("snmpifspeed", Long.toString(nullSafeUnbox(snmpIface.getIfSpeed(), -1))); m_attributes.put("snmpifalias", m_ifAlias); }
String descr = iface.getIfDescr(); String physAddr = iface.getPhysAddr();
String descr = iface.getIfDescr(); String physAddr = iface.getPhysAddr();
/** {@inheritDoc} */ @Override public Event createEvent(final String uei, final int nodeId, final String addr, final String netMask, final Date date, final OnmsSnmpInterface snmpinterface) { log().debug("createEvent: uei = " + uei + " nodeid = " + nodeId + " date = " + date); EventBuilder bldr = new EventBuilder(uei, this.getName(), date); bldr.setNodeid(nodeId); if (addr != null) { bldr.setInterface(InetAddressUtils.addr(addr)); } if (netMask != null) { bldr.addParam(EventConstants.PARM_SNMP_INTERFACE_MASK, InetAddressUtils.normalize(netMask)); } bldr.setService(getServiceName()); bldr.setHost(this.getLocalHostName()); bldr.setField("ifIndex", snmpinterface.getIfIndex().toString()); bldr.addParam(EventConstants.PARM_SNMP_INTERFACE_IFINDEX, snmpinterface.getIfIndex().toString()); if (snmpinterface.getIfName() != null) bldr.addParam(EventConstants.PARM_SNMP_INTERFACE_NAME, snmpinterface.getIfName()); if (snmpinterface.getIfDescr() != null) bldr.addParam(EventConstants.PARM_SNMP_INTERFACE_DESC, snmpinterface.getIfDescr()); if (snmpinterface.getIfAlias() != null) bldr.addParam(EventConstants.PARM_SNMP_INTERFACE_ALIAS, snmpinterface.getIfAlias()); return bldr.getEvent(); }
.setId(snmpInterface.getId()) .setIfIndex(snmpInterface.getIfIndex()); if (snmpInterface.getIfDescr() != null) { builder.setIfDescr(snmpInterface.getIfDescr());
if (!nullSafeEquals(snmpIface.getIfDescr(), importedSnmpIface.getIfDescr())) { snmpIface.setIfDescr(importedSnmpIface.getIfDescr());
.setId(snmpInterface.getId()) .setIfIndex(snmpInterface.getIfIndex()); if (snmpInterface.getIfDescr() != null) { builder.setIfDescr(snmpInterface.getIfDescr());
if (hasNewValue(scannedSnmpIface.getIfDescr(), getIfDescr())) { setIfDescr(scannedSnmpIface.getIfDescr());