Tip of the Month: Getting XML Formatted Device Details
By Chet on May 21, 2008 in News Items, Tips
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
- Go to http://yourzenoss:8080/zport/portal_skins/custom/manage
- Choose “Page Template” from the drop-down box in the top-right and click Add.
- Set the Id to “deviceStatusXml” then click Add and Edit.
- Replace the default contents with the XML template below.
- 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
- Navigate to any device in your Zenoss web interface.
- Click on the Status tab. Note that the URL ends with /deviceStatus
- Change the URL to end with /deviceStatusXml instead.
- View the source of the page that comes up. Device status in XML!

















Receive
Blog Updates via Email