CentOS 5.2 x86の環境でサーバを運営しているけれど、毎日サーバから送られている logwatch の postfix のレポートが、次のように分かりくなっていて困った。どうやら、このサーバからメールが送られた分のログがレポートしてでているっぽい。
-------------------- postfix Begin ------------------------
7565212 bytes transferred
1428 messages sent
1428 messages removed from queue
Connections lost:
Connection lost while CONNECT : 151 Time(s)
Connection lost while EHLO : 1 Time(s)
Connection lost while RCPT : 8 Time(s)
Connection lost while UNKNOWN : 2 Time(s)
Unrecognized warning:
non-SMTP command from 122-116-113-159.HINET-IP.hinet.net[122.116.113.159]: GET http://www.scanproxy.com:80/p-25.html HTTP/1.0 : 1 Time(s)
**Unmatched Entries**
D8BF616482D2: to=, relay=XXX[XXX]:25, delay=0.1, delays=0.06/0.01/0.02/0.02, dsn=2.0.0, status=sent (250 ok XXX qp 11493)
... 以下続く
どうしたらものかなと調べてみると、postfix-logwatch というものがあってこれをインストールするときれいにレポートを整形してくれるようなのでさっそくインストールしてみた。
RPM がなかったので、さくっと次のような SPEC ファイルを書いてみた。
%define prefix_logwatch /etc/logwatch
%define scriptdir_logwatch %{prefix_logwatch}/scripts/services
%define confdir_logwatch %{prefix_logwatch}/conf/services
%define program_logwatch postfix
Summary: postfix logwatch utility
Name: postfix-logwatch
Version: 1.37.06
Release: 1%{?dist}
Group: Utilities/System
License: GPL
URL: http://www.mikecappella.com/logwatch/
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires: logwatch
BuildArch: noarch
Source0: http://www.mikecappella.com/logwatch/release/%{name}-%{version}.tgz
%description
The postfix-logwatch utilities are postfix log analyzers that produce summaries, reports a
nd statistics regarding the operation of postfix. Either utility can be used as a standalo
ne program, or as a filter module for the open source logwatch utility.
%prep
%setup -q
%build
# removes taint mode (-T) to run under logwatch
sed -i -e '1c#!/usr/bin/perl' %{name}
%install
rm -fr %{buildroot}
install -d -m 0755 %{buildroot}%{scriptdir_logwatch} %{buildroot}%{confdir_logwatch}
install -m 0644 %{name} %{buildroot}%{scriptdir_logwatch}/%{program_logwatch}
install -m 0644 %{name}.conf %{buildroot}%{confdir_logwatch}/%{program_logwatch}.conf
%clean
rm -fr %{buildroot}
%files
%defattr(-, root, root, -)
%{scriptdir_logwatch}/%{program_logwatch}
%{confdir_logwatch}/%{program_logwatch}.conf
%changelog
* Tue Sep 30 2008 - 1.37.06
- Initial package
この postfix-logwatch パッケージをインストールしたあと、logwatch の postfix のレポートが次のようにかなり見やすくなった!
--------------------- Postfix Begin ------------------------
3.603M Bytes accepted 3,777,846
4.396M Bytes sent via SMTP 4,609,837
1.524M Bytes delivered 1,598,361
======== ==================================================
1932 Accepted 99.95%
1 Rejected 0.05%
-------- --------------------------------------------------
1933 Total 100.00%
======== ==================================================
1 5xx Reject relay denied 100.00%
-------- --------------------------------------------------
1 Total 5xx Rejects 100.00%
======== ==================================================
2220 Connections
145 Connections lost (inbound)
2220 Disconnections
1932 Removed from queue
966 Delivered
1968 Sent via SMTP
たしか、Fedora Core だとこんなレポートが最初から出ていたのに CentOS だと postfix-logwatch を使う必要がありそう。
ついでにこのパッケージを扱う puppet module も書いてばっちりです!
class logwatch {
package { [ "logwatch", "postfix-logwatch" ] : }
}
Tags: linux logwatch