New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[dev.icinga.com #13427] Improve error handling when responding to non-HTML requests #2635
Comments
Updated by elippmann on 2016-12-06 16:11:14 +00:00
Hi, The JSON output is not limited actually. What do you mean w/ the "JSON output is not being provided"? Which version of Web 2 are you using? Best regards, |
Updated by medicmomcilo on 2016-12-06 16:32:03 +00:00 Hi Eric, Version of Web2 is 2.3.4+fix-1~ppa1404+1 on Ubuntu 14.04 When tried via curl I get nothing as well, however status is 200:
I just installed brand new VM with latest vanilla Icinga Web2 and I get the same behaviour.
Kind regards, |
Updated by medicmomcilo on 2016-12-07 08:02:05 +00:00 Hi Eric, Just as a side note, CSV export works perfectly. This should rule out any database issues or issues with other components. Kind regards, |
Updated by tgelf on 2016-12-07 08:15:19 +00:00
Hi Momcilo, you should check your webserver (error) logs. What probably happens is that your PHP is using more memory than it was granted. To solve this you should raise the memory_limit in your php.ini to a reasonable memory, allowing you to prepare all the requested data in memory. I guess your Ubuntu is running with very conservative defaults. Furthermore you might also consider upgrading your box. 16.04 LTS uses PHP 7, and that one consumes far less memory. But don't worry, we still support (and test) everything from PHP 5.3 to PHP 7. medicmomcilo wrote:
Well, one main difference is that the web frontend shows a limited amount of lines while the requested JSON ships all of them. CSV works differently, as it iterates over the result set. That way it is able to send data line by line while fetching rows from the DB. This won't work with JSON for various reasons. You cannot really stream it unless combined with other technology. So it has to be built in memory. To be able to do so, we first fetch all the data into a PHP data structure. So the whole thing is in memory at least twice at that moment. Cheers, |
Updated by tgelf on 2016-12-07 08:17:38 +00:00 medicmomcilo wrote:
Well, at least this is strange and speaks against my theory. It should be 500 when running out of memory. And 400 services isn't that much... |
Updated by medicmomcilo on 2016-12-07 13:24:59 +00:00 Hi Thomas, Thanks for your replies! Unfortunately there is nothing in logs. I checked apache2 access_log error_log and icingaweb2.log which is in DEBUG logging. If there is anything I can further provide, do let me know. Kind regards, |
Updated by aklimov on 2016-12-08 15:45:03 +00:00
Hi Momcilo, I've tried to reproduce this with the following setup:
When I fetch ALL of them as JSON with PHP's memory limit left as is... easy going. If you're still getting this error, please test the following:
This will explicitly set the content length (to something > 0). After testing you can undo this by:
Cheers, |
Updated by medicmomcilo on 2016-12-08 16:28:08 +00:00 Hi Alex, Thank you for your idea.
This is how handleFormatRequest procedure looks now:
'; Is there any other way it can be related to database, or other components even though it can produce csv output? Kind regards, |
Updated by medicmomcilo on 2016-12-13 11:18:32 +00:00 Hi all! Finally I was able to identify the issue here.
This is causing json_encode function in php to return 'false' indicating error in encoding. We decided to stop monitoring this process as fixing this may require fixing non-maintained code. You can go ahead and close this issue if you like or you can introduce some sort of handling for this. Thank you all for your help and feedback, it really helped me to start thinking differently. Keep up the good work friends ;) Kind regards, |
Updated by jmeyer on 2016-12-13 14:54:06 +00:00
Hi, many thanks for sharing your solution with us! Best regards, |
Updated by jmeyer on 2016-12-13 14:54:16 +00:00
|
Updated by aklimov on 2016-12-14 12:38:55 +00:00
Hi Momcilo, I'm happy for you that you've found a solution for that, but that doesn't fix the problem. Please could you help us with that and:
Cheers, |
Updated by medicmomcilo on 2016-12-26 00:08:41 +00:00 Hi Alex, Sorry for the late reply. I've looked at your patch and I am really uncomfortable sharing entire array in public. If you prefer base64 output of the check, here it is:
PHP version on the server is: 5.5.9+dfsg-1ubuntu4.20 on Ubuntu 14.04.5 Do let me know if there is anything else I can do assist in handling these types of errors. Kind regards, |
...and add some logging to ease tracking errors. refs #2635
Need to pause here now. Until now only JsonResponse has been adjusted but there are other usages of json_encode() which need to be handled this way. |
@nilmerg Souldn't we adjust our Json::encode() and just use it everywhere? |
@Al2Klimov Sure. Scratch that, it's the other way round. That's for <=5.4. We've raised the minimum to 5.6. There invalid JSON should throw an error without the mentioned option. |
@nilmerg I've taken a look at your change's effect and I'm not quite sure that it's the way(tm). Any non-UTF8 string gets NULL. What about this:
|
As discussed w/ @nilmerg (offline): |
This issue has been migrated from Redmine: https://dev.icinga.com/issues/13427
Created by medicmomcilo on 2016-12-06 15:43:52 +00:00
Assignee: medicmomcilo
Status: Feedback
Target Version: Backlog
Last Update: 2016-12-26 00:08:41 +00:00 (in Redmine)
Hi friends!
Recently in our infrastructure Nagstamon suddenly stopped working.
After some hours of troubleshooting we identified that this is due to JSON output is not being provided:
/monitoring/list/services?service_state>0&service_state<=3&service_state_type=1&addColumns=service_last_check&format=json
Our assumption is that because of number of criticals it stopped, this can also be confirmed with narrowing down the filter.
You can test this with inclusion of services in OK state if you don't have enough testing criticals. URL for that:
/monitoring/list/services?service_state>=0&service_state<=3&service_state_type=1&addColumns=service_last_check&format=json
Do let me know if there is anything else I can provide to help you investigate this issue further.
Kind regards,
Momcilo.
Attachments
The text was updated successfully, but these errors were encountered: