Kozupon.com    
 
 isoqlogを使ってメールログを取る!


isoqlog と言うメールログ解析ツールを入れた。この解析ツールは、データをHTML化してくれるのでWeb上で観覧できてとても便利。受信ログと送信ログをトータルしてくれたり日々管理が出来る。データをHTML出力をしてる割にはスクリプト系の言語を使わずにプログラムをC言語で書かいるのは少し驚いた。サポートされているログフォーマットは、qmail-multilog, qmail-syslog, sendmail, postfix の4種類で、ここではPostfixフォーマットの/var/log/maillog の解析結果を/usr/local/apache2/htdocs/Isoqlog へ出力する事とした。

インストール環境 )
OS : Nature's Linux1.5 Kernel2.6
マシン : Dell OptiprexGX260


1.ソースをゲットする
まず、ここ から isoqlog-2.2.1.tar.gz(2006年9月現在最新) をゲットする。

[VFS-root@web2 /]# cd /usr/local/src
[VFS-root@web2 src]# wget http://www.enderunix.org/isoqlog/isoqlog-2.2.1.tar.gz
[VFS-root@web2 src]# tar zxvf isoqlog-2.2.1.tar.gz
[VFS-root@web2 src]# chown -R root.root isoqlog-2.2.1


2.コンパイル&リンク
[VFS-root@web2 src]# cd isoqlog-2.2.1
[VFS-root@web2 isoqlog-2.2.1]# ./configure

checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets ${MAKE}... yes
checking for gcc... gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for dirent.h that defines DIR... yes
checking for library containing opendir... none required
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking for unistd.h... (cached) yes
checking for size_t... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking for stdlib.h... (cached) yes
checking for working malloc... yes
checking whether lstat dereferences a symlink specified with a trailing slash... yes
checking whether stat accepts an empty string... no
checking for gethostname... yes
checking for memset... yes
checking for mkdir... yes
checking for strcasecmp... yes
checking for strdup... yes
checking for strerror... yes
checking for strstr... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating isoqlog/Makefile
config.status: creating data/Makefile
config.status: creating data/isoqlog.conf-dist
config.status: creating data/htmltemp/Makefile
config.status: creating data/htmltemp/images/Makefile
config.status: creating data/htmltemp/library/Makefile
config.status: creating data/lang/Makefile
config.status: creating tr/Makefile
config.status: creating isoqlog/config.h
config.status: executing default-1 commands

[VFS-root@web2 isoqlog-2.2.1]# make
Making all in data
make[1]: Entering directory `/usr/local/src/isoqlog-2.2.1/data'
Making all in htmltemp
make[2]: Entering directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp'
Making all in images
make[3]: Entering directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp/images'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp/images'
Making all in library
make[3]: Entering directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp/library'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp/library'
make[3]: Entering directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp'
make[2]: Leaving directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp'
Making all in lang
make[2]: Entering directory `/usr/local/src/isoqlog-2.2.1/data/lang'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/usr/local/src/isoqlog-2.2.1/data/lang'
make[2]: Entering directory `/usr/local/src/isoqlog-2.2.1/data'
make[2]: Nothing to be done for `all-am'.
make[2]: Leaving directory `/usr/local/src/isoqlog-2.2.1/data'
make[1]: Leaving directory `/usr/local/src/isoqlog-2.2.1/data'
Making all in isoqlog
make[1]: Entering directory `/usr/local/src/isoqlog-2.2.1/isoqlog'
cd .. \
&& CONFIG_FILES= CONFIG_HEADERS=isoqlog/config.h \
/bin/sh ./config.status
config.status: creating isoqlog/config.h
config.status: isoqlog/config.h is unchanged
config.status: executing default-1 commands
make all-am
make[2]: Entering directory `/usr/local/src/isoqlog-2.2.1/isoqlog'
source='Store.c' object='Store.o' libtool=no \
depfile='.deps/Store.Po' tmpdepfile='.deps/Store.TPo' \
depmode=gcc3 /bin/sh ../depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f Store.c || echo './'`Store.c
source='Parser.c' object='Parser.o' libtool=no \
depfile='.deps/Parser.Po' tmpdepfile='.deps/Parser.TPo' \
depmode=gcc3 /bin/sh ../depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f Parser.c || echo './'`Parser.c
source='main.c' object='main.o' libtool=no \
depfile='.deps/main.Po' tmpdepfile='.deps/main.TPo' \
depmode=gcc3 /bin/sh ../depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f main.c || echo './'`main.c
source='loadconfig.c' object='loadconfig.o' libtool=no \
depfile='.deps/loadconfig.Po' tmpdepfile='.deps/loadconfig.TPo' \
depmode=gcc3 /bin/sh ../depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f loadconfig.c || echo './'`loadconfig.c
source='LangCfg.c' object='LangCfg.o' libtool=no \
depfile='.deps/LangCfg.Po' tmpdepfile='.deps/LangCfg.TPo' \
depmode=gcc3 /bin/sh ../depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f LangCfg.c || echo './'`LangCfg.c
source='Html.c' object='Html.o' libtool=no \
depfile='.deps/Html.Po' tmpdepfile='.deps/Html.TPo' \
depmode=gcc3 /bin/sh ../depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f Html.c || echo './'`Html.c
source='Dir.c' object='Dir.o' libtool=no \
depfile='.deps/Dir.Po' tmpdepfile='.deps/Dir.TPo' \
depmode=gcc3 /bin/sh ../depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f Dir.c || echo './'`Dir.c
source='Data.c' object='Data.o' libtool=no \
depfile='.deps/Data.Po' tmpdepfile='.deps/Data.TPo' \
depmode=gcc3 /bin/sh ../depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c `test -f Data.c || echo './'`Data.c
gcc -g -O2 -o isoqlog Store.o Parser.o main.o loadconfig.o LangCfg.o Html.o Dir.o Data.o
make[2]: Leaving directory `/usr/local/src/isoqlog-2.2.1/isoqlog'
make[1]: Leaving directory `/usr/local/src/isoqlog-2.2.1/isoqlog'
Making all in tr
make[1]: Entering directory `/usr/local/src/isoqlog-2.2.1/tr'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/usr/local/src/isoqlog-2.2.1/tr'
make[1]: Entering directory `/usr/local/src/isoqlog-2.2.1'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/usr/local/src/isoqlog-2.2.1'

[VFS-root@web2 isoqlog-2.2.1]# make install
Making install in data
make[1]: Entering directory `/usr/local/src/isoqlog-2.2.1/data'
Making install in htmltemp
make[2]: Entering directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp'
Making install in images
make[3]: Entering directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp/images'
make[4]: Entering directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp/images'
make[4]: Nothing to be done for `install-exec-am'.
/bin/sh ../../../mkinstalldirs /usr/local/share/isoqlog/htmltemp/images
mkdir /usr/local/share/isoqlog
mkdir /usr/local/share/isoqlog/htmltemp
mkdir /usr/local/share/isoqlog/htmltemp/images
/usr/bin/install -c -m 644 dot.gif /usr/local/share/isoqlog/htmltemp/images/dot.gif
/usr/bin/install -c -m 644 home.gif /usr/local/share/isoqlog/htmltemp/images/home.gif
/usr/bin/install -c -m 644 isoqlog.gif /usr/local/share/isoqlog/htmltemp/images/isoqlog.gif
/usr/bin/install -c -m 644 pk.gif /usr/local/share/isoqlog/htmltemp/images/pk.gif
/usr/bin/install -c -m 644 up.gif /usr/local/share/isoqlog/htmltemp/images/up.gif
make[4]: Leaving directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp/images'
make[3]: Leaving directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp/images'
Making install in library
make[3]: Entering directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp/library'
make[4]: Entering directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp/library'
make[4]: Nothing to be done for `install-exec-am'.
/bin/sh ../../../mkinstalldirs /usr/local/share/isoqlog/htmltemp/library
mkdir /usr/local/share/isoqlog/htmltemp/library
/usr/bin/install -c -m 644 isoqlog.css /usr/local/share/isoqlog/htmltemp/library/isoqlog.css
make[4]: Leaving directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp/library'
make[3]: Leaving directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp/library'
make[3]: Entering directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp'
make[4]: Entering directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp'
make[4]: Nothing to be done for `install-exec-am'.
/bin/sh ../../mkinstalldirs /usr/local/share/isoqlog/htmltemp
/usr/bin/install -c -m 644 daily.html /usr/local/share/isoqlog/htmltemp/daily.html
/usr/bin/install -c -m 644 domain.html /usr/local/share/isoqlog/htmltemp/domain.html
/usr/bin/install -c -m 644 generaldaily.html /usr/local/share/isoqlog/htmltemp/generaldaily.html
/usr/bin/install -c -m 644 generaldomain.html /usr/local/share/isoqlog/htmltemp/generaldomain.html
/usr/bin/install -c -m 644 generalmonthly.html /usr/local/share/isoqlog/htmltemp/generalmonthly.html
/usr/bin/install -c -m 644 generalyearly.html /usr/local/share/isoqlog/htmltemp/generalyearly.html
/usr/bin/install -c -m 644 index.html /usr/local/share/isoqlog/htmltemp/index.html
/usr/bin/install -c -m 644 monthly.html /usr/local/share/isoqlog/htmltemp/monthly.html
/usr/bin/install -c -m 644 yearly.html /usr/local/share/isoqlog/htmltemp/yearly.html
make[4]: Leaving directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp'
make[3]: Leaving directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp'
make[2]: Leaving directory `/usr/local/src/isoqlog-2.2.1/data/htmltemp'
Making install in lang
make[2]: Entering directory `/usr/local/src/isoqlog-2.2.1/data/lang'
make[3]: Entering directory `/usr/local/src/isoqlog-2.2.1/data/lang'
make[3]: Nothing to be done for `install-exec-am'.
/bin/sh ../../mkinstalldirs /usr/local/share/isoqlog/lang
mkdir /usr/local/share/isoqlog/lang
/usr/bin/install -c -m 644 turkish /usr/local/share/isoqlog/lang/turkish
/usr/bin/install -c -m 644 swedish /usr/local/share/isoqlog/lang/swedish
/usr/bin/install -c -m 644 spanish /usr/local/share/isoqlog/lang/spanish
/usr/bin/install -c -m 644 russian /usr/local/share/isoqlog/lang/russian
/usr/bin/install -c -m 644 portuguese /usr/local/share/isoqlog/lang/portuguese
/usr/bin/install -c -m 644 polish /usr/local/share/isoqlog/lang/polish
/usr/bin/install -c -m 644 dutch /usr/local/share/isoqlog/lang/dutch
/usr/bin/install -c -m 644 english /usr/local/share/isoqlog/lang/english
/usr/bin/install -c -m 644 finnish /usr/local/share/isoqlog/lang/finnish
/usr/bin/install -c -m 644 french /usr/local/share/isoqlog/lang/french
/usr/bin/install -c -m 644 german /usr/local/share/isoqlog/lang/german
/usr/bin/install -c -m 644 italian /usr/local/share/isoqlog/lang/italian
/usr/bin/install -c -m 644 norwegian /usr/local/share/isoqlog/lang/norwegian
/usr/bin/install -c -m 644 czech /usr/local/share/isoqlog/lang/czech
/usr/bin/install -c -m 644 romana /usr/local/share/isoqlog/lang/romana
/usr/bin/install -c -m 644 bulgarian /usr/local/share/isoqlog/lang/bulgarian
/usr/bin/install -c -m 644 danish /usr/local/share/isoqlog/lang/danish
make[3]: Leaving directory `/usr/local/src/isoqlog-2.2.1/data/lang'
make[2]: Leaving directory `/usr/local/src/isoqlog-2.2.1/data/lang'
make[2]: Entering directory `/usr/local/src/isoqlog-2.2.1/data'
make[3]: Entering directory `/usr/local/src/isoqlog-2.2.1/data'
make[3]: Nothing to be done for `install-exec-am'.
/bin/sh ../mkinstalldirs /usr/local/etc
/usr/bin/install -c -m 644 isoqlog.conf-dist /usr/local/etc/isoqlog.conf-dist
/usr/bin/install -c -m 644 isoqlog.domains-dist /usr/local/etc/isoqlog.domains-dist
make[3]: Leaving directory `/usr/local/src/isoqlog-2.2.1/data'
make[2]: Leaving directory `/usr/local/src/isoqlog-2.2.1/data'
make[1]: Leaving directory `/usr/local/src/isoqlog-2.2.1/data'
Making install in isoqlog
make[1]: Entering directory `/usr/local/src/isoqlog-2.2.1/isoqlog'
make[2]: Entering directory `/usr/local/src/isoqlog-2.2.1/isoqlog'
/bin/sh ../mkinstalldirs /usr/local/bin
/usr/bin/install -c isoqlog /usr/local/bin/isoqlog
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/usr/local/src/isoqlog-2.2.1/isoqlog'
make[1]: Leaving directory `/usr/local/src/isoqlog-2.2.1/isoqlog'
Making install in tr
make[1]: Entering directory `/usr/local/src/isoqlog-2.2.1/tr'
make[2]: Entering directory `/usr/local/src/isoqlog-2.2.1/tr'
make[2]: Nothing to be done for `install-exec-am'.
/bin/sh ../mkinstalldirs /usr/local/share/doc/isoqlog/tr
mkdir /usr/local/share/doc/isoqlog
mkdir /usr/local/share/doc/isoqlog/tr
/usr/bin/install -c -m 644 BENIOKU /usr/local/share/doc/isoqlog/tr/BENIOKU
/usr/bin/install -c -m 644 DEGISIKLIKLER /usr/local/share/doc/isoqlog/tr/DEGISIKLIKLER
/usr/bin/install -c -m 644 HABERLER /usr/local/share/doc/isoqlog/tr/HABERLER
/usr/bin/install -c -m 644 KOPYALAMA /usr/local/share/doc/isoqlog/tr/KOPYALAMA
/usr/bin/install -c -m 644 KURULUM /usr/local/share/doc/isoqlog/tr/KURULUM
/usr/bin/install -c -m 644 YAZARLAR /usr/local/share/doc/isoqlog/tr/YAZARLAR
make[2]: Leaving directory `/usr/local/src/isoqlog-2.2.1/tr'
make[1]: Leaving directory `/usr/local/src/isoqlog-2.2.1/tr'
make[1]: Entering directory `/usr/local/src/isoqlog-2.2.1'
make[2]: Entering directory `/usr/local/src/isoqlog-2.2.1'
make[2]: Nothing to be done for `install-exec-am'.
/bin/sh ./mkinstalldirs /usr/local/share/doc/isoqlog
/usr/bin/install -c -m 644 AUTHORS /usr/local/share/doc/isoqlog/AUTHORS
/usr/bin/install -c -m 644 ChangeLog /usr/local/share/doc/isoqlog/ChangeLog
/usr/bin/install -c -m 644 COPYING /usr/local/share/doc/isoqlog/COPYING
/usr/bin/install -c -m 644 EnderUNIX /usr/local/share/doc/isoqlog/EnderUNIX
/usr/bin/install -c -m 644 FAQ /usr/local/share/doc/isoqlog/FAQ
/usr/bin/install -c -m 644 INSTALL /usr/local/share/doc/isoqlog/INSTALL
/usr/bin/install -c -m 644 NEWS /usr/local/share/doc/isoqlog/NEWS
/usr/bin/install -c -m 644 README /usr/local/share/doc/isoqlog/README
/usr/bin/install -c -m 644 README.Turkish /usr/local/share/doc/isoqlog/README.Turkish
/usr/bin/install -c -m 644 TODO /usr/local/share/doc/isoqlog/TODO
make[2]: Leaving directory `/usr/local/src/isoqlog-2.2.1'
make[1]: Leaving directory `/usr/local/src/isoqlog-2.2.1'


3.必要ファイルのコピー
設定ファイルとかをリネームしてコピーする。

[VFS-root@web2 isoqlog-2.2.1]# mkdir /usr/local/apache2/htdocs/Isoqlog
[VFS-root@web2 isoqlog-2.2.1]# cp /usr/local/etc/isoqlog.conf-dist /usr/local/etc/isoqlog.conf
[VFS-root@web2 isoqlog-2.2.1]# cp /usr/local/etc/isoqlog.domains-dist /usr/local/etc/isoqlog.domains
[VFS-root@web2 isoqlog-2.2.1]# cp -r /usr/local/share/isoqlog/htmltemp/{images,library} /usr/local/apache2/htdocs/Isoqlog


4.設定ファイルの編集
[VFS-root@web2 isoqlog-2.2.1]# vi /usr/local/etc/isoqlog.conf
#isoqlog Configuration file

logtype = "postfix"                         # log type qmai-multilog, qmail-syslog, sendmail, postfix
logstore = "/var/log/maillog"                 #

domainsfile = "/usr/local/etc/isoqlog.domains"         #
outputdir = "/usr/local/apache2/htdocs/Isoqlog"  # html output directory
htmldir = "/usr/local/share/isoqlog/htmltemp"
langfile = "/usr/local/share/isoqlog/lang/english"
hostname = "web2.xxxxxxxx.co.jp"

maxsender = 100
maxreceiver = 100
maxtotal = 100
maxbyte = 100

これで設定は、完了。


5.実行してみる
[VFS-root@web2 isoqlog-2.2.1]# /usr/local/bin/isoqlog
Year: 2006 Month: 9
outputdir:/usr/local/apache2/htdocs/Isoqlog
htmldir:/usr/local/share/isoqlog/htmltemp
logtype:postfix
logstore:/var/log/maillog
langfile:/usr/local/share/isoqlog/lang/english
maxsender:100
maxreceiver:100
maxtotal:100
maxbyte:100
hostname: web2.xxxxxxxx.co.jp
Domains domain1.com
Domains domain2.com

/usr/local/apache2/htdocs/Isoqlog このディレクトリにHTMLが出力された。


6.HTMLを観覧する
ブラウザ上から、ログデータを観覧するには以下のURLを入力する。

http://web2.xxxxxxxx.co.jp/Isoqlog/

図1は、メイン画面。

  図1

図2は、generalのリンクをたどるとTotalとかAverageが観覧できる。

  図2

図3は、日付のリンクをたどると、SenderとReceiverの詳細が観覧できる。

  図3


7.九龍で定期的に実行する
Isoqlogは、HTMLを生成して終了してしまうため、定期的に実行してデータを更新してやらなければならない。
したがって、以下のように九龍で定期的に執行してやることが必要である。
[VFS-root@web2 isoqlog-2.2.1]# vi /etc/crontab
省略
0 * * * * /usr/local/bin/isoqlog > /dev/null 2>&1
省略

この例では、一時間に一回00分ちょうどに実行するようになっている。

以上

 


 
 
 



Copyright 2005 Kozupon.com.