Esempio n. 1
0
 /** Whether autodiscovery is enabled in linkd-config (default: false) */
 @Override
 public boolean isAutoDiscoveryEnabled() {
   try {
     getReadLock().lock();
     if (m_config.hasAutoDiscovery()) return m_config.getAutoDiscovery();
   } finally {
     getReadLock().unlock();
   }
   return false;
 }
Esempio n. 2
0
 /** Whether vlan discovery is enabled in linkd-config (default: true) */
 @Override
 public boolean isVlanDiscoveryEnabled() {
   try {
     getReadLock().lock();
     if (m_config.hasEnableVlanDiscovery()) return m_config.getEnableVlanDiscovery();
   } finally {
     getReadLock().unlock();
   }
   return true;
 }
Esempio n. 3
0
  protected void updateIpRouteClassNames() {
    m_oidMask2IpRouteclassName.clear();
    try {
      getWriteLock().lock();
      final Iproutes iproutes = m_config.getIproutes();
      if (iproutes == null) {
        LOG.info("no iproutes found in config");
        return;
      }

      for (final Vendor vendor : iproutes.getVendorCollection()) {
        final SnmpObjectId curRootSysOid = new SnmpObjectId(vendor.getSysoidRootMask());
        final String curClassName = vendor.getClassName();

        for (final String specific : vendor.getSpecific()) {
          final SnmpObjectId oidMask = new SnmpObjectId(specific);
          oidMask.prepend(curRootSysOid);
          m_oidMask2IpRouteclassName.put(oidMask.toString(), curClassName);
          LOG.debug(
              "initializeIpRouteClassNames:  adding class {} for oid {}", curClassName, oidMask);
        }
      }
    } finally {
      getWriteLock().unlock();
    }
  }
Esempio n. 4
0
  /**
   * This method is used to establish package against IP list mapping, with which, the IP list is
   * selected per package via the configured filter rules from the database.
   */
  protected void updatePackageIpListMap() {
    m_pkgIpMap.clear();
    try {
      getWriteLock().lock();
      for (final org.opennms.netmgt.config.linkd.Package pkg : m_config.getPackageCollection()) {
        //
        // Get a list of IP addresses per package against the filter rules from
        // database and populate the package, IP list map.
        //
        try {
          final List<InetAddress> ipList = getIpList(pkg);
          LOG.trace(
              "createPackageIpMap: package {}: ipList size = {}", pkg.getName(), ipList.size());

          if (ipList != null && ipList.size() > 0) {
            m_pkgIpMap.put(pkg, ipList);
          }
        } catch (final Throwable t) {
          LOG.error(
              "createPackageIpMap: failed to map package: {} to an IP list", pkg.getName(), t);
        }
      }
    } finally {
      getWriteLock().unlock();
    }
  }
Esempio n. 5
0
 protected void updateUrlIpMap() {
   m_urlIPMap.clear();
   for (final org.opennms.netmgt.config.linkd.Package pkg : m_config.getPackageCollection()) {
     if (pkg == null) continue;
     for (final String urlname : pkg.getIncludeUrlCollection()) {
       final java.util.List<String> iplist = IpListFromUrl.fetch(urlname);
       if (iplist.size() > 0) {
         m_urlIPMap.put(urlname, iplist);
       }
     }
   }
 }
Esempio n. 6
0
 /**
  * {@inheritDoc}
  *
  * <p>Returns the first package that the IP belongs to, null if none.
  *
  * <p><strong>Note: </strong>Evaluation of the interface against a package filter will only work
  * if the IP is already in the database.
  */
 @Override
 public org.opennms.netmgt.config.linkd.Package getFirstPackageMatch(final InetAddress ipaddr) {
   try {
     getReadLock().lock();
     for (final org.opennms.netmgt.config.linkd.Package pkg : m_config.getPackageCollection()) {
       if (isInterfaceInPackage(ipaddr, pkg)) {
         return pkg;
       }
     }
   } finally {
     getReadLock().unlock();
   }
   return null;
 }
Esempio n. 7
0
 /** {@inheritDoc} */
 @Override
 public org.opennms.netmgt.config.linkd.Package getPackage(final String name) {
   try {
     getReadLock().lock();
     for (final org.opennms.netmgt.config.linkd.Package thisPackage :
         m_config.getPackageCollection()) {
       final String n = thisPackage.getName();
       if (n != null && n.equals(name)) {
         return thisPackage;
       }
     }
   } finally {
     getReadLock().unlock();
   }
   return null;
 }
Esempio n. 8
0
  /**
   * {@inheritDoc}
   *
   * <p>Returns a list of package names that the IP belongs to, null if none.
   *
   * <p><strong>Note: </strong>Evaluation of the interface against a package filter will only work
   * if the IP is already in the database.
   */
  @Override
  public List<String> getAllPackageMatches(final InetAddress ipaddr) {
    final List<String> matchingPkgs = new ArrayList<String>();

    try {
      getReadLock().lock();
      for (final org.opennms.netmgt.config.linkd.Package pkg : m_config.getPackageCollection()) {
        final String pkgName = pkg.getName();
        if (isInterfaceInPackage(ipaddr, pkg)) {
          matchingPkgs.add(pkgName);
        }
      }
    } finally {
      getReadLock().unlock();
    }
    return matchingPkgs;
  }
Esempio n. 9
0
 /**
  * getThreads
  *
  * @return a int.
  */
 @Override
 public int getThreads() {
   if (m_config.hasThreads()) return m_config.getThreads();
   return 5;
 }
Esempio n. 10
0
 @Override
 public long getDiscoveryLinkInterval() {
   if (m_config.hasSnmp_poll_interval()) return m_config.getDiscovery_link_interval();
   return 3600000;
 }
Esempio n. 11
0
 @Override
 public long getSnmpPollInterval() {
   if (m_config.hasSnmp_poll_interval()) return m_config.getSnmp_poll_interval();
   return 900000;
 }
Esempio n. 12
0
 /**
  * saveStpInterfaceTable
  *
  * @return a boolean.
  */
 @Override
 public boolean saveStpInterfaceTable() {
   if (m_config.hasSaveStpInterfaceTable()) return m_config.getSaveStpInterfaceTable();
   return true;
 }
Esempio n. 13
0
 /**
  * useWifiDiscovery
  *
  * @return a boolean.
  */
 @Override
 public boolean useWifiDiscovery() {
   if (m_config.hasUseWifiDiscovery()) return m_config.getUseWifiDiscovery();
   return true;
 }
Esempio n. 14
0
 /**
  * saveRouteTable
  *
  * @return a boolean.
  */
 @Override
 public boolean saveRouteTable() {
   if (m_config.hasSaveRouteTable()) return m_config.getSaveRouteTable();
   return true;
 }
Esempio n. 15
0
  protected void updateVlanClassNames() {
    m_oidMask2VlanclassName.clear();
    try {
      getWriteLock().lock();
      final Vlans vlans = m_config.getVlans();
      if (vlans == null) {
        LOG.info("initializeVlanClassNames: no vlans found in config");
      }

      final List<String> excludedOids = new ArrayList<String>();
      for (final Vendor vendor : vlans.getVendorCollection()) {
        final SnmpObjectId curRootSysOid = new SnmpObjectId(vendor.getSysoidRootMask());
        final String curClassName = vendor.getClassName();

        for (final String specific : vendor.getSpecific()) {
          final SnmpObjectId oidMask = new SnmpObjectId(specific);
          oidMask.prepend(curRootSysOid);
          m_oidMask2VlanclassName.put(oidMask.toString(), curClassName);
          LOG.debug("initializeVlanClassNames:  adding class {} for oid {}", curClassName, oidMask);
        }

        for (final ExcludeRange excludeRange : vendor.getExcludeRangeCollection()) {
          final SnmpObjectId snmpBeginOid = new SnmpObjectId(excludeRange.getBegin());
          final SnmpObjectId snmpEndOid = new SnmpObjectId(excludeRange.getEnd());
          final SnmpObjectId snmpRootOid = getRootOid(snmpBeginOid);
          if (snmpBeginOid.getLength() == snmpEndOid.getLength()
              && snmpRootOid.isRootOf(snmpEndOid)) {
            final SnmpObjectId snmpCurOid = new SnmpObjectId(snmpBeginOid);
            while (snmpCurOid.compare(snmpEndOid) <= 0) {
              excludedOids.add(snmpCurOid.toString());
              LOG.debug(
                  "initializeVlanClassNames:  signing excluded class {} for oid {}",
                  curClassName,
                  curRootSysOid.toString().concat(snmpCurOid.toString()));
              int lastCurCipher = snmpCurOid.getLastIdentifier();
              lastCurCipher++;
              int[] identifiers = snmpCurOid.getIdentifiers();
              identifiers[identifiers.length - 1] = lastCurCipher;
              snmpCurOid.setIdentifiers(identifiers);
            }
          }
        }

        for (final IncludeRange includeRange : vendor.getIncludeRangeCollection()) {
          final SnmpObjectId snmpBeginOid = new SnmpObjectId(includeRange.getBegin());
          final SnmpObjectId snmpEndOid = new SnmpObjectId(includeRange.getEnd());
          final SnmpObjectId rootOid = getRootOid(snmpBeginOid);
          if (snmpBeginOid.getLength() == snmpEndOid.getLength() && rootOid.isRootOf(snmpEndOid)) {
            final SnmpObjectId snmpCurOid = new SnmpObjectId(snmpBeginOid);
            while (snmpCurOid.compare(snmpEndOid) <= 0) {
              if (!excludedOids.contains(snmpBeginOid.toString())) {
                final SnmpObjectId oidMask = new SnmpObjectId(snmpBeginOid);
                oidMask.prepend(curRootSysOid);
                m_oidMask2VlanclassName.put(oidMask.toString(), curClassName);
                LOG.debug(
                    "initializeVlanClassNames:  adding class {} for oid {}", curClassName, oidMask);
              }
              int lastCipher = snmpBeginOid.getLastIdentifier();
              lastCipher++;
              int[] identifiers = snmpBeginOid.getIdentifiers();
              identifiers[identifiers.length - 1] = lastCipher;
              snmpCurOid.setIdentifiers(identifiers);
            }
          }
        }
      }
    } finally {
      getWriteLock().unlock();
    }
  }
Esempio n. 16
0
 @Override
 public boolean forceIpRouteDiscoveryOnEthernet() {
   if (m_config.hasForceIpRouteDiscoveryOnEthernet())
     return m_config.getForceIpRouteDiscoveryOnEthernet();
   return false;
 }
Esempio n. 17
0
 @Override
 public long getInitialSleepTime() {
   if (m_config.hasInitial_sleep_time()) return m_config.getInitial_sleep_time();
   return 1800000;
 }