たまには技術ネタを ( ^ω^)おっ おっ おっ
Sendmail のログを解析してくれるフリーソフトです。
http://www.klake.org/sma/
開発やめちゃったみたいですけど(´・ω・`)
mailstats(1) コマンドというものもあるのだけど、合計値だけしか出ないとかちょっと情報が少ないのでもう少し情報が欲しかったので試してみました。
今回は、Solaris9(sparc)の環境でインスコしました。
BGMはYUKIの「長い夢」です。(でもそんなの関係ねぇ!)
あと、バージョン1.3.2 で試してしまったけど、1.4 も使えるようなのでそっちのほうがいいかも。
インストールで参考にさせていただいたのはこちらのページです。
いろいろ長くなったので続きは追記に移動。
% gtar zxvf sma-1.3.2.tar.gz
% cd sma-1.3.2.tar.gz
% cp -p conf.h conf.h.org
% vi conf.h
% diff conf.h.org conf.h
13c13
< #define DEFAULT_CONF "./sma.conf"
---
> #define DEFAULT_CONF "/usr/local/etc/sma.conf"
% gmake
% su
# gmake -n install
./install-sh sma /usr/local/bin
./install-sh sma.8 /usr/local/man/man8
(一応ね(笑))
# gmake install
./install-sh sma /usr/local/bin
./install-sh sma.8 /usr/local/man/man8
# cp sma.conf /usr/local/etc/
# cd /usr/local/etc/
# cp -p sma.conf sma.conf.org
# vi sma.conf
# diff sma.conf.org sma.conf
27c27
< #HostName myhost.com
---
> HostName example.example.com(適宜)
33c33
< #OutFile /home/jt/report.html
---
> OutFile /usr/local/etc/sma_report.html
# /usr/local/bin/sma /var/log/syslog
#(解析終了)
デフォルトで読み込むファイルは /var/log/maillog のようなのでその場合は /varlog/syslog 部分は省略可です。
特に指定したい場合のみ。
参考までに help
# /usr/local/bin/sma -h
SMA version 1.3.2
usage: /usr/local/bin/sma [OPTIONS] [files...]
OPTIONS are
-a set the output format as ascii
-b
-c show copyright information and exit
-C
-D
-d print only the domain portion of email addresses
-f
-F do not use default configuration file even if it exists
-h print this text and exit
-H
-i print ASCII report as HTML comment (requires -w or -O html)
-L
-n do not print the time distribution
-o
-O
-p print current configuration to stdout
-s sort by tranfers
-q be quiet (no error messages)
-v show debugging information
-l
-r
-t
-w set the output format as html
files log files
これで /usr/local/etc/sma_report.html に html が生成されます。
自動化する場合は、ここを他の場所にしたり、cron とかに登録するとよいでしょう。
(`□´) 以上である!(爆)
解析結果には、
* General information
* Top envelope pairs
* Top envelope senders
* Top envelope recipients
* Top relay pairs
* Top relay addresses, sender
* Top relay addresses, recipient
* Top status messages
* Top ruleset rejections
* Message distribution
Inbound messages per day
Outbound messages per day
Inbound messages per hour
Outbound messages per hour
といった項目が表示されます。
スパムとかエラーメールしか飛んでこないようなサーバで試してしまったのであまり結果がおもしろくなかった。
とりあえずうまくいったので、他OSのメールサーバにでも仕掛けてみます。
追記:
FreeBSD で ports があったのでインスコして動かしてみました。
まともなメールサーバだとログが多いので、結構処理に時間がかかるのと処理中CPUほぼ食い尽くしたり・・・
こりゃ別サーバに動かして解析したほうが賢いかもしれませぬ。
#CPUショボいサーバではやりたくない・・・(笑)
