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

HttpCollector fails to parse numeric values in locales that use different decimal notation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reopened (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.10.3
    • Fix Version/s: Backlog
    • Component/s: Data Collection - HTTP
    • Security Level: Default (Default Security Scheme)
    • Labels:
      None
    • Environment:

      Description

      While trying to collect datas from apache's mod_status I got an error because it starts with a dot instead of 0.something.
      ERROR [CollectdScheduler-50 Pool-fiber25] HttpCollector: attribute apacheReqPerSec failed to match a parsable number! Matched ".123988" instead.
      After trying numerous regex and figuring out I could not split these values into 2 columns then use CDEF on graph.properties since the returned decimal is not always with the same lenght.
      Here is the patch I produced, compiled, unit test passed.
      Patch:
      diff --git a/opennms-services/src/main/java/org/opennms/netmgt/collectd/HttpCollector.java b/opennms-services/src/main/java/org/opennms/netmgt/collectd/HttpCollector.java
      index af5d606..aec4f76 100644
      — a/opennms-services/src/main/java/org/opennms/netmgt/collectd/HttpCollector.java
      +++ b/opennms-services/src/main/java/org/opennms/netmgt/collectd/HttpCollector.java
      @@ -465,7 +465,10 @@ public class HttpCollector implements ServiceCollector {
      for (Attrib attribDef : attribDefs) {
      if (! attribDef.getType().matches("^([Oo](ctet|CTET)[Ss](tring|TRING))|([Ss](tring|TRING))$")) {
      try {

      • Number num = NumberFormat.getNumberInstance().parse(m.group(attribDef.getMatchGroup()));
        + String numstr = new String(m.group(attribDef.getMatchGroup()));
        + if (numstr.startsWith("."))
        + numstr = "0".concat(numstr);
        + Number num = NumberFormat.getNumberInstance().parse(numstr);
        HttpCollectionAttribute bute =
        new HttpCollectionAttribute(
        collectionResource,

      -------------------------------------------------------
      T E S T S
      -------------------------------------------------------
      Running org.opennms.netmgt.collectd.HttpCollectorTest
      [...]
      Tests run: 6, Failures: 0, Errors: 0, Skipped: 0

      Now the problem is the collected data is without the decimal and as I said i can not split it into 2 columns since it's a variable number of decimals that are returned by mod_status
      2012-07-09 18:39:23,451 DEBUG [CollectdScheduler-50 Pool-fiber37] HttpCollector: responseBody = Total Accesses: 2628627
      Total kBytes: 56919252
      CPULoad: .210944
      Uptime: 2187657
      ReqPerSec: 1.20157
      BytesPerSec: 26642.8
      BytesPerReq: 22173.3
      BusyWorkers: 2
      IdleWorkers: 8
      Scoreboard: .___.W.K_...................................................................................................................................................................................................................................................
      2012-07-09 18:39:23,451 DEBUG [CollectdScheduler-50 Pool-fiber37] HttpCollector: getmatches = (?s).?Total\sAccesses:\s([0-9]).?Total\skBytes:\s([0-9]).?CPULoad:\s([0-9\.]).?Uptime:\s([0-9]).?ReqPerSec:\s([0-9\.]).?BytesPerSec:\s([0-9\.]).?BytesPerReq:\s([0-9\.]).?BusyWorkers:\s([0-9]).?IdleWorkers:\s([0-9]).*
      2012-07-09 18:39:23,454 DEBUG [CollectdScheduler-50 Pool-fiber37] HttpCollector: processResponse: found matching attributes: true
      2012-07-09 18:39:23,463 DEBUG [CollectdScheduler-50 Pool-fiber37] HttpCollector: processResponse: adding found numeric attribute: HttpAttribute: apacheTotalAccesses:gauge32:2628627
      2012-07-09 18:39:23,464 DEBUG [CollectdScheduler-50 Pool-fiber37] HttpCollector: processResponse: adding found numeric attribute: HttpAttribute: apacheTotalkBytes:gauge32:56919252
      2012-07-09 18:39:23,464 DEBUG [CollectdScheduler-50 Pool-fiber37] HttpCollector: processResponse: adding found numeric attribute: HttpAttribute: apacheCPULoad:gauge32:0
      2012-07-09 18:39:23,464 DEBUG [CollectdScheduler-50 Pool-fiber37] HttpCollector: processResponse: adding found numeric attribute: HttpAttribute: apacheUptime:gauge32:2187657
      2012-07-09 18:39:23,465 DEBUG [CollectdScheduler-50 Pool-fiber37] HttpCollector: processResponse: adding found numeric attribute: HttpAttribute: apacheReqPerSec:gauge32:1
      2012-07-09 18:39:23,465 DEBUG [CollectdScheduler-50 Pool-fiber37] HttpCollector: processResponse: adding found numeric attribute: HttpAttribute: apacheBytesPerSec:gauge32:26642
      2012-07-09 18:39:23,465 DEBUG [CollectdScheduler-50 Pool-fiber37] HttpCollector: processResponse: adding found numeric attribute: HttpAttribute: apacheBytesPerReq:gauge32:22173
      2012-07-09 18:39:23,465 DEBUG [CollectdScheduler-50 Pool-fiber37] HttpCollector: processResponse: adding found numeric attribute: HttpAttribute: apacheBusyWorkers:gauge32:2
      2012-07-09 18:39:23,465 DEBUG [CollectdScheduler-50 Pool-fiber37] HttpCollector: processResponse: adding found numeric attribute: HttpAttribute: apacheIdleWorkers:gauge32:8

        Attachments

          Activity

            People

            • Assignee:
              ranger Benjamin Reed
              Reporter:
              dinde David
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: