Working with the JSON API

From Zenoss Wiki
Revision as of 03:12, 25 November 2012 by Chet Luther (Talk | contribs)$7

(diff) ← Older revision | Approved revision (diff) | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

You can find API documentation for the Zenoss JSON API at http://docs.zenoss.org/. The accompanying files for this document include a shell script called json_api.sh. This is an example for using curl in a shell script to use the Zenoss JSON API.

The following example uses helper functions in json_api.sh to show the title and URL for the graphs on a particular device. Be sure to download json_api.sh for this example.

$ # Get the zenoss_api function by sourcing json_api.sh.
$ source json_api.sh

$ # Call the getGraphDefs method.
$ zenoss_api device_router DeviceRouter getGraphDefs '{"uid":"/zport/dmd/Devices/Server/Linux/devices/zenosstrain6.zenoss.com","drange":129600}'

The output of this command will be a JSON document that contains the title and graph URL for every graph on the device identified by the uid parameter above.