This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.

Please visit our production wiki at https://wiki.gentoo.org

Logcheck

From Gentoo Wiki (test)
Jump to:navigation Jump to:search
This page is a translated version of the page Logcheck and the translation is 100% complete.

이 안내서는 logcheck를 이용하여 시스템 로그를 분석하는 방법을 알려드립니다.

logcheck로 시작하기

배경

logcheck는 시스템 로그를 분석하는 도구인 logsentry의 개선 버전입니다. 게다가 logcheck 는 일반적으로 내장 데이터베이스가 딸려오며, 관심 없는 잡다한 로그 메시지를 걸러냅니다. 이 도구의 일반 개념은 불필요한 내용으로 간주된 메시지를 제외한 모든 메시지에 관심이 있는걸로 간주합니다. logcheck은 주기적으로 관심있는 내용의 요약본을 이메일로 송부합니다.

logcheck 설치

중요
logsentry를 시스템에 설치했다면 제거하는걸 추천합니다. 게다가, 권한 위반과 파일 충돌 문제를 해결하려면 /etc/logcheck를 제거해야 합니다.
root #emerge -c logsentry
root #rm -rf /etc/logcheck

이제 logcheck 설치를 수행할 수 있습니다.

root #emerge --ask app-admin/logcheck

기본 설정

logcheck는 루트 실행을 막기 위해 "logcheck" 사용자를 따로 만듭니다. 실제로 루트 계정으로 실행하는 동작을 막습니다. 로그 분석을 하도록 하려면 logcheck가 읽을 수 있게 해야 합니다. syslog-ng의 예제를 보여드리겠습니다.

Code/etc/syslog-ng/syslog-ng.conf 일부

'"`UNIQ--pre-00000001-QINU`"'

This is a deprecated template. Help us update this template!

이제 설정을 다시 불러온 후 기대한 바대로 동작하는지 확인하십시오.

root #/etc/init.d/syslog-ng 다시 불러오기
root #ls -l /var/log/messages
-rw-r----- 1 root logcheck 1694438 Feb 12 12:18 /var/log/messages

이제 /etc/logcheck/logcheck.conf 에 있는 기본 logcheck 설정을 건드려야 합니다.

Code/etc/logcheck/logcheck.conf 기본 설정

'"`UNIQ--pre-00000005-QINU`"'

This is a deprecated template. Help us update this template!

어떤 로그 파일(/etc/logcheck/logcheck.logfiles)을 검색해야 하는지 logcheck에게 알려야 합니다.

Code/etc/logcheck/logcheck.logfiles 기본 설정

'"`UNIQ--pre-00000008-QINU`"'

This is a deprecated template. Help us update this template!

마지막으로, 크론 잡에서 logcheck를 활성화 하십시오.

root #nano -w /etc/cron.hourly/logcheck.cron
참고
크론에 대한 더 많은 내용은 크론 안내서를 보십시오.

축하합니다! 이제 이메일로 중요한 로그 메시지를 받아 보실 수 있습니다. 예제 메시지는 다음과 같습니다:

Codelogcheck 메시지 예제

'"`UNIQ--pre-0000000B-QINU`"'

This is a deprecated template. Help us update this template!

문제 해결

일반적인 요령

다음과 같이 더 많은 디버깅 정보를 표시하려 한다면 logcheck의 -d 스위치를 사용할 수 있습니다:

root #su -s /bin/bash -c '/usr/sbin/logcheck -d' logcheck
D: [1281318818] Turning debug mode on
D: [1281318818] Sourcing - /etc/logcheck/logcheck.conf
D: [1281318818] Finished getopts c:dhH:l:L:m:opr:RsS:tTuvw
D: [1281318818] Trying to get lockfile: /var/lock/logcheck/logcheck.lock
D: [1281318818] Running lockfile-touch /var/lock/logcheck/logcheck.lock
D: [1281318818] cleanrules: /etc/logcheck/cracking.d/kernel
...
D: [1281318818] cleanrules: /etc/logcheck/violations.d/su
D: [1281318818] cleanrules: /etc/logcheck/violations.d/sudo
...
D: [1281318825] logoutput called with file: /var/log/messages
D: [1281318825] Running /usr/sbin/logtail2 on /var/log/messages
D: [1281318825] Sorting logs
D: [1281318825] Setting the Intro
D: [1281318825] Checking for security alerts
D: [1281318825] greplogoutput: kernel
...
D: [1281318825] greplogoutput: returning 1
D: [1281318825] Checking for security events
...
D: [1281318825] greplogoutput: su
D: [1281318825] greplogoutput: Entries in checked
D: [1281318825] cleanchecked - file: /tmp/logcheck.uIFLqU/violations-ignore/logcheck-su
D: [1281318825] report: cat'ing - Security Events for su
...
D: [1281318835] report: cat'ing - System Events
D: [1281318835] Setting the footer text
D: [1281318835] Sending report: 'localhost 2010-08-09 03:53 Security Events' to root
D: [1281318835] cleanup: Killing lockfile-touch - 17979
D: [1281318835] cleanup: Removing lockfile: /var/lock/logcheck/logcheck.lock
D: [1281318835] cleanup: Removing - /tmp/logcheck.uIFLqU

This page is based on a document formerly found on our main website gentoo.org.
The following people contributed to the original document: phajdan.jr, nightmorph
They are listed here because wiki history does not allow for any external attribution. If you edit the wiki article, please do not add yourself here; your contributions are recorded on each article's associated history page.