Skip to content
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

Livestatus crash with non-ascii characters #71

Open
FloooW opened this issue Aug 2, 2016 · 0 comments
Open

Livestatus crash with non-ascii characters #71

FloooW opened this issue Aug 2, 2016 · 0 comments

Comments

@FloooW
Copy link

FloooW commented Aug 2, 2016

When the livestatus module is attempting to output non-ascii characters, it crashes. Such caracters can be found in macros.

[1470141883] ERROR: [broker-1] Unexpected error: 'ascii' codec can't encode character u'\xfc' in position 11: ordinal not in range(128) ; traceback: Traceback (most recent call last):
File "/var/lib/shinken/modules/livestatus/livestatus_client_thread.py", line 254, in run
self.handle_request(request_bytes)
File "/var/lib/shinken/modules/livestatus/livestatus_client_thread.py", line 237, in handle_request
self.send_response(response)
File "/var/lib/shinken/modules/livestatus/livestatus_client_thread.py", line 208, in send_response
for data in response:
File "/var/lib/shinken/modules/livestatus/livestatus_response.py", line 66, in iter
for v2 in value:
File "/var/lib/shinken/modules/livestatus/livestatus_response.py", line 278, in make_live_data_generator
for value in self.make_live_data_generator2(result, columns, aliases):
File "/var/lib/shinken/modules/livestatus/livestatus_response.py", line 261, in make_live_data_generator2
l.append(row_item_handler(self, value))
File "/var/lib/shinken/modules/livestatus/livestatus_response.py", line 160, in _format_csv_value
return self.separators.list.join(str(x) for x in value)
File "/var/lib/shinken/modules/livestatus/livestatus_response.py", line 160, in
return self.separators.list.join(str(x) for x in value)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 11: ordinal not in range(128)

[1470141938] INFO: [broker-1] [Livestatus Broker] So I quit
[1470141938] INFO: [broker-1] [Livestatus Broker] So I quit

In this case, the issue was caused by the character ü.

Adding the following lines after the imports to the file "/var/lib/shinken/modules/livestatus/livestatus_response.py" fixed the issue.

import sys  # import sys package, if not already imported
reload(sys)
sys.setdefaultencoding('utf-8')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant