b-boy
11-11-2008, 07:55 AM
Hi all
I hope you can help me as I have no idea what I’m doing when it comes to XML . I am trying to modify some code (OpenNMS HTTP collector) to collect stats from a webpage.
The example code they give me uses a matches statement to populate the var by looking for a string and pumping what’s next to it into a var.
<http-datacollection-config
xmlns:http-dc="http://xmlns.opennms.org/xsd/config/http-datacollection"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.opennms.org/xsd/config/http-datacollection http://www.opennms.org/xsd/config/http-datacollection-config.xsd"
rrdRepository="/opt/opennms/share/rrd/snmp/" >
<http-collection name="weather">
<rrd step="300">
<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="weather-station">
<url path="/"
virtual-host="www.example.com"
matches="(?s).*?Temperature.*?3366FF">([0-9\.]+).*?Humidity.*?3366FF">([0-9]+)
.*?Barometer.*?3366FF">([0-9\.]+).*?Wind\sChill.*?3366FF"><small>([0-9\.]+)
.*?Heat\sIndex.*?3366FF"><small>([0-9\.]+).*"
response-range="100-399" >
</url>
<attributes>
<attrib alias="wsTemperature" match-group="1" type="gauge32"/>
<attrib alias="wsHumidity" match-group="2" type="gauge32"/>
<attrib alias="wsBarometer" match-group="3" type="gauge32"/>
<attrib alias="wsWindChill" match-group="4" type="gauge32"/>
<attrib alias="wsHeatIndex" match-group="5" type="gauge32"/>
</attributes>
</uri>
</uris>
</http-collection>
</http-datacollection-config>
My problem is the data I want to collect from a web page is displayed like this
“1,2,3,4,0.2,0.4,0.8,1000,2000”
So there is no key word to search for , how would I go about pumping that data into the var? It looks like it might work with an array or something but i have no idea..
Thanks in advance
b
I hope you can help me as I have no idea what I’m doing when it comes to XML . I am trying to modify some code (OpenNMS HTTP collector) to collect stats from a webpage.
The example code they give me uses a matches statement to populate the var by looking for a string and pumping what’s next to it into a var.
<http-datacollection-config
xmlns:http-dc="http://xmlns.opennms.org/xsd/config/http-datacollection"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.opennms.org/xsd/config/http-datacollection http://www.opennms.org/xsd/config/http-datacollection-config.xsd"
rrdRepository="/opt/opennms/share/rrd/snmp/" >
<http-collection name="weather">
<rrd step="300">
<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="weather-station">
<url path="/"
virtual-host="www.example.com"
matches="(?s).*?Temperature.*?3366FF">([0-9\.]+).*?Humidity.*?3366FF">([0-9]+)
.*?Barometer.*?3366FF">([0-9\.]+).*?Wind\sChill.*?3366FF"><small>([0-9\.]+)
.*?Heat\sIndex.*?3366FF"><small>([0-9\.]+).*"
response-range="100-399" >
</url>
<attributes>
<attrib alias="wsTemperature" match-group="1" type="gauge32"/>
<attrib alias="wsHumidity" match-group="2" type="gauge32"/>
<attrib alias="wsBarometer" match-group="3" type="gauge32"/>
<attrib alias="wsWindChill" match-group="4" type="gauge32"/>
<attrib alias="wsHeatIndex" match-group="5" type="gauge32"/>
</attributes>
</uri>
</uris>
</http-collection>
</http-datacollection-config>
My problem is the data I want to collect from a web page is displayed like this
“1,2,3,4,0.2,0.4,0.8,1000,2000”
So there is no key word to search for , how would I go about pumping that data into the var? It looks like it might work with an array or something but i have no idea..
Thanks in advance
b