Ejemplo n.º 1
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");
        }
      }
    }
Ejemplo n.º 2
0
  protected void runCollection() {

    final Date now = new Date();

    LOG.debug("run: collecting : {}", getPeer());

    IpNetToMediaTableTracker ipNetToMediaTableTracker =
        new IpNetToMediaTableTracker() {
          public void processIpNetToMediaRow(final IpNetToMediaRow row) {
            IpNetToMedia macep = row.getIpNetToMedia();
            if (macep.getIpNetToMediaType() == IpNetToMediaType.IPNETTOMEDIA_TYPE_DYNAMIC
                || macep.getIpNetToMediaType() == IpNetToMediaType.IPNETTOMEDIA_TYPE_STATIC)
              m_linkd.getQueryManager().store(getNodeId(), macep);
          }
        };

    String trackerName = "ipNetToMedia";
    SnmpWalker walker = SnmpUtils.createWalker(getPeer(), trackerName, ipNetToMediaTableTracker);
    walker.start();

    try {
      walker.waitFor();
      if (walker.timedOut()) {
        LOG.info(
            "run:Aborting IpNetToMedia Linkd node scan : Agent timed out while scanning the {} table",
            trackerName);
        return;
      } else if (walker.failed()) {
        LOG.info(
            "run:Aborting IpNetToMedia Linkd node scan : Agent failed while scanning the {} table: {}",
            trackerName,
            walker.getErrorMessage());
        return;
      }
    } catch (final InterruptedException e) {
      LOG.error("run: collection interrupted, exiting", e);
      return;
    }

    m_linkd.getQueryManager().reconcileIpNetToMedia(getNodeId(), now);
  }
Ejemplo n.º 3
0
  protected void runCollection() {

    final Date now = new Date();

    String trackerName = "isisSysObjectCollection";
    final IsisSysObjectGroupTracker isisSysObject = new IsisSysObjectGroupTracker();
    LOG.info("run: collecting {} on: {}", trackerName, str(getTarget()));
    SnmpWalker walker = SnmpUtils.createWalker(getPeer(), trackerName, isisSysObject);

    walker.start();

    try {
      walker.waitFor();
      if (walker.timedOut()) {
        LOG.info(
            "run:Aborting Is-Is Linkd node scan : Agent timed out while scanning the {} table",
            trackerName);
        return;
      } else if (walker.failed()) {
        LOG.info(
            "run:Aborting Is-Is Linkd node scan : Agent failed while scanning the {} table: {}",
            trackerName,
            walker.getErrorMessage());
        return;
      }
    } catch (final InterruptedException e) {
      LOG.error("run: Is-Is Linkd node collection interrupted, exiting", e);
      return;
    }

    if (isisSysObject.getIsisSysId() == null) {
      LOG.info("Is-Is mib not supported on: {}", str(getPeer().getAddress()));
      return;
    }

    m_linkd.getQueryManager().store(getNodeId(), isisSysObject.getIsisElement());

    final List<IsIsLink> links = new ArrayList<IsIsLink>();
    trackerName = "isisISAdjTable";
    final IsisISAdjTableTracker isisISAdjTableTracker =
        new IsisISAdjTableTracker() {
          @Override
          public void processIsisAdjRow(IsIsAdjRow row) {
            links.add(row.getIsisLink());
          }
        };
    LOG.info("run: collecting {} on: {}", trackerName, str(getTarget()));
    walker = SnmpUtils.createWalker(getPeer(), trackerName, isisISAdjTableTracker);

    walker.start();

    try {
      walker.waitFor();
      if (walker.timedOut()) {
        LOG.info(
            "run:Aborting Is-Is Linkd node scan : Agent timed out while scanning the {} table",
            trackerName);
        return;
      } else if (walker.failed()) {
        LOG.info(
            "run:Aborting Is-Is Linkd node scan : Agent failed while scanning the {} table: {}",
            trackerName,
            walker.getErrorMessage());
        return;
      }
    } catch (final InterruptedException e) {
      LOG.error("run: Is-Is Linkd node collection interrupted, exiting", e);
      return;
    }

    trackerName = "isisCircTable";
    final IsisCircTableTracker isisCircTableTracker =
        new IsisCircTableTracker() {
          @Override
          public void processIsisCircRow(IsIsCircRow row) {
            IsIsLink link = row.getIsisLink();
            for (IsIsLink adjlink : links) {
              if (link.getIsisCircIndex().intValue() == adjlink.getIsisCircIndex().intValue()) {
                adjlink.setIsisCircIfIndex(link.getIsisCircIfIndex());
                adjlink.setIsisCircAdminState(link.getIsisCircAdminState());
              }
            }
          }
        };

    LOG.info("run: collecting {} on: {}", trackerName, str(getTarget()));
    walker = SnmpUtils.createWalker(getPeer(), trackerName, isisCircTableTracker);

    walker.start();

    try {
      walker.waitFor();
      if (walker.timedOut()) {
        LOG.info(
            "run:Aborting Is-Is Linkd node scan : Agent timed out while scanning the {} table",
            trackerName);
        return;
      } else if (walker.failed()) {
        LOG.info(
            "run:Aborting Is-Is Linkd node scan : Agent failed while scanning the {} table: {}",
            trackerName,
            walker.getErrorMessage());
        return;
      }
    } catch (final InterruptedException e) {
      LOG.error("run: Is-Is Linkd node collection interrupted, exiting", e);
      return;
    }

    for (IsIsLink link : links) m_linkd.getQueryManager().store(getNodeId(), link);

    m_linkd.getQueryManager().reconcileIsis(getNodeId(), now);
  }
Ejemplo n.º 4
0
    public void detectPhysicalInterfaces(final BatchTask currentPhase) {
      if (isAborted()) {
        return;
      }
      final SnmpAgentConfig agentConfig = getAgentConfigFactory().getAgentConfig(getAgentAddress());
      Assert.notNull(getAgentConfigFactory(), "agentConfigFactory was not injected");

      final PhysInterfaceTableTracker physIfTracker =
          new PhysInterfaceTableTracker() {
            @Override
            public void processPhysicalInterfaceRow(PhysicalInterfaceRow row) {
              LOG.info(
                  "Processing ifTable row for ifIndex {} on node {}/{}/{}",
                  row.getIfIndex(),
                  getNodeId(),
                  getForeignSource(),
                  getForeignId());
              OnmsSnmpInterface snmpIface = row.createInterfaceFromRow();
              snmpIface.setLastCapsdPoll(getScanStamp());

              final List<SnmpInterfacePolicy> policies =
                  getProvisionService()
                      .getSnmpInterfacePoliciesForForeignSource(
                          getForeignSource() == null ? "default" : getForeignSource());
              for (final SnmpInterfacePolicy policy : policies) {
                if (snmpIface != null) {
                  snmpIface = policy.apply(snmpIface);
                }
              }

              if (snmpIface != null) {
                final OnmsSnmpInterface snmpIfaceResult = snmpIface;

                // add call to the SNMP interface collection enable policies

                final Runnable r =
                    new Runnable() {
                      @Override
                      public void run() {
                        getProvisionService()
                            .updateSnmpInterfaceAttributes(getNodeId(), snmpIfaceResult);
                      }
                    };
                currentPhase.add(r, "write");
              }
            }
          };

      final SnmpWalker walker =
          SnmpUtils.createWalker(agentConfig, "ifTable/ifXTable", physIfTracker);
      walker.start();

      try {
        walker.waitFor();

        if (walker.timedOut()) {
          abort("Aborting node scan : Agent timed out while scanning the interfaces table");
        } else if (walker.failed()) {
          abort(
              "Aborting node scan : Agent failed while scanning the interfaces table: "
                  + walker.getErrorMessage());
        } else {
          LOG.debug("Finished phase {}", currentPhase);
        }
      } catch (final InterruptedException e) {
        abort("Aborting node scan : Scan thread interrupted while waiting for interfaces table");
        Thread.currentThread().interrupt();
      }
    }