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

Fix for check-log.rb to handly invalid UTF-8 characters #31

Open
gihuphil opened this issue Nov 28, 2014 · 0 comments
Open

Fix for check-log.rb to handly invalid UTF-8 characters #31

gihuphil opened this issue Nov 28, 2014 · 0 comments

Comments

@gihuphil
Copy link

Hi all,

I was having some trouble with check-log.rb here. It crashed while parsing /var/log/syslog, because it found some really weird characters in there, which were logged e. g. together with strange GET requests. I fixed this for me applying the patch below, its a one liner. Maybe you want to consider applying this to the check, making it more robust, though it may drop some bytes now.

Kind Regards,

Philipp

@@ -106,6 +106,7 @@
@log.seek(@bytes_to_skip, File::SEEK_SET)
end
@log.each_line do |line|

  •  line.encode!('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
    
    bytes_read += line.size
    if m = line.match(config[:pattern])
    if m[1]
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