Skip to content

Livestatus crash with non-ascii characters #71

@FloooW

Description

@FloooW

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')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions