예제 #1
0
  /** {@inheritDoc} */
  @Override
  public void run(final BatchTask parent) {
    LOG.info("Scanning node {}/{}/{}", m_nodeId, m_foreignSource, m_foreignId);

    parent
        .getBuilder()
        .addSequence(
            new RunInBatch() {
              @Override
              public void run(final BatchTask phase) {
                loadNode(phase);
              }
            },
            new RunInBatch() {
              @Override
              public void run(final BatchTask phase) {
                detectAgents(phase);
              }
            },
            new RunInBatch() {
              @Override
              public void run(final BatchTask phase) {
                handleAgentUndetected(phase);
              }
            },
            new RunInBatch() {
              @Override
              public void run(final BatchTask phase) {
                scanCompleted(phase);
              }
            });
  }
예제 #2
0
 void updateIpInterface(final BatchTask currentPhase, final OnmsIpInterface iface) {
   getProvisionService().updateIpInterfaceAttributes(getNodeId(), iface);
   if (iface.isManaged()) {
     currentPhase.add(
         new IpInterfaceScan(
             getNodeId(), iface.getIpAddress(), getForeignSource(), getProvisionService()));
   }
 }
예제 #3
0
    void stampProvisionedInterfaces(final BatchTask phase) {
      if (!isAborted()) {

        for (final OnmsIpInterface iface : getNode().getIpInterfaces()) {
          iface.setIpLastCapsdPoll(getScanStamp());
          phase.add(ipUpdater(phase, iface), "write");
        }
      }
    }
예제 #4
0
    private void walkTable(
        final BatchTask currentPhase,
        final Set<InetAddress> provisionedIps,
        final TableTracker tracker) {
      final OnmsNode node = getNode();
      LOG.info(
          "detecting IP interfaces for node {}/{}/{} using table tracker {}",
          node.getId(),
          node.getForeignSource(),
          node.getForeignId(),
          tracker);

      if (isAborted()) {
        LOG.debug("'{}' is marked as aborted; skipping scan of table {}", currentPhase, tracker);
      } else {
        Assert.notNull(getAgentConfigFactory(), "agentConfigFactory was not injected");

        final SnmpAgentConfig agentConfig =
            getAgentConfigFactory().getAgentConfig(getAgentAddress());

        final SnmpWalker walker = SnmpUtils.createWalker(agentConfig, "IP address tables", tracker);
        walker.start();

        try {
          walker.waitFor();

          if (walker.timedOut()) {
            abort("Aborting node scan : Agent timed out while scanning the IP address tables");
          } else if (walker.failed()) {
            abort(
                "Aborting node scan : Agent failed while scanning the IP address tables : "
                    + walker.getErrorMessage());
          } else {

            // After processing the SNMP provided interfaces then we need to scan any that
            // were provisioned but missing from the ip table
            for (final InetAddress ipAddr : provisionedIps) {
              final OnmsIpInterface iface = node.getIpInterfaceByIpAddress(ipAddr);

              if (iface != null) {
                iface.setIpLastCapsdPoll(getScanStamp());
                iface.setIsManaged("M");

                currentPhase.add(ipUpdater(currentPhase, iface), "write");
              }
            }

            LOG.debug("Finished phase {}", currentPhase);
          }
        } catch (final InterruptedException e) {
          abort("Aborting node scan : Scan thread failed while waiting for the IP address tables");
        }
      }
    }
예제 #5
0
 /**
  * loadNode
  *
  * @param loadNode a {@link org.opennms.core.tasks.BatchTask} object.
  */
 public void loadNode(final BatchTask loadNode) {
   if (getForeignSource() != null) {
     m_node = m_provisionService.getRequisitionedNode(getForeignSource(), getForeignId());
     if (m_node == null) {
       abort(
           String.format(
               "Unable to get requisitioned node (%s/%s): aborted", m_foreignSource, m_foreignId));
     } else {
       for (final OnmsIpInterface iface : m_node.getIpInterfaces()) {
         loadNode.add(
             new IpInterfaceScan(
                 getNodeId(), iface.getIpAddress(), getForeignSource(), getProvisionService()));
       }
     }
   } else {
     m_node = m_provisionService.getNode(m_nodeId);
   }
 }
예제 #6
0
  /**
   * handleAgentUndetected
   *
   * @param currentPhase a {@link org.opennms.core.tasks.BatchTask} object.
   */
  public void handleAgentUndetected(final BatchTask currentPhase) {

    if (!isAgentFound()) {
      currentPhase.add(createNoAgentScan());
    }
  }