更新:日志报告:
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 中的正则表达式不正确。请任何人都可以为我的问题提供正确的正则表达式吗?谢谢。
我一直在尝试使用 OpenNMS 设置 HTTP 收集器,以定期从网站收集数字,原始 HTML 代码类似于:
<!DOCTYPE HTML>
............
<i style="display:none" >opennms781opennms</i>
............
</body>
</html>
目标是收集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:在包“Example1”下
<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"/>