Zenoss 5 JSON API

5 posts / 0 new
Last post
Mohsin106
Mohsin106's picture
Offline
Last seen: 2 weeks 1 day ago
Joined: 03/10/2017 - 16:53
Posts: 3
Zenoss 5 JSON API

Hi,

I'm trying to learn how to use the Zenoss 5 JSON API. So far I have created this in my test bash script:

cat test.sh

#!/bin/sh
source /home/utilities/zenoss/test/zenoss.sh

zenoss_api   "I know there are supposed to be some arguments that need to go here but not sure which ones."

For example if I want to list all the devices from a specific group/system then what arguments would I put after zenoss_api?

Thanks

Mo

Jstanley
Jstanley's picture
Offline
Last seen: 6 hours 15 min ago
Joined: 07/10/2014 - 09:31
Posts: 213
Read up on the API

Read up on the API

https://www.zenoss.com/services-support/documentation/zenoss-json-api

 

Here is the python way of doing it. Script provided by Zenoss

https://github.com/jstanley23/ZenossAPIExamples

https://support.zenoss.com/hc/en-us/articles/202384859-How-To-Create-And-Close-Events-Via-curl-With-The-JSON-API

http://wiki.zenoss.org/Working_with_the_JSON_API

 

Mohsin106
Mohsin106's picture
Offline
Last seen: 2 weeks 1 day ago
Joined: 03/10/2017 - 16:53
Posts: 3
Python API

I think my last post got blocked by Mollom for spam for some reason. I'll try again ...

I'm getting the following error when using the Python API:

 

$ python test2.py

ValueError: No JSON object could be decoded

This is what I appended towards the end of the python script:

z = ZenossAPIExample()
devices = z.get_devices()
pprint.pprint(devices)

Inside the get_devices function I also tried using deviceClass='/zport/dmd/itinfrastructure#devices:.zport.dmd.Devices' since that is the URL I see when I view all devices from the Zenoss WebUI.

FYI...I'm able to get the Python API script to work on my Zenoss 4.2.5 instance but I can't get it to work on 5.2.0. The only difference between the two instances from my side is the new 5.2.0 is HTTPS as opposed to HTTP on the 4.2.5 instance.

Thanks

Mohsin106
Mohsin106's picture
Offline
Last seen: 2 weeks 1 day ago
Joined: 03/10/2017 - 16:53
Posts: 3
Working Just Fine.

Whoops! frown

I was using the wrong password on my new instance!! My bad, and thanks for your support.

Jstanley
Jstanley's picture
Offline
Last seen: 6 hours 15 min ago
Joined: 07/10/2014 - 09:31
Posts: 213
Not this:

Not this:

deviceClass='/zport/dmd/itinfrastructure#devices:.zport.dmd.Devices' 

But this:

deviceClass='/zport/dmd/Devices' 

If you want to use the URL as a guide, take the last part of it and replace '.' with '/'

Log in to post comments