[ZBX-3915] cannot add host due to inability to call DBstart and DBend from API (via Jsonrpc interface) Created: 2011 Jul 01  Updated: 2017 May 30  Resolved: 2011 Oct 05

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A)
Affects Version/s: None
Fix Version/s: 1.9.7 (beta), 2.0.0

Type: Incident report Priority: Trivial
Reporter: Francis (Grizzly) Smit Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: api
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

coding api from jsonrpc interface in python



 Description   

when I create a host using the API it returns me a hostid as if all is fine but when I then add that host to a map it does not show, upon checking I find that the host does not exist even though the API call to API::Host->create($hosts) executed fine.

Upon further investigation to see how the web page does this I find that they call DBstart(true) before the call to the api and DBend(true) after, so I wonder if there is any way for me to do the same as API calls.



 Comments   
Comment by Francis (Grizzly) Smit [ 2011 Jul 01 ]

sorry I've accidentally set the priority to Trivial it should be blocker or some such as I cannot proceed due to this bug

Comment by richlv [ 2011 Jul 01 ]

please show json query used to create host & the response to it

Comment by Francis (Grizzly) Smit [ 2011 Jul 04 ]

here is the json sent:
{"params": [{"status": 0, "templates": [

{"templateid": "10048"}

], "interfaces": [

{"ip": "", "useip": 0, "type": 1, "port": 10050, "dns": "Y1-aus800.oztell.com"}

,

{"ip": "", "useip": 0, "type": 1, "port": 10050, "dns": "alphaY1-aus800.oztell.com"}

,

{"ip": "", "useip": 0, "type": 1, "port": 10050, "dns": "betaY1-aus800.oztell.com"}

], "host": "Y1-aus800", "profile":

{"macaddress": "FED1234:987:AB", "name": "", "serialno": "12234BFD23545", "notes": "", "contact": "", "hardware": "", "tag": "", "devicetype": "", "location": "", "os": "", "software": ""}

, "groups": [

{"groupid": "6"}

,

{"groupid": "7"}

]}], "jsonrpc": "2.0", "method": "host.create", "auth": "bad7ae07237ab20b21c8eae69695bf4f", "id": 5}
10: Sending headers:

{'Content-Type': 'application/json-rpc', 'Authorization': 'Basic YXBpdXNlcjpbfiYkQCgpKl4lJDE5OTEtaGVsbG9d', 'User-Agent': 'python/zabbix_api'}

and the respose:
{'jsonrpc': '2.0', 'result':

{'hostids': ['10051']}

, 'id': 5}
10: json_obj: {'params':

{'pattern': 'aus800', 'extendoutput': True, 'sortfield': 'name'}

, 'jsonrpc': '2.0', 'method': 'map.get', 'auth': 'bad7ae07237ab20b21c8eae69695bf4f', 'id': 6}

Comment by richlv [ 2011 Jul 04 ]

1. i'm a bit suspicious about that map.get part at the end. is that just the next method ?
2. i'm not sure whether empty ip is allowed in the interface (it might be) - you could try 0.0.0.0 instead.
3. could you try host.get with the id returned after creating it to see whether host itself exists ?
4. what actually is the problem ? host not being created ? host element not being added to map ? if the latter, please attach full json of adding an object to a map, then retrieving map details and showing it missing.

note that map elements must always be an array, even if there's only one element, as per ZBX-3685...

Comment by Francis (Grizzly) Smit [ 2011 Jul 04 ]

1). yes the
10: json_obj: {'params':

{'pattern': 'aus800', 'extendoutput': True, 'sortfield': 'name'}

, 'jsonrpc': '2.0', 'method': 'map.get', 'auth': 'bad7ae07237ab20b21c8eae69695bf4f', 'id': 6}
bit is the next call that got caught up by accident when I cut and pasted from the log so ignore it

2). I'll try that.
3). will do
4). yeah the host is not created it returns like it is, but I presume it gets rolled back or some thing

Comment by richlv [ 2011 Sep 03 ]

did any of (2) or (3) help ?

Comment by Francis (Grizzly) Smit [ 2011 Sep 05 ]

sorry been busy with other projects, should get back to zabbix soon

Comment by Francis (Grizzly) Smit [ 2011 Oct 05 ]

This bug is gone as of the latest version

Comment by Francis (Grizzly) Smit [ 2011 Oct 05 ]

The problem has gone away in the latest version

Generated at Tue Apr 16 11:06:33 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.