RSS Feed for This PostCurrent Article

Tip of the Month: Getting XML Formatted Device Details

Zenoss provides a variety of tools to help you integrate it into other tools. Commonly used are the REST, XML-RPC and Python APIs. Another less-used option is XML. This can be very useful as a read-only integration point because you can get all of the data you need in a single simple transaction and good XML parsing libraries exist for all languages.

In this example, we’ll be creating a page template that replicates the data that is available on a device’s status tab. The only difference is that the data will be easily-consumable XML.

Create the Page Template

  1. Go to http://yourzenoss:8080/zport/portal_skins/custom/manage
  2. Choose “Page Template” from the drop-down box in the top-right and click Add.
  3. Set the Id to “deviceStatusXml” then click Add and Edit.
  4. Replace the default contents with the XML template below.
  5. Click Save Changes.

XML Template

<?xml version="1.0"?>
<tal:block tal:define="
status python:here.getPingStatus()<1 and 'Up' or 'Down';
productionState python:here.convertProdState(here.productionState);
priority python:here.convertPriority(here.priority);
">

<device tal:attributes="id here/id">
<manageIp tal:content="here/manageIp"/>
<status tal:content="status"/>

<availability tal:content="here/availability"/>
<uptime tal:content="here/uptimeStr"/>
<productionState tal:content="productionState"/>
<priority tal:content="priority"/>
<lastChange tal:content="here/getLastChangeString"/>
<lastCollection tal:content="here/getSnmpLastCollectionString"/>
<firstSeen tal:content="here/getCreatedTimeString"/>

<deviceClass tal:content="here/getDeviceClassName"/>
<location tal:content="here/getLocationName"/>
<groups tal:repeat="group here/groups/objectValuesAll">
<group tal:attributes="id group/id; name group/getOrganizerName"/>
</groups>
<systems tal:repeat="system here/systems/objectValuesAll">
<system tal:attributes="id system/id; name system/getOrganizerName"/>
</systems>

<tag tal:content="here/hw/tag"/>
<serialNumber tal:content="here/hw/serialNumber"/>
<hardwareMake tal:content="here/hw/getManufacturerName"/>
<hardwareModel tal:content="here/hw/getModelName"/>
<osMake tal:content="here/os/getManufacturerName"/>
<osVersion tal:content="here/os/getModelName"/>
<rackSlot tal:content="here/rackSlot"/>
<snmpSysName tal:content="here/snmpSysName"/>
<snmpLocation tal:content="here/snmpLocation"/>
<snmpContact tal:content="here/snmpContact"/>

<snmpDescr tal:content="here/snmpDescr"/>
<comments tal:content="here/comments"/>
</device>

</tal:block>

Viewing the XML

  1. Navigate to any device in your Zenoss web interface.
  2. Click on the Status tab. Note that the URL ends with /deviceStatus
  3. Change the URL to end with /deviceStatusXml instead.
  4. View the source of the page that comes up. Device status in XML!
Sphere: Related Content

Trackback URL

RSS Feed for This PostPost a Comment