Petiti-Linux 시스템 관리자를위한 오픈 소스 로그 분석 도구
Petit은 기업 환경에서 로그 파일을 신속하게 분석하도록 설계된 Cygwin 시스템뿐만 아니라 Unix 계열 용 무료 오픈 소스 명령 줄 기반 로그 분석 도구입니다.
작고 빠르고 사용하기 쉽다는 Unix 철학을 따르도록 고안되었으며 syslog 및 Apache 로그 파일을 포함한 다양한 로그 파일 형식을 검사/지원하는 데 사용할 수 있습니다.
- Supports for log analysis.
- Auto-detects and supports various log file formats( e.g. Syslog, Apache Access, Apache Error, Snort Log, Linux Secure Log, and raw log files).
- Supports for log Hashing .
- Supports command line graphing.
- Supports for word discovery and count with common stop-words within log data.
- Supports for log reduction for easy reading.
- Provides various default and specially made filters.
- Supports fingerprints, useful in identifying and excluding reboot signatures.
- Offers several output options for wide screen terminals and character selection and many more.
이 튜토리얼에서는 Linux에서 Petit 로그 분석 도구를 설치하고 사용하여 다양한 방법으로 시스템 로그에서 유용한 정보를 추출하는 방법을 보여줍니다.
Linux에서 Petit Log Analysis Tool을 설치하고 사용하는 방법
Petit은 아래와 같이 apt 패키지 관리 도구를 사용하여 Debian/Ubuntu 및 그 파생 제품의 기본 저장소에서 설치할 수 있습니다.
$ sudo apt install petit
RHEL/CentOS/Fedora 시스템에서 이와 같이 .rpm 패키지를 다운로드하여 설치하십시오.
# wget http://crunchtools.com/wp-content/files/petit/petit-current.rpm # rpm -i petit-current.rpm
설치가 완료되면 예제와 함께 Petit 기본 사용법을 살펴볼 차례입니다 ..
이것은 간단한 쁘띠 함수입니다. 로그 파일에서 발견 된 행 수를 합산합니다. 출력은 로그에서 발견 된 유사한 줄의 수와 아래에 표시된 그룹의 대략적인 모습으로 구성됩니다.
# petit --hash /var/log/yum.log OR # petit --hash --fingerprint /var/log/messages
2: Mar 18 14:35:54 Installed: libiec61883-1.2.0-4.el6.x86_64 2: Mar 18 15:25:18 Installed: xorg-x11-drv-i740-1.3.4-11.el6.x86_64 1: Dec 16 12:36:23 Installed: 5:mutt-1.5.20-7.20091214hg736b6a.el6.x86_64 1: Dec 16 12:36:22 Installed: mailcap-2.1.31-2.el6.noarch 1: Dec 16 12:40:49 Installed: mailx-12.4-8.el6_6.x86_64 1: Dec 16 12:40:20 Installed: man-1.6f-32.el6.x86_64 1: Dec 16 12:43:33 Installed: sysstat-9.0.4-31.el6.x86_64 1: Dec 16 12:36:22 Installed: tokyocabinet-1.4.33-6.el6.x86_64 1: Dec 16 12:36:22 Installed: urlview-0.9-7.el6.x86_64 1: Dec 16 12:40:19 Installed: xz-4.999.9-0.5.beta.20091007git.el6.x86_64 1: Dec 16 12:40:19 Installed: xz-lzma-compat-4.999.9-0.5.beta.20091007git.el6.x86_64 1: Dec 16 12:43:31 Updated: 2:tar-1.23-15.el6_8.x86_64 1: Dec 16 12:43:31 Updated: procps-3.2.8-36.el6.x86_64 1: Feb 18 12:40:27 Erased: mysql 1: Feb 18 12:40:28 Erased: mysql-libs 1: Feb 18 12:40:22 Installed: MariaDB-client-10.1.21-1.el6.x86_64 1: Feb 18 12:40:12 Installed: MariaDB-common-10.1.21-1.el6.x86_64 1: Feb 18 12:40:10 Installed: MariaDB-compat-10.1.21-1.el6.x86_64 1: Feb 18 12:54:50 Installed: apr-1.3.9-5.el6_2.x86_64 ......
-daemon
옵션을 사용하면 아래 예와 같이 특정 시스템 데몬이 생성 한 행의 기본 보고서를 출력하는 데 도움이됩니다.
# petit --hash --daemon /var/log/syslog
847: vmunix: 48: CRON[#]: 30: dhclient[#]: 26: nm-dispatcher: 14: rtkit-daemon[#]: 6: smartd[#]: 5: ntfs-#g[#]: 4: udisksd[#]: 3: mdm[#]: 2: ag[#]: 2: syslogd 1: cinnamon-killer-daemon: 1: cinnamon-session[#]: 1: pulseaudio[#]:
특정 호스트에 의해 생성 된 모든 행 수를 찾으려면 아래와 같이 -host
플래그를 사용하십시오. 이는 둘 이상의 호스트에 대한 로그 파일을 분석 할 때 유용 할 수 있습니다.
# petit --host /var/log/syslog 999: tecmint
이 기능은 로그 파일에서 질적으로 중요한 단어를 검색하고 표시하는 데 사용됩니다.
# petit --wordcount /var/log/syslog
845: [ 97: [mem 75: ACPI: 64: pci 62: debian-sa# 62: to 51: USB 50: of 49: device 47: && 47: (root) 47: CMD 47: usb 41: systemd# 36: ACPI 32: > 32: driver 32: reserved 31: (comm# 31: -v
이는 아래 예에 표시된 것처럼 분포를 나란히 비교하기 위해 키/값 막대 차트 형식으로 작동합니다.
syslog에서 처음 60 초를 그래프로 표시하려면 다음과 같이 -sgrapg
플래그를 사용하십시오.
# petit --sgraph /var/log/syslog
# # # # # ############################################################ 59 29 58 Start Time: 2017-06-08 09:45:59 Minimum Value: 0 End Time: 2017-06-08 09:46:58 Maximum Value: 1 Duration: 60 seconds Scale: 0.166666666667
이 예는 로그 파일에서 특정 단어 (예 : 아래 명령의 \"dhcp\")를 추적하고 그래프로 표시하는 방법을 보여줍니다.
# cat /var/log/messages | grep error | petit --mgraph
# # # # # # # # # # # # # # # ############################################################ 10 40 09 Start Time: 2017-06-08 10:10:00 Minimum Value: 0 End Time: 2017-06-08 11:09:00 Maximum Value: 2 Duration: 60 minutes Scale: 0.333333333333
또한 로그 파일의 각 항목에 대한 샘플을 표시하려면 다음과 같이 –allsamples 옵션을 사용하십시오.
# petit --hash --allsample /var/log/syslog
중요한 쁘띠 파일 :
- /var/lib/petit/fingerprint_library – used to construct custom fingerprint files.
- /var/lib/petit/fingerprints (aggregate fingerprint files) – used to filter out reboots and other events not considered vital by the system administrator.
- /var/lib/petit/filters/
자세한 정보와 사용 옵션은 이와 같은 petit man 페이지를 참조하십시오.
# man petit OR # petit -h
쁘띠 홈페이지 : http://crunchtools.com/software/petit/
또한 Linux의 로그 모니터링 및 관리에 관한 다음 유용한 가이드를 읽어보십시오.
- 4 Good Open Source Log Monitoring and Management Tools for Linux
- How to Manage System Logs (Configure, Rotate and Import Into Database) in Linux
- How to Setup and Manage Log Rotation Using Logrotate in Linux
- Monitor Server Logs in Real-Time with “Log.io” Tool on Linux
아래 피드백 양식을 통해 질문을 보내거나 Linux 용 유용한 로그 분석 도구에 대한 정보를 공유 할 수 있습니다.