XML Serialisation

The preferred data formats is to use JSON or perl as this preserves all the data in the native formats, as well as being much smaller in size. However, there is the ability to communicate with the Opsview REST API using XML.

The rules for data conversion are:

Example List Data Copied

An example request when using opsview_rest (note the change of the --data-format=xml option compared to other examples):

opsview_rest --token-file /path/to/opsview_restapi_token --data-format=xml GET config/host/1

An example response is:

<opsview>
  <list>
    <item name="cisco"
          alias=""
          check_attempts="2"
          check_interval="0"
          enable_snmp="0"
          flap_detection_enabled="1"
          id="7"
          ip="192.168.10.20"
          nmis_node_type="router"
          notification_interval="0"
          notification_options="u,d,r"
          other_addresses=""
          rancid_connection_type="ssh"
          ref="/rest/config/host/7"
          retry_check_interval="1"
          snmp_community="shouldnotcreate"
          snmp_version="2c"
          snmpv3_authpassword=""
          snmpv3_privpassword=""
          snmpv3_username=""
          uncommitted="1"
          use_mrtg="0"
          use_nmis="0"
          use_rancid="0">
      <check_command name="slow ping"
                     ref="/rest/config/hostcheckcommand/1" />
      <check_period name="24x7"
                    ref="/rest/config/timeperiod/1" />
      <event_handlers isEmpty="1" />
      <exceptions isEmpty="1" />
      <excludedservicechecks isEmpty="1" />
      <hostattributes isEmpty="1" />
      <hostgroup name="Leaf"
                 ref="/rest/config/hostgroup/4" />
      <hosttemplates>
        <item name="Cisco Mgt"
              ref="/rest/config/hosttemplate/3" />
      </hosttemplates>
      <icon name="SYMBOL - Environment Monitor" />
      <keywords>
        <item name="alphaearly"
              ref="/rest/config/keyword/6" />
        <item name="cisco"
              ref="/rest/config/keyword/2" />
        <item name="cisco_gp1"
              ref="/rest/config/keyword/3" />
      </keywords>
      <monitored_by name="Master Monitoring Server"
                    ref="/rest/config/monitoringcluster/1" />
      <notification_period name="24x7"
                           ref="/rest/config/timeperiod/1" />
      <parents>
        <item name="cisco"
              ref="/rest/config/host/7" />
      </parents>
      <rancid_password isNull="1" />
      <rancid_username isNull="1" />
      <rancid_vendor isNull="1" />
      <servicechecks>
        <item name="Another exception"
              ref="/rest/config/servicecheck/82" />
        <item name="Coldstart"
              ref="/rest/config/servicecheck/79" />
        <item name="Interface"
              ref="/rest/config/servicecheck/95" />
        <item name="snmp poll"
              ref="/rest/config/servicecheck/83" />
        <item name="Test exceptions"
              ref="/rest/config/servicecheck/81" />
      </servicechecks>
      <snmpv3_authprotocol isNull="1" />
      <snmpv3_privprotocol isNull="1" />
      <timed_exceptions isEmpty="1" />
    </item>
    ...
  </list>
  <summary allrows="22"
           page="1"
           rows="2"
           totalpages="11"
           totalrows="22" />
</opsview>
["Opsview"] ["API", "Technical Reference"]

Was this topic helpful?