TECHZEN Zenoss User Community ARCHIVE  

how to query zodb database for device/status?

Subject: how to query zodb database for device/status?
Author: [Not Specified]
Posted: 2015-02-20 09:36

We are building an app that maps infrastructure devices to a location in our building. Is there a document that details how to query (zodb I assume) to get devices and the state of the device



Subject: You want the API
Author: [Not Specified]
Posted: 2015-02-20 10:38

JSON API: http://wiki.zenoss.org/index.phptitle=Working_with_the_JSON_API&oldid=1...

getDevices method will get you a list of devices; and depending on what you mean by State (up/down) That is the "status" field of the getInfo method for each device.

zenoss_api "device_router" "DeviceRouter" "getInfo" '{"uid":"/zport/dmd/Devices/Server/Linux/devices/ZENOSSTEST"}'|grep -i status
'status' => ${\$VAR1->{'result'}{'disabled'}}, <- a down device
'status' => ${\$VAR1->{'result'}{'success'}}, <- an up device



Subject: Looks great! Thank you!
Author: [Not Specified]
Posted: 2015-02-20 12:27

Looks great! Thank you!



Subject: Point of clarification -
Author: [Not Specified]
Posted: 2015-02-20 12:40

The output I pasted was from my version of zenoss_api that runs the JSON thru Perl Data::Dumper - If you're using the stock zenoss_api supplied in the wiki page, look for this:

"status": true (up)
or
"status": false (down)

embedded in the JSON response.

HTH,
Dave



Subject: Here is what the call returns
Author: [Not Specified]
Posted: 2015-02-20 13:59

Here is what the call returns. I deleted a large part of "data" but "status" within data appears to change to false with a down device. Disabled and success do not seem to change. I'm not sure how that relates to your example and if you could explain it I would appreciate it!

'status' ={\$VAR1{'result'}{'disabled'}}, a down device
'status' ={\$VAR1{'result'}{'success'}}, an up device

-------------------------- returned data -----------------------------------

{
"uuid":"f4079708-5db1-437a-a762-1b4937cf2795",
"action":"DeviceRouter",
"result":{
"disabled":false,
"data":{...
"status:true
...},
"success":true
},
"tid":1,
"type":"rpc",
"method":"getInfo"
}



Subject: Got it! Thanks again!
Author: [Not Specified]
Posted: 2015-02-21 00:01

Got it! Thanks again!



Subject: just for the purpose of those
Author: Andrew Kirch
Posted: 2015-02-26 11:59

just for the purpose of those finding this thread in the future, you must not directly query or write to the zodb database.

Andrew Kirch

akirch@gvit.com

Need Zenoss support, consulting or custom development Look no further. Email or PM me!

Ready for Distributed Topology (collectors) for Zenoss 5 Coming May 1st from GoVanguard



< Previous
Progamatically create local zProperty value?
  Next
Adding/editing device interface descriptions
>