自宅サーバー ≫ Linux Server ≫ CentOS 7 ≫ ログを見る(LogWatch)

 
LogWatch
自宅Webサーバーで24時間運営していると色々な攻撃にさらされ る。そこで各種のログを見て対策を施すことになりますが各種をログを一つひとつ確認して行くのは大変手間の掛かることなので LogWatch と言うソフトを使い各種ログを一括して収集し、メールで管理人の元へ知らせる。
LogWatchのインストール
 
 
[root@fedora]# yum -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

 # 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.0 (03/01/11) ####################
        Processing Initiated: Sun Jan 17 13:52:13 2018
        Date Range Processed: yesterday
                              ( 2018-Jan-16 )
                              Period is day.
        Detail Level of Output: 5
        Type of Output/Format: mail / text
        Logfiles for Host: papa-net-server
  ###############################################################

 ----------------------
Clamav Begin -------------------------

 ***************
  ****************
    ********************************************************

 -----------------------
Clamav End --------------------------

 ------------------------
Cron Begin --------------------------

 **********
  *************

 -------------------------
Cron End ---------------------------

 ----------------------
Dovecot Begin -------------------------

 *********************************
  ****************
    ************

 -----------------------
Dovecot End --------------------------

 ------------------------
httpd Begin --------------------------

 *****************************************
   ************
     *********************

 -------------------------
httpd End ---------------------------

 -----------------------
pam_unix Begin ------------------------

 *******************
   ***************************

 ******************
   **********************

 ------------------------
pam_unix End -------------------------

 ------------------------
Postfix Begin -------------------------

 ******
Summary *************************************
 ******************************
 ******************************

 -------------------------
Postfix End --------------------------
 
 途中略

 ###################### Logwatch End #########################

 
ログ収集自動実行の確認
LogWatch インストール後は、デフォルトで “/etc/cron.daily/” ディレクトリに “0logwatch” というファイルが作成され、毎日自動実行されるような設定になっていて、24時間可動しているサーバーでは 3:06 〜 3:50 の範囲でランダムに実行される設定になっている。

戻る