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

[check-log] Trace an old file after logrotation with the inode number #250

Merged
merged 22 commits into from Sep 12, 2018

Conversation

Projects
None yet
2 participants
@yuuki
Member

yuuki commented Sep 6, 2018

Problem

check-log skips to check a renamed old file after logrotation.

Resolution

  1. saves inode number of the target logfile into a state file
  2. logrotate (ex. mv /var/log/access.log => /var/log/access.log.1 and create /var/log/access.log)
  3. find a file with same inode number of the logfile checked the last time in the directory of the target logfile.
  4. regards the found file as rotated file and also checks the file.

Notes

  • copytruncate is not supported.
  • windows is not supported.

@yuuki yuuki changed the title from [check-log] Trace old file after logrotation with inode to [check-log] Trace an old file after logrotation with the inode number Sep 6, 2018

Show outdated Hide outdated check-log/lib/check-log.go Outdated
@yuuki

This comment has been minimized.

Show comment
Hide comment
@yuuki

yuuki Sep 12, 2018

Member

I solved the problem that the state file management was duplicated by check-log and Songmu/postailer.

  1. Jsonize check-logs's status file #252
  2. Include inode number into the JSON status file
  3. add tracing inode logic to check-log without postailer
Member

yuuki commented Sep 12, 2018

I solved the problem that the state file management was duplicated by check-log and Songmu/postailer.

  1. Jsonize check-logs's status file #252
  2. Include inode number into the JSON status file
  3. add tracing inode logic to check-log without postailer
@yuuki

This comment has been minimized.

Show comment
Hide comment
@yuuki

yuuki Sep 12, 2018

Member

@astj Review again please!

Member

yuuki commented Sep 12, 2018

@astj Review again please!

Show outdated Hide outdated check-log/lib/check-log.go Outdated
}
warnNum += oldWarnNum
critNum += oldCritNum
errLines += oldErrLines

This comment has been minimized.

@astj

astj Sep 12, 2018

Contributor

When --return option specified, matched lines will be returned.

$ go run main.go --check-first -f README.md --pattern ISO --warning-over=1 --return
LOG CRITICAL: 14 warnings, 14 criticals for pattern /ISO/.
[README.md]
* ISO-2022-JP
* ISO-8859-1
* ISO-8859-2
* ISO-8859-3
* ISO-8859-4
* ISO-8859-5
* ISO-8859-6
* ISO-8859-7
* ISO-8859-8
* ISO-8859-10
* ISO-8859-13
* ISO-8859-14
* ISO-8859-15
* ISO-8859-16

exit status 2

With this implementation, matched lines in old file and those in new file will be displayed in same manner and users cannot distinguish. Do you have any idea to solve this problem?
(Though I think this p-r's behavior is acceptable)

@astj

astj Sep 12, 2018

Contributor

When --return option specified, matched lines will be returned.

$ go run main.go --check-first -f README.md --pattern ISO --warning-over=1 --return
LOG CRITICAL: 14 warnings, 14 criticals for pattern /ISO/.
[README.md]
* ISO-2022-JP
* ISO-8859-1
* ISO-8859-2
* ISO-8859-3
* ISO-8859-4
* ISO-8859-5
* ISO-8859-6
* ISO-8859-7
* ISO-8859-8
* ISO-8859-10
* ISO-8859-13
* ISO-8859-14
* ISO-8859-15
* ISO-8859-16

exit status 2

With this implementation, matched lines in old file and those in new file will be displayed in same manner and users cannot distinguish. Do you have any idea to solve this problem?
(Though I think this p-r's behavior is acceptable)

This comment has been minimized.

@yuuki

yuuki Sep 12, 2018

Member

That's a good point.
I can add a prefix like [old] and [path/to/file]to displayed lines, but check-log will lost backward compatibility if a user's program parses check-logs's output.

@yuuki

yuuki Sep 12, 2018

Member

That's a good point.
I can add a prefix like [old] and [path/to/file]to displayed lines, but check-log will lost backward compatibility if a user's program parses check-logs's output.

yuuki added some commits Sep 12, 2018

@yuuki

This comment has been minimized.

Show comment
Hide comment
@yuuki
Member

yuuki commented Sep 12, 2018

@astj

astj approved these changes Sep 12, 2018

@yuuki yuuki merged commit ef4b5bd into master Sep 12, 2018

5 checks passed

continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls Coverage increased (+1.4%) to 57.435%
Details

@yuuki yuuki deleted the check-log-trace-rotate branch Sep 12, 2018

@yuuki yuuki referenced this pull request Sep 13, 2018

Merged

Release version 0.22.1 #254

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