![]() |
◆ | LogWatch |
自宅Webサーバーで24時間運営していると色々な攻撃にさらされ る。そこで各種のログを見て対策を施すことになりますが各種をログを一つひとつ確認して行くのは大変手間の掛かることなので LogWatch と言うソフトを使い各種ログを一括して収集し、メールで管理人の元へ知らせる。 | |
◆ | LogWatchのインストール |
[root@fedora]# dnf -y install logwatch ← 入力 |
|
◆ | LogWatchの設定 |
[root@fedora]# vi /usr/share/logwatch/default.conf/logwatch.conf 途中略 # Default person to mail reports to. Can be a local account or a # complete email address. Variable Output should be set to mail, or # --output mail should be passed on command line to enable mail feature. MailTo = root ← 書き換え(メールの送信先アドレス ) ↓ MailTo = xxx@yyyy.zzz 途中略 # Use archives? If set to 'Yes', the archives of logfiles # (i.e. /var/log/messages.1 or /var/log/messages.1.gz) will # be searched in addition to the /var/log/messages file. # This usually will not do much if your range is set to just # 'Yesterday' or 'Today'... it is probably best used with Range = All. # By default this is now set to Yes. To turn off Archives uncomment this. #Archives = No <--- コメント解除し書き換え(アーカイブログも含める) ↓ Archives = Yes # Range = All # The default time range for the report... # The current choices are All, Today, Yesterday Range = yesterday # The default detail level for the report. # This can either be Low, Med, High or a number. # Low = 0 # Med = 5 # High = 10 Detail = Low <--- 書き換え(ログの詳細度 Low = 低 Med = 中 High = 高) ↓ Detail = Med 以下略 |
|
◆ | ログの送信テスト |
[root@fedora]# logwatch --output mail |
|
メールの受信をしてみる。下記のようなメールが届いたら成功。(送信例なので環境によって違う) | |
################### Logwatch 7.4.3 (04/27/16) #################### Processing Initiated: Sun May 23 15:43:15 2021 Date Range Processed: yesterday ( 2021-May-22 ) Period is day. Detail Level of Output: 5 Type of Output/Format: mail / text Logfiles for Host: papa-net.info ################################################################## --------------------- Kernel Audit Begin ------------------------ 内容省略 ---------------------- Kernel Audit End ------------------------- ------------------------ Cron Begin -------------------------- 内容省略 ------------------------- Cron End --------------------------- --------------------- dhcpd Begin ------------------------ 内容省略 ---------------------- dhcpd End ------------------------- --------------------- Dovecot Begin ------------------------ 内容省略 ---------------------- Dovecot End ------------------------- --------------------- httpd Begin ------------------------ 内容省略 ---------------------- httpd End ------------------------- --------------------- Kernel Begin ------------------------ 内容省略 ---------------------- Kernel End ------------------------- --------------------- LVM Begin ------------------------ 内容省略 ---------------------- LVM End ------------------------- --------------------- pam_unix Begin ------------------------ 内容省略 ---------------------- pam_unix End ------------------------- --------------------- Postfix Begin ------------------------ 内容省略 ---------------------- Postfix End ------------------------- --------------------- Connections (secure-log) Begin ------------------------ 内容省略 ---------------------- Connections (secure-log) End ------------------------- --------------------- Smartd Begin ------------------------ 内容省略 ---------------------- Smartd End ------------------------- --------------------- SSHD Begin ------------------------ 内容省略 ---------------------- SSHD End ------------------------- --------------------- Sudo (secure-log) Begin ------------------------ 内容省略 ---------------------- Sudo (secure-log) End ------------------------- --------------------- Systemd Begin ------------------------ 内容省略 ---------------------- Systemd End ------------------------- --------------------- Disk Space Begin ------------------------ 内容省略 ---------------------- Disk Space End ------------------------- ###################### Logwatch End ######################### |
|
◆ | ログ収集自動実行の確認 |
LogWatch インストール後は、デフォルトで “/etc/cron.daily/” ディレクトリに “0logwatch” というファイルが作成され、毎日自動実行されるような設定になっていて、24時間可動しているサーバーでは 3:06 〜 3:50 の範囲でランダムに実行される設定になっている。 | |