Postfixログ解析ツール導入(pflogsumm)

最終更新日: 2014.02.19

<<トップページ <<新着情報 <<サイト内検索 <<CentOSで自宅サーバー構築 <<Scientific Linuxで自宅サーバー構築

■概要

Postfixのログ解析ツールであるpflogsummを導入する。
ここでは、毎日自動的に前日分のPostfixログを解析して結果をメールサーバー管理者(postmaster)宛にメール送信するようにする。


■pflogsummインストール

[root@fedora ~]# yum -y install postfix-pflogsumm ← pflogsummインストール
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Excluding Packages in global exclude list
Finished
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for postfix-pflogsumm to pack into transaction set.
postfix-pflogsumm-2.3.3-2 100% |=========================|  15 kB    00:00
---> Package postfix-pflogsumm.i386 2:2.3.3-2 set to be updated
--> Running transaction check
--> Processing Dependency: perl(Date::Calc) for package: postfix-pflogsumm
--> Processing Dependency: perl-Date-Calc for package: postfix-pflogsumm
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for perl-Date-Calc to pack into transaction set.
perl-Date-Calc-5.4-1.2.2. 100% |=========================| 9.8 kB    00:00
---> Package perl-Date-Calc.i386 0:5.4-1.2.2.1 set to be updated
--> Running transaction check
--> Processing Dependency: perl(Bit::Vector) for package: perl-Date-Calc
--> Processing Dependency: perl(Carp::Clan) for package: perl-Date-Calc
--> Processing Dependency: perl-Bit-Vector >= 6.4 for package: perl-Date-Calc
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for perl-Bit-Vector to pack into transaction set.
perl-Bit-Vector-6.4-2.2.2 100% |=========================| 6.9 kB    00:00
---> Package perl-Bit-Vector.i386 0:6.4-2.2.2.1 set to be updated
---> Downloading header for perl-Carp-Clan to pack into transaction set.
perl-Carp-Clan-5.3-1.2.1. 100% |=========================| 3.2 kB    00:00
---> Package perl-Carp-Clan.noarch 0:5.3-1.2.1 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 postfix-pflogsumm       i386       2:2.3.3-2        core               49 k
Installing for dependencies:
 perl-Bit-Vector         i386       6.4-2.2.2.1      core              179 k
 perl-Carp-Clan          noarch     5.3-1.2.1        core               22 k
 perl-Date-Calc          i386       5.4-1.2.2.1      core              270 k

Transaction Summary
=============================================================================
Install      4 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 520 k
Downloading Packages:
(1/4): postfix-pflogsumm- 100% |=========================|  49 kB    00:00
(2/4): perl-Bit-Vector-6. 100% |=========================| 179 kB    00:00
(3/4): perl-Carp-Clan-5.3 100% |=========================|  22 kB    00:00
(4/4): perl-Date-Calc-5.4 100% |=========================| 270 kB    00:00
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: perl-Carp-Clan               ######################### [1/4]
  Installing: perl-Date-Calc               ######################### [2/4]
  Installing: postfix-pflogsumm            ######################### [3/4]
  Installing: perl-Bit-Vector              ######################### [4/4]

Installed: postfix-pflogsumm.i386 2:2.3.3-2
Dependency Installed: perl-Bit-Vector.i386 0:6.4-2.2.2.1 perl-Carp-Clan.noarch 0:5.3-1.2.1 perl-Date-Calc.i386 0:5.4-1.2.2.1
Complete!

■pflogsumm確認

[root@fedora ~]# vi pflogsumm_report ← pflogsumm実行スクリプト作成
#!/bin/bash

MAILLOG=`mktemp`
for log in `ls /var/log/maillog*|sort -r`
do
    cat $log >> $MAILLOG
done
REPORT=`mktemp`
pflogsumm --problems_first --verbose_msg_detail --mailq -d yesterday $MAILLOG > $REPORT
cat $REPORT | mail -s "`head -1 $REPORT` in `uname -n`" postmaster
rm -f $MAILLOG $REPORT

[root@fedora ~]# chmod 700 pflogsumm_report ← pflogsumm実行スクリプトへ実行権限付加

[root@fedora ~]# ./pflogsumm_report ← pflogsumm実行スクリプト実行

以下のようなメールがpostmaster宛に送られてくることを確認
Postfix log summaries for Feb 16

Grand Totals
------------
messages

      4   received
      4   delivered
      0   forwarded
      0   deferred
      0   bounced
      4   rejected (50%)
      0   reject warnings
      0   held
      0   discarded (0%)

  31578   bytes received
  31578   bytes delivered
      2   senders
      2   sending hosts/domains
      2   recipients
      1   recipient hosts/domains


message deferral detail: none

message bounce detail (by relay): none

message reject detail
---------------------
  RCPT
    550 : Recipient address rejected: User unknown in local recipient table; from= to= proto=SMTP helo= (total: 1)
           1   xxxxxxxx.com
    550 : Recipient address rejected: User unknown in local recipient table; from= to= proto=SMTP helo= (total: 1)
           1   62.63.187.136
    554 : Relay access denied; from= to= proto=SMTP helo= (total: 1)
           1   dyxnet.com
    554 : Relay access denied; from= to= proto=SMTP helo= (total: 1)
           1   210.200.18.153

message reject warning detail: none

message hold detail: none

message discard detail: none

smtp delivery failures: none

Warnings: none

Fatal Errors: none

Panics: none

Master daemon messages: none

Per-Hour Traffic Summary
    time          received  delivered   deferred    bounced     rejected
    --------------------------------------------------------------------
    0000-0100           0          0          0          0          0
    0100-0200           0          0          0          0          0
    0200-0300           0          0          0          0          0
    0300-0400           0          0          0          0          0
    0400-0500           2          2          0          0          0
    0500-0600           0          0          0          0          0
    0600-0700           0          0          0          0          0
    0700-0800           0          0          0          0          1
    0800-0900           0          0          0          0          0
    0900-1000           0          0          0          0          1
    1000-1100           0          0          0          0          0
    1100-1200           0          0          0          0          0
    1200-1300           0          0          0          0          0
    1300-1400           0          0          0          0          1
    1400-1500           0          0          0          0          0
    1500-1600           0          0          0          0          0
    1600-1700           2          2          0          0          0
    1700-1800           0          0          0          0          0
    1800-1900           0          0          0          0          0
    1900-2000           0          0          0          0          0
    2000-2100           0          0          0          0          0
    2100-2200           0          0          0          0          1
    2200-2300           0          0          0          0          0
    2300-2400           0          0          0          0          0

Host/Domain Summary: Message Delivery
 sent cnt  bytes   defers   avg dly max dly host/domain
 -------- -------  -------  ------- ------- -----------
      4    31578        0    26.5 s    1.2 m  xxxxxxxx.com

Host/Domain Summary: Messages Received
 msg cnt   bytes   host/domain
 -------- -------  -----------
      2    27078   xxxxxxxx.com
      2     4500   xxxxxxxx.jp

Senders by message count
------------------------
      2   root@xxxxxxxx.com
      2   apache@xxxxxxxx.jp

Recipients by message count
---------------------------
      2   root@xxxxxxxx.com
      2   webmaster@xxxxxxxx.com

Senders by message size
-----------------------
  27078   root@xxxxxxxx.com
   4500   apache@xxxxxxxx.jp

Recipients by message size
--------------------------
  16517   webmaster@xxxxxxxx.com
  15061   root@xxxxxxxx.com

Current Mail Queue
------------------
Mail queue is empty

■pflogsumm定期自動実行設定

[root@fedora ~]# mv pflogsumm_report /etc/cron.daily/ ← pflogsumm実行スクリプトを毎日自動実行されるディレクトリへ移動




▲このページのトップへ戻る

LPIロゴ Copyright© 2004-2017 fallenangels, All rights reserved.
ご自由にリンクしてください(連絡は不要です)
本ページへのご意見・ご要望、誤字・脱字・リンク切れ等のご連絡はこちらからお願いします