[ZBX-2469] PHP Fatal error: Cannot break/continue 1 level in /srv/src/zabbix/1.8/frontends/php/api/classes/class.cscreen.php on line 693 Created: 2010 May 27  Updated: 2017 May 30  Resolved: 2010 Jun 07

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A)
Affects Version/s: None
Fix Version/s: 1.8.3

Type: Incident report Priority: Major
Reporter: Maxence Dunnewind Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Debian squeeze,
root@zabbix:~# dpkg -l|grep apache
ii apache2 2.2.15-5 Apache HTTP Server metapackage
ii apache2-mpm-prefork 2.2.15-5 Apache HTTP Server - traditional non-threade
ii apache2-utils 2.2.15-5 utility programs for webservers
ii apache2.2-bin 2.2.15-5 Apache HTTP Server common binary files
ii apache2.2-common 2.2.15-5 Apache HTTP Server common files
ii libapache2-mod-php5 5.3.2-1 server-side, HTML-embedded scripting languag

root@zabbix:~# dpkg -l|grep zabbix
ii zabbix-agent 1:1.8.2-1 network monitoring solution - agent
ii zabbix-frontend-php 1:1.8.2-1 network monitoring solution - PHP front-end
ii zabbix-server-mysql 1:1.8.2-1 network monitoring solution - server (using



 Description   

I tried to use the python API mapping to delete a screen, the trace :

20: url: http://zabbix.krg/zabbix/api_jsonrpc.php
10: Trying to login with 'api':'md5(8a5da52ed126447d359e70c05721a8aa)'
10: json_obj: {'params':

{'password': 'api', 'user': 'api'}

, 'jsonrpc': '2.0', 'method': 'user.authenticate', 'auth': '', 'id': 0}
10: Connection object <httplib.HTTPConnection instance at 0x28b65f0>
20: Sending: {"params":

{"password": "api", "user": "api"}

, "jsonrpc": "2.0", "method": "user.authenticate", "auth": "", "id": 0}
10: Sending headers:

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

20: Response Code: 200 OK
10: Response Body:

{'jsonrpc': '2.0', 'result': '42e72a52d13b0286ce579af874f8572b', 'id': 0}

10: json_obj: {'params': {}, 'jsonrpc': '2.0', 'method': 'APIInfo.version', 'auth': '42e72a52d13b0286ce579af874f8572b', 'id': 1}
10: Connection object <httplib.HTTPConnection instance at 0x28b6878>
20: Sending: {"params": {}, "jsonrpc": "2.0", "method": "APIInfo.version", "auth": "42e72a52d13b0286ce579af874f8572b", "id": 1}
10: Sending headers:

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

20: Response Code: 200 OK
10: Response Body:

{'jsonrpc': '2.0', 'result': '1.2', 'id': 1}

Zabbix API Version: 1.2
10: json_obj: {'params':

{'sessionid': '42e72a52d13b0286ce579af874f8572b'}

, 'jsonrpc': '2.0', 'method': 'user.checkAuthentication', 'auth': '42e72a52d13b0286ce579af874f8572b', 'id': 2}
10: Connection object <httplib.HTTPConnection instance at 0x28b6998>
20: Sending: {"params":

{"sessionid": "42e72a52d13b0286ce579af874f8572b"}

, "jsonrpc": "2.0", "method": "user.checkAuthentication", "auth": "42e72a52d13b0286ce579af874f8572b", "id": 2}
10: Sending headers:

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

20: Response Code: 200 OK
10: Response Body:

{'jsonrpc': '2.0', 'result': True, 'id': 2}

Logged in: True
10: json_obj: {'params':

{'screenid': '3'}

, 'jsonrpc': '2.0', 'method': 'screen.delete', 'auth': '42e72a52d13b0286ce579af874f8572b', 'id': 3}
10: Connection object <httplib.HTTPConnection instance at 0x28b65f0>
20: Sending: {"params":

{"screenid": "3"}

, "jsonrpc": "2.0", "method": "screen.delete", "auth": "42e72a52d13b0286ce579af874f8572b", "id": 3}
10: Sending headers:

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

20: Response Code: 500 Internal Server Error
HTTP ERROR 500: Internal Server Error

Also tried with svn version svn://svn.zabbix.com/branches/1.8/frontends/php, same issue.

Log in apache :

[Thu May 27 09:28:40 2010] [error] [client 10.2.23.254] PHP Fatal error: Cannot break/continue 1 level in /srv/src/zabbix/1.8/frontends/php/api/classes/class.cscreen.php on line 693



 Comments   
Comment by Maxence Dunnewind [ 2010 Jun 03 ]

methods must be declared as public. If they are declared protected, any access finish with an error :

Error -32400: System error., JSON-rpc error generation failed. No such error:

Comment by Alexey Fukalov [ 2010 Jun 04 ]

Yes, it's not mistake.
To update items, you can use screen.update passing screenid and array of screenitems.

Probably in future there will be additionsl methods for configuration separate screenitems.

Comment by Maxence Dunnewind [ 2010 Jun 04 ]

mhhh ok.

Why not directly providing get / updateItems as public ?

Do you have some exemples of the parameters I'm supposed to send at update() to :

  • delete screenItems
  • add screenItems
  • update screenItems

Regards,

Maxence

Comment by Alexey Fukalov [ 2010 Jun 04 ]

{"jsonrpc":"2.0","method":"screen.update","params":[{"screenid":37,"screenitems":[

{"resourceid":18470,"resourcetype":1,"x":0,"y":0}

]}],"auth":"f3f8d561cc345977322643e7c610f744","id":4}

this request will update screen with id 37 by setting cell 0,0 to contain simple graph for item with id 18470, and removing all other screen items.
if you need screen to contain more items, add them to 'screenitems' array.

Comment by Maxence Dunnewind [ 2010 Jun 04 ]

ok, and so, to delete all the items of a screen, I have to do something like :

{"jsonrpc":"2.0","method":"screen.update","params":[{"screenid":37,"screenitems":{}}],"auth":"f2b9e786c3085f165d89d596da4fafaa","id":4}

Right ?

Comment by Alexey Fukalov [ 2010 Jun 04 ]

yes

Comment by Maxence Dunnewind [ 2010 Jun 04 ]

Ok.

I'll be able to try it this afternoon, I'll close this bug if it works.

Regards,

Maxence

Comment by richlv [ 2010 Jun 04 ]

i strongly suggest adding these examples to http://www.zabbix.com/documentation/1.8/api/objects/screen

Comment by Maxence Dunnewind [ 2010 Jun 04 ]

Ok, it works perfectly, I'm able to update my screen with new data.

Thanks !

Maxence

Comment by richlv [ 2010 Jun 04 ]

dev branch rev 12569.
when creating a new screen, it is created with name enclosed in single quotes

Comment by richlv [ 2010 Jun 07 ]

dev branch rev 12591.

attempting to update an existing screen upon import :

Undefined index: resourcetype[/usr/local/apache2/htdocs/dev/ZBX-2469-cscreen/api/classes/class.cscreen.php:476]
Undefined index: resourceid[/usr/local/apache2/htdocs/dev/ZBX-2469-cscreen/api/classes/class.cscreen.php:488]

Comment by richlv [ 2010 Jun 07 ]

also, a couple of error messages are quite useless :
[ CScreen::update ] Graph

Comment by richlv [ 2010 Jun 08 ]

confirming the fix in dev branch rev 12616.

Comment by Alexey Fukalov [ 2010 Jun 08 ]

Path
frontends/php/api/classes/class.cscreen.php

Generated at Fri Apr 26 19:30:34 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.