Ad Widget

Collapse

XML parsing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • z4g
    Junior Member
    • Jun 2008
    • 8

    #1

    XML parsing

    Hi,

    Need some help configuring zabbix to go over an XML and get values of it to insert in to the DB.

    Basically we have a product that we can use "get" to a URL that will return an XML with various values, I need a way to have zabbix go to that URL get the XML and parse different values off of it.

    Something like this

    point the browser to:



    will get me this:

    <result>
    <status result="OK">
    <description code="1" status="OK">running</description>
    </status>
    <info>
    <dock id="01">
    <description>dock 01</description>
    <location>Lab</location>
    </dock>
    <cradle index="1">
    <description>Cradle 01</description>
    <access>0101</access>
    <video>
    <recording>false</recording>
    <streaming>true</streaming>
    <PauseVideo>true</PauseVideo>
    <HasAudio>true</HasAudio>hssId_DEXTER-cradle_0101-569D87A3</video>
    <audio>XXXXXXXXX 1010LT 3/4</audio>
    <hssid>XXXXXX</hssid>
    <status code="1">running</status>
    </cradle>
    <Version>
    <name>Atlantis</name>
    <iteration_code>21</iteration_code>
    <build_number>661</build_number>
    <build_date>2010-07-25_06-02-08</build_date>
    <build_time>2010-07-25_06-02-08</build_time>
    <build_version>2010-07-25_06-02-08.661</build_version>
    <dev_version>atlantis21-SNAPSHOT</dev_version>
    <build_timestamp>1280027158360</build_timestamp>
    <scm_version>31684</scm_version>
    </Version>
    <handset>
    <manufacturer>XXXX XXXXXXXXX</manufacturer>
    <model>SXXXX XXXXXXXXX W850</model>
    <version>XXXXXXX 060831 2039 XX_GENERIC_CY</version>
    <imei>XXXXXXXXXXXXXXX</imei>
    <imsi>UNKNOWN</imsi>
    <client-version>UNKNOWN</client-version>
    <template-data>
    <manufacturer>XXXX XXXXXXXXX</manufacturer>
    <model>XXXXX</model>
    <distributor>XXXX XXXXXXXXX</distributor>
    <version>XXXXXXX 060831 2039 XX</version>
    </template-data>
    </handset>
    </info>
    <time64>
    <time>1280240509</time>
    <millitm>940</millitm>
    <timezone>-120</timezone>
    <dstflag>1</dstflag>
    </time64>
    <req_time>183425621</req_time>
    <duration>234</duration>
    <sys_start_time>Sun Jul 25 14:24:52 2010</sys_start_time>
    <sys_uptime>2 days 02:56:57</sys_uptime>
    <camera initialized="true" type="Pixelink">
    <settings>
    <fps>6</fps>
    <rotate>0</rotate>
    <roi>
    <x>48</x>
    <y>256</y>
    <w>792</w>
    <h>632</h>
    </roi>
    <sn>774001102</sn>
    <feature id="FEATURE_WHITE_BAL">
    <param>3200.000000</param>
    <flags>2</flags>
    </feature>
    <feature id="FEATURE_SATURATION">
    <param>150.000000</param>
    <flags>2</flags>
    </feature>
    <feature id="FEATURE_GAMMA">
    <param>2.200000</param>
    <flags>18</flags>
    </feature>
    <feature id="FEATURE_SHUTTER">
    <param>0.145000</param>
    <flags>2</flags>
    </feature>
    <feature id="FEATURE_GAIN">
    <param>4.080000</param>
    <flags>2</flags>
    </feature>
    <feature id="FEATURE_FRAME_RATE">
    <param>6.000000</param>
    <flags>2</flags>
    </feature>
    <feature id="FEATURE_FLIP">
    <param>0.000000</param>
    <param>0.000000</param>
    <flags>514</flags>
    </feature>
    <feature id="FEATURE_WHITE_SHADING">
    <param>1.523438</param>
    <param>1.000000</param>
    <param>1.437500</param>
    <flags>2</flags>
    </feature>
    </settings>
    <statistics>
    <window>10</window>
    <fps>6</fps>
    <min_frame_time>125</min_frame_time>
    <max_frame_time>172</max_frame_time>
    <avg_frame_time>165.616669</avg_frame_time>
    <bad_frames>0</bad_frames>
    <bad_frames_percent>0.000000</bad_frames_percent>
    <delayed_frames>0</delayed_frames>
    <delayed_frames_percent>0.000000</delayed_frames_percent>
    <min_delayed_frame_time>0</min_delayed_frame_time>
    <avg_delayed_frame_time>0.000000</avg_delayed_frame_time>
    </statistics>
    </camera>
    </result>

    Any help would be appreciated
  • sarathyme
    Member
    • Mar 2009
    • 58

    #2
    Are you saying the values coming from the xml are sort of profile information for the host.

    Or those values should go as an items?

    if you ask me, i will say, use Java to connect to the URL (URLConnection) and fetch the xml. Parse the xml. Insert to zabbix database.

    If you want to send as an item, consider using the java senders along with your code. (http://svn.gdries.nl/public/ZabbixTools/trunk/) I personally like Zabbix Tools developed by Gerco Dries than zapcat.

    Please give litte more info on what you want to do, i can be of some help on this. :-)

    Comment

    • z4g
      Junior Member
      • Jun 2008
      • 8

      #3
      Yes, the values should return as items

      The main issue is how or with what tool to parse the XML we are working on windows servers BTW

      Thanks for your help

      Comment

      • sarathyme
        Member
        • Mar 2009
        • 58

        #4
        You could try JAXB to parse, which creates objects based on xml. (It has unmarshaller class that takes input stream).



        Regards
        Vijay

        Comment

        Working...