更新:日志报告:

no attributes defined by the response: <a class="navbar-brand" href="http://foo.com/foo1">

        CSG - Client:DRS - Site:foo1 Gdns - August 13 2015 06:28 AM
        <i style="display:none">opennms9929opennms</i>
    </a>

我在xml中的regex似乎不正确。有人能为我的问题提供正确的正则表达式吗?谢谢。
我一直在尝试使用opennms设置一个http收集器来定期从一个网站收集一个数字,原始的html代码如下:
<!DOCTYPE HTML>
............
<i style="display:none" >opennms781opennms</i>
............
</body>
</html>

目标是使用regex收集介于opennms(number)opennms之间的数字。
我已经按照OpenNMS HTTP Collector Wiki中的说明编辑了所需的xml文件,opennms能够提取原始html数据并将其记录在日志中,但是我仍然收到以下警告/错误:
2015-08-13 14:18:39,946 WARN  [Collectd-Thread-49-of-50] o.o.n.c.HttpCollector: doCollection: More than 1 Content-Language headers received. Ignoring them!
2015-08-13 14:18:39,946 WARN  [Collectd-Thread-49-of-50] o.o.n.c.HttpCollector: doCollection: no attributes defined by the response: <a class="navbar-brand" href="http://foo.com/foo1">

    CSG - Client:DRS - Site:foo1 Gdns - August 13 2015 06:28 AM
    <i style="display:none">opennms9929opennms</i>
</a>
2015-08-12 12:08:14,771 WARN  [Collectd-Thread-10-of-50] o.o.n.c.HttpCollector: collect: http collection failed
org.opennms.netmgt.collectd.HttpCollector$HttpCollectorException: Unexpected exception caught during HTTP collection
    at org.opennms.netmgt.collectd.HttpCollector.doCollection(HttpCollector.java:307) ~[opennms-services-16.0.2.jar:?]
    at org.opennms.netmgt.collectd.HttpCollector.access$100(HttpCollector.java:107) ~[opennms-services-16.0.2.jar:?]
    at org.opennms.netmgt.collectd.HttpCollector$HttpCollectionSet.collect(HttpCollector.java:179) [opennms-services-16.0.2.jar:?]
    at org.opennms.netmgt.collectd.HttpCollector.collect(HttpCollector.java:139) [opennms-services-16.0.2.jar:?]
    at org.opennms.netmgt.collectd.CollectionSpecification.collect(CollectionSpecification.java:274) [opennms-services-16.0.2.jar:?]
    at org.opennms.netmgt.collectd.CollectableService.doCollection(CollectableService.java:388) [opennms-services-16.0.2.jar:?]
    at org.opennms.netmgt.collectd.CollectableService.doRun(CollectableService.java:322) [opennms-services-16.0.2.jar:?]
    at org.opennms.netmgt.collectd.CollectableService.access$000(CollectableService.java:70) [opennms-services-16.0.2.jar:?]
    at org.opennms.netmgt.collectd.CollectableService$1.run(CollectableService.java:300) [opennms-services-16.0.2.jar:?]
    at org.opennms.core.logging.Logging.withPrefix(Logging.java:66) [org.opennms.core.logging-16.0.2.jar:?]
    at org.opennms.netmgt.collectd.CollectableService.run(CollectableService.java:296) [opennms-services-16.0.2.jar:?]
    at org.opennms.netmgt.scheduler.LegacyScheduler$1.run(LegacyScheduler.java:209) [opennms-services-16.0.2.jar:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_51]
    at org.opennms.core.concurrent.LogPreservingThreadFactory$3.run(LogPreservingThreadFactory.java:124) [opennms-util-16.0.2.jar:?]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_51]
2015-08-12 12:08:14,771 WARN  [Collectd-Thread-10-of-50] o.o.n.c.CollectableService: run: failed collection for 63/(foo's IP)/HttpSecCount/foo1
2015-08-12 12:08:14,771 ERROR [Collectd-Thread-10-of-50] o.o.n.c.CollectableService: Collection failed for an unknown reason (code 2.  Please review previous logs for this thread for details.  You can also open up an enhancement bug report (include your logs) to request that failure messages are logged for this type of error.
org.opennms.netmgt.collectd.CollectionFailed: Collection failed for an unknown reason (code 2.  Please review previous logs for this thread for details.  You can also open up an enhancement bug report (include your logs) to request that failure messages are logged for this type of error.
    at org.opennms.netmgt.collectd.CollectableService.doCollection(CollectableService.java:413) ~[opennms-services-16.0.2.jar:?]
    at org.opennms.netmgt.collectd.CollectableService.doRun(CollectableService.java:322) [opennms-services-16.0.2.jar:?]
    at org.opennms.netmgt.collectd.CollectableService.access$000(CollectableService.java:70) [opennms-services-16.0.2.jar:?]
    at org.opennms.netmgt.collectd.CollectableService$1.run(CollectableService.java:300) [opennms-services-16.0.2.jar:?]
    at org.opennms.core.logging.Logging.withPrefix(Logging.java:66) [org.opennms.core.logging-16.0.2.jar:?]
    at org.opennms.netmgt.collectd.CollectableService.run(CollectableService.java:296) [opennms-services-16.0.2.jar:?]
    at org.opennms.netmgt.scheduler.LegacyScheduler$1.run(LegacyScheduler.java:209) [opennms-services-16.0.2.jar:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_51]
    at org.opennms.core.concurrent.LogPreservingThreadFactory$3.run(LogPreservingThreadFactory.java:124) [opennms-util-16.0.2.jar:?]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_51]

我想知道是否有人知道是什么导致了这个问题?
http-datacollection-config.xml文件:
<http-collection name="sec-count">
    <rrd step="900">
      <rra>RRA:AVERAGE:0.5:1:2016</rra>
      <rra>RRA:AVERAGE:0.5:12:1488</rra>
      <rra>RRA:AVERAGE:0.5:288:366</rra>
      <rra>RRA:MAX:0.5:288:366</rra>
      <rra>RRA:MIN:0.5:288:366</rra>
    </rrd>
    <uris>
      <uri name="foo">
        <url path="/foo1/index.php"
         host="www.foo.com"
             user-agent="Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0"
             matches="(?!opennms)(\d+)(?=opennms)" response-range="100-399" >
        </url>
        <attributes>
          <attrib alias="secondCount" match-group="1" type="gauge"/>
        </attributes>
      </uri>
    </uris>
  </http-collection>

collectd-configuration.xml文件:
在“示例1”包下
<service name="HttpSecCount" interval="900000" user-defined="false" status="on">
            <parameter key="collection" value="sec-count"/>
        </service>
<collector service="HttpSecCount" class-name="org.opennms.netmgt.collectd.HttpCollector"/>

最佳答案

(?!opennms)(\d+)(?=opennms)不是您要查找的regex:
请改为使用以下选项:

(?<=opennms)(\d+)(?=opennms)

通过Debuggex可视化

09-26 12:00