Example #1
0
  /**
   * This method schedules a {@link SnmpCollection} for node for each package. Also schedule
   * discovery link on package when not still activated.
   *
   * @param node
   */
  private void scheduleCollectionForNode(final LinkableNode node) {

    for (final SnmpCollection snmpcoll :
        getSnmpCollections(node.getNodeId(), node.getSnmpPrimaryIpAddr(), node.getSysoid())) {
      if (m_activepackages.contains(snmpcoll.getPackageName())) {
        LogUtils.debugf(
            this, "ScheduleCollectionForNode: package active: %s", snmpcoll.getPackageName());
      } else {
        // schedule discovery link
        LogUtils.debugf(
            this,
            "ScheduleCollectionForNode: Scheduling Discovery Link for Active Package: %s",
            snmpcoll.getPackageName());
        final DiscoveryLink discovery = this.getDiscoveryLink(snmpcoll.getPackageName());
        if (discovery.getScheduler() == null) {
          discovery.setScheduler(m_scheduler);
        }
        discovery.schedule();
        m_activepackages.add(snmpcoll.getPackageName());
      }
      if (snmpcoll.getScheduler() == null) {
        snmpcoll.setScheduler(m_scheduler);
      }
      LogUtils.debugf(
          this,
          "ScheduleCollectionForNode: Scheduling SNMP Collection for Package/NodeId: %s/%d/%s",
          snmpcoll.getPackageName(),
          node.getNodeId(),
          snmpcoll.getInfo());
      snmpcoll.schedule();
    }
  }
Example #2
0
  /**
   * Method that uses info in hash snmpprimaryip2nodes and also save info into database. This method
   * is called by DiscoveryLink after all stuff is done
   *
   * @param discover
   */
  void updateDiscoveryLinkCollection(final DiscoveryLink discover) {

    try {
      m_queryMgr.storeDiscoveryLink(discover);
    } catch (SQLException e) {
      LogUtils.errorf(
          this,
          e,
          "Failed to save discoverylink on database for package: %s",
          discover.getPackageName());
    }
  }
Example #3
0
  public boolean runSingleCollection(final int nodeId) {
    try {
      final LinkableNode node = m_queryMgr.getSnmpNode(nodeId);

      for (final SnmpCollection snmpColl :
          getSnmpCollections(nodeId, node.getSnmpPrimaryIpAddr(), node.getSysoid())) {
        snmpColl.setScheduler(m_scheduler);
        snmpColl.run();

        final DiscoveryLink link = getDiscoveryLink(snmpColl.getPackageName());
        link.setScheduler(m_scheduler);
        link.run();
      }

      return true;
    } catch (final SQLException e) {
      LogUtils.debugf(
          this,
          "runSingleCollection: unable to get linkable node from database with ID %d",
          nodeId);
    }
    return false;
  }
Example #4
0
  /** {@inheritDoc} */
  public DiscoveryLink getDiscoveryLink(final String pkgName) {
    final Package pkg = m_linkdConfig.getPackage(pkgName);

    if (pkg == null) return null;

    final DiscoveryLink discoveryLink = new DiscoveryLink();
    discoveryLink.setLinkd(this);
    discoveryLink.setPackageName(pkg.getName());
    discoveryLink.setInitialSleepTime(m_linkdConfig.getInitialSleepTime());

    discoveryLink.setSnmpPollInterval(
        pkg.hasSnmp_poll_interval()
            ? pkg.getSnmp_poll_interval()
            : m_linkdConfig.getSnmpPollInterval());
    discoveryLink.setDiscoveryInterval(
        pkg.hasDiscovery_link_interval()
            ? pkg.getDiscovery_link_interval()
            : m_linkdConfig.getDiscoveryLinkInterval());
    discoveryLink.setDiscoveryUsingBridge(
        pkg.hasUseBridgeDiscovery()
            ? pkg.getUseBridgeDiscovery()
            : m_linkdConfig.useBridgeDiscovery());
    discoveryLink.setDiscoveryUsingCdp(
        pkg.hasUseCdpDiscovery() ? pkg.getUseCdpDiscovery() : m_linkdConfig.useCdpDiscovery());
    discoveryLink.setDiscoveryUsingRoutes(
        pkg.hasUseIpRouteDiscovery()
            ? pkg.getUseIpRouteDiscovery()
            : m_linkdConfig.useIpRouteDiscovery());
    discoveryLink.setEnableDownloadDiscovery(
        pkg.hasEnableDiscoveryDownload()
            ? pkg.getEnableDiscoveryDownload()
            : m_linkdConfig.enableDiscoveryDownload());
    discoveryLink.setForceIpRouteDiscoveryOnEtherNet(
        pkg.hasForceIpRouteDiscoveryOnEthernet()
            ? pkg.getForceIpRouteDiscoveryOnEthernet()
            : m_linkdConfig.forceIpRouteDiscoveryOnEthernet());

    return discoveryLink;
  }