Ejemplo n.º 1
0
  @Override
  public void discoverPost(
      String hostname,
      JrdsElement hostEleme,
      Map<String, JrdsDocument> probdescs,
      HttpServletRequest request) {

    boolean withOid = false;
    String withOidStr = request.getParameter("discoverWithOid");
    if (withOidStr != null && "true".equals(withOidStr.toLowerCase())) withOid = true;

    Set<String> done = new HashSet<String>();

    log(Level.DEBUG, "Will search for probes %s", sortedProbeName);
    for (String name : sortedProbeName) {
      ProbeDescSummary summary = summaries.get(name);
      if (summary == null) {
        log(Level.ERROR, "ProbeDesc not valid for %s, skip it", name);
        done.add(name);
        continue;
      }
      if (done.contains(name)) {
        log(Level.TRACE, "ProbeDesc %s already done, it must be hidden", name);
        continue;
      }
      log(Level.TRACE, "Trying to discover probe %s", name);

      try {
        boolean found = false;
        if (summary.isIndexed) {
          found = (enumerateIndexed(hostEleme, summary, withOid) > 0);
        } else {
          found = doesExist(hostEleme, summary);
        }
        if (found) {
          log(Level.DEBUG, "%s found", name);
          done.add(name);
          // Add all the hidden probes desc to the already done one
          String hidesStr = summary.specifics.get("hides");
          if (hidesStr != null && !hidesStr.isEmpty()) {
            for (String hides : hidesStr.split(",")) {
              log(Level.DEBUG, "%s hides %s", name, hides.trim());
              done.add(hides.trim());
            }
          }
        }
      } catch (Exception e1) {
        log(Level.ERROR, e1, "Error detecting %s: %s", name, e1);
      }
    }
    active.doStop();
  }