Ad Widget
Collapse
Python library for Zabbix API
Collapse
X
-
I use the following code snippet to get a long(er) text value...
The problem: not all the data is fetched (+- 512) (everything shows in zabbix frontend)Code:for item in zapi.item.get({'filter': { 'hostid' : k, 'key_':'test1[]'} , 'output' :'extend'}): print "%s %s %s %s %s" % (item['hostid'], item['itemid'],item['description'], item['lastvalue'], item['templateid']) dicto[k] = item['lastvalue'] print dicto
How can I solve this?Comment
-
version of zabbix API? I check this:I use the following code snippet to get a long(er) text value...
The problem: not all the data is fetched (+- 512) (everything shows in zabbix frontend)Code:for item in zapi.item.get({'filter': { 'hostid' : k, 'key_':'test1[]'} , 'output' :'extend'}): print "%s %s %s %s %s" % (item['hostid'], item['itemid'],item['description'], item['lastvalue'], item['templateid']) dicto[k] = item['lastvalue'] print dicto
How can I solve this?
f =zapi.item.get({'filter': {},'output' :'extend'})
print len(f)
and always get true count of items.Comment
-
Item bulk creation
Hi,
I think there may be a problem with the item.create method of the api. My code looks like this:
items = []
items = builditems(conf,scen,step,hostid)
zapi.item.create(items)
The builditems function generates a set of items and returns a list (items). When I pass this list to zapi I get this error:
Traceback (most recent call last):
File "./webgen.py", line 178, in <module>
zapi.item.create(items)
File "/home/user/api/zabbix_api.py", line 365, in method
return self.universal("item.%s" % name, opts[0])
File "/home/user/api/zabbix_api.py", line 79, in wrapper
return self.do_request(self.json_obj(method, opts))['result']
File "/home/user/api/zabbix_api.py", line 337, in do_request
return self.parent.do_request(req)
File "/home/user/api/zabbix_api.py", line 301, in do_request
raise ZabbixAPIException(msg, jobj['error']['code'])
TypeError: __init__() takes exactly 2 arguments (3 given)
However, if I force builditems to return only 1 set of item parameters then item creation works. Is there something else I need to do in order to bulk load items?
Regards,
DavidLast edited by Yello; 04-01-2012, 18:03.Comment
-
Hi,
Thank you for your job on this library !
I am discovering the functionnality of the zabbix API, I would like to be able to see all the details about an item, but I can't see how ?
I know how to list all items id about a particular host:
Now that I have the item id, what is the way to describe it ?Code:list_item = zapi.item.get({"filter":{"hostids":hostid}}) for item in list_item: if item['itemid'] == '26062': print item
Thank you.Comment
Thx a lot!
Comment