Uploaded image for project: 'OpenNMS'
  1. OpenNMS
  2. NMS-4499

NSClient data collection only reads the first <nsclient-collection> tag

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.10
    • Fix Version/s: 1.8.11, 1.9.7
    • Security Level: Default (Default Security Scheme)
    • Labels:
      None
    • Environment:
      Windows, but should also apply with Linux

      Description

      There's a bug in the search for the NSClientCollection that matches the desired name.
      The current code does the following:

      public NsclientCollection getNSClientCollection(String collectionName) {
      NsclientCollection[] collections = m_config.getNsclientCollection();
      NsclientCollection collection = null;
      for (NsclientCollection coll : collections)

      { if (coll.getName().equalsIgnoreCase(collectionName)) collection = coll; break; }

      if (collection == null)

      { throw new IllegalArgumentException("getNSClientCollection: collection name: " +collectionName+" specified in collectd configuration not found in nsclient collection configuration."); }

      return collection;
      }

      What happens is that the break always executes after the first item in the collection array. Thus if the first item wasn't the one you were looking for, the method would fail indicating the item isn't in the collection array, even if it was one of the later items in the array.
      The following is a pretty obvious and trivial fix that should hopefully get approved quickly:

      public NsclientCollection getNSClientCollection(String collectionName) {
      NsclientCollection[] collections = m_config.getNsclientCollection();
      NsclientCollection collection = null;
      for (NsclientCollection coll : collections) {
      if (coll.getName().equalsIgnoreCase(collectionName))

      { collection = coll; break; }

      }
      if (collection == null)

      { throw new IllegalArgumentException("getNSClientCollection: collection name: " +collectionName+" specified in collectd configuration not found in nsclient collection configuration."); }

      return collection;
      }

        Attachments

          Activity

            People

            • Assignee:
              ranger Benjamin Reed
              Reporter:
              papanon@sierrasystems.com Paul-Andre Panon
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1 hour
                1h
                Remaining:
                Remaining Estimate - 1 hour
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified