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

Why is the file in /var/cache being truncated ? How will check-log do pattern search on a empty file #16

Open
jsiddharth opened this issue Feb 15, 2017 · 2 comments

Comments

@jsiddharth
Copy link

tail on /var/cache/check-log/.../var/log/auth.log reports
9333715tail: /var/cache/check-log/default/var/log/auth.log: file truncated
9333715tail: /var/cache/check-log/default/var/log/auth.log: file truncated
9333715tail: /var/cache/check-log/default/var/log/auth.log: file truncated

URGENT ISSUE

@jsiddharth
Copy link
Author

jsiddharth commented Feb 15, 2017

Does this line need to change ?
From

FileUtils.mkdir_p(File.dirname(@state_file))
    File.open(@state_file, 'w') do |file|
      file.write(@bytes_to_skip + bytes_read)
    end

To //sorry for java syntax, but I think you get the point

if (bytes_read > 0) {
FileUtils.mkdir_p(File.dirname(@state_file))
    File.open(@state_file, 'w') do |file|
      file.write(@bytes_to_skip + bytes_read)
    end
}

@majormoses
Copy link
Member

majormoses commented May 13, 2017

I have not used this plugin or read through it's code enough to comment on why the file is truncated.

Regarding an empty file (or a non existent file for that matter) we should just check that the files size is 0:

if File.stat(my_file).size.zero? || !File.exist?(my_file)
  p "skipping #{my_file} as it is empty or does not exist
else
  # do current logic
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants