MRTG のインストール

MRTGとは

ネットワークの回線負荷や、サーバのCPU利用率などを、モニタリングするソフトウェア。SNMPマネージャである。

参考サイト

ファイルのダウンロード

MRTG本家サイト より、Unix版をダウンロードする。2005年6月25日時点では、mrtg-2.12.2.tar.gz が最新であった。

インストール

アーカイブを展開して、configure を実行する。VFライブラリを、リンク用にフラグへ指定しておく。

[bokupi@pokota mrtg-2.12.2]$ export LDFLAGS=-lVFlib2
[bokupi@pokota mrtg-2.12.2]$ ./configure --prefix=/usr/local/mrtg-2
checking for gcc... gcc
checking for C compiler default output file name... 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 gcc option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -E
checking whether make sets $(MAKE)... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking for perl... /usr/local/bin/perl
checking for groff... /usr/bin/groff
checking for egrep... grep -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 for inttypes.h... (cached) yes
checking for unsigned long long... yes
checking for long long... yes
checking for strtoll... yes
checking for printf long long format specifier... %lld
checking for pow in -lm... yes
checking for gdImageGif in -lgd... no
checking for gdImagePng in -lgd... yes
checking for gdImagePng_jpg in -lgd... no
checking for gdImagePng_jpg_ft in -lgd... no
checking for gdImageGd in -lgd... yes
checking gd.h usability... yes
checking gd.h presence... yes
checking for gd.h... yes
checking the weather... (cached) it's fine
checking if we can use GCC-specific compiler options... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
ordering CD from http://people.ee.ethz.ch/~oetiker/wish .... just kidding ;-)

----------------------------------------------------------------
Config is DONE!

Type 'make' to compile the software

       ... that wishlist mentioned above does really exist. So if
you feel like showing your appreciation for MRTG, this is the
place to go. I just love CDs and DVDs

                            -- Tobi Oetiker <oetiker@ee.ethz.ch>
----------------------------------------------------------------

make を実行する。

[bokupi@pokota mrtg-2.12.2]$ make
LD_RUN_PATH= gcc bin/rateup.o -o bin/rateup -lVFlib2  -Wl,-Bstatic -lgd -lpng -l
z -Wl,-Bdynamic  -lm
/usr/local/bin/perl -0777 -p -i~ -e 's@^#!\s*/\S*perl@#! /usr/local/bin/perl@' .
/bin/cfgmaker ./bin/indexmaker ./bin/mrtg
/usr/local/bin/perl -0777 -p -i~ -e 's@GRAPHFMT="...";@GRAPHFMT="png";@' ./bin/m
rtg ./bin/indexmaker

もし、LDFLAGS を指定しないと、下記のようにリンクエラーが発生する。

[root@pokota mrtg-2.12.2]# make
LD_RUN_PATH= gcc bin/rateup.o -o bin/rateup   -Wl,-Bstatic -lgd -lpng -lz -Wl,-B
dynamic  -lm
/usr/lib/libgd.a(gd.o): In function `gdImageKanjiChar':
gd.o(.text+0x1448): undefined reference to `VF_Init'
gd.o(.text+0x146e): undefined reference to `VF_OpenFont'
gd.o(.text+0x14de): undefined reference to `VF_GetBitmap'
gd.o(.text+0x1590): undefined reference to `VF_CloseFont'
gd.o(.text+0x1595): undefined reference to `VF_Deinit'
/usr/lib/libgd.a(gd.o): In function `gdImageKanjiCharUp':
gd.o(.text+0x16b8): undefined reference to `VF_Init'
gd.o(.text+0x16de): undefined reference to `VF_OpenFont'
gd.o(.text+0x174e): undefined reference to `VF_GetBitmap'
gd.o(.text+0x180f): undefined reference to `VF_CloseFont'
gd.o(.text+0x1814): undefined reference to `VF_Deinit'
collect2: ld returned 1 exit status
make: *** [bin/rateup] エラー 1

インストールを実行する。

[root@pokota mrtg-2.12.2]# make install
/bin/sh ./mkinstalldirs /usr/local/mrtg-2/bin
mkdir /usr/local/mrtg-2
mkdir /usr/local/mrtg-2/bin
for x in ./bin/mrtg ./bin/cfgmaker ./bin/indexmaker; do \
  /usr/bin/install -c -m 755 $x /usr/local/mrtg-2/bin; done
for x in bin/rateup; do \
  /usr/bin/install -c -m 755 $x /usr/local/mrtg-2/bin; done
/bin/sh ./mkinstalldirs /usr/local/mrtg-2/lib/mrtg2/Pod
mkdir /usr/local/mrtg-2/lib
mkdir /usr/local/mrtg-2/lib/mrtg2
mkdir /usr/local/mrtg-2/lib/mrtg2/Pod
for x in ./lib/mrtg2/*.pm; do \
  /usr/bin/install -c -m 644 $x /usr/local/mrtg-2/lib/mrtg2; done
for x in ./lib/mrtg2/Pod/*.pm; do \
  /usr/bin/install -c -m 644 $x /usr/local/mrtg-2/lib/mrtg2/Pod; done
/bin/sh ./mkinstalldirs /usr/local/mrtg-2/share/mrtg2/icons
mkdir /usr/local/mrtg-2/share
mkdir /usr/local/mrtg-2/share/mrtg2
mkdir /usr/local/mrtg-2/share/mrtg2/icons
for x in ./images/*.gif ./images/*.png; do \
  /usr/bin/install -c -m 644 $x /usr/local/mrtg-2/share/mrtg2/icons; done
/bin/sh ./mkinstalldirs /usr/local/mrtg-2/share/doc/mrtg2
mkdir /usr/local/mrtg-2/share/doc
mkdir /usr/local/mrtg-2/share/doc/mrtg2
(cd .; for x in COPYING COPYRIGHT README CHANGES THANKS doc/*.pod doc/*.html doc
/*.wml doc/*.txt doc/*.png; do \
  /usr/bin/install -c -m 644 $x /usr/local/mrtg-2/share/doc/mrtg2; done)
/bin/sh ./mkinstalldirs /usr/local/mrtg-2/man/man1
mkdir /usr/local/mrtg-2/man
mkdir /usr/local/mrtg-2/man/man1
for x in ./doc/*.1; do \
  /usr/bin/install -c -m 644 $x /usr/local/mrtg-2/man/man1; done

設定

トラフィック帯域の監視

設定ファイルを作成する。cfgmaker コマンドを使って、テンプレートを作成する。

[root@pokota conf]# /usr/local/mrtg-2/bin/cfgmaker private@localhost > /usr/loca
l/mrtg-2/conf/traffic.cfg
--base: Get Device Info on private@localhost:
--base: Vendor Id:
--base: Populating confcache
--coca: populate confcache private@localhost:
--coca: store in confcache private@localhost_ Descr lo --> 1
--coca: store in confcache private@localhost_ Descr dummy0 --> 2
--coca: store in confcache private@localhost_ Descr bond0 --> 3
--coca: store in confcache private@localhost_ Descr eql --> 4
--coca: store in confcache private@localhost_ Descr eth0 --> 5
--coca: store in confcache private@localhost_ Type 24 --> 1
--coca: store in confcache private@localhost_ Type 6 --> 2
--coca: store in confcache private@localhost_ Type 6 --> 3 (duplicate)
--coca: store in confcache private@localhost_ Type 28 --> 4
--coca: store in confcache private@localhost_ Type 6 --> 5 (duplicate)
--coca: store in confcache private@localhost_ Ip 127.0.0.1 --> 1
--coca: store in confcache private@localhost_ Ip 192.168.0.3 --> 5
--coca: store in confcache private@localhost_ Eth  --> 1
--coca: store in confcache private@localhost_ Eth  --> 2 (duplicate)
--coca: store in confcache private@localhost_ Eth  --> 3 (duplicate)
--coca: store in confcache private@localhost_ Eth  --> 4 (duplicate)
--coca: store in confcache private@localhost_ Eth 00-02-b3-b8-b2-f9 --> 5
--base: Get Interface Info
--base: Walking ifIndex
--base: Walking ifType
--base: Walking ifAdminStatus
--base: Walking ifOperStatus
--base: Walking ifMtu
--base: Walking ifSpeed

設定ファイル traffic.cfg のWorkDir を、適宜変更する。また、日本語出力のために、Language 指定を追加する。

# Created by
# /usr/local/mrtg-2/bin/cfgmaker private@localhost


### Global Config Options

#  for UNIX
WorkDir: /home/httpd/status

#  or for NT
# WorkDir: c:\mrtgdata

### Global Defaults

#  to get bits instead of bytes and graphs growing to the right
Options[_]: growright, bits

Language: eucjp
(以下略)

今回は、httpd 配下に status というディレクトリを作成し、そこを指定した。この設定ファイルを指定して、mrtg を起動する。

[root@pokota mrtg-2]# ./bin/mrtg ./conf/traffic.cfg
Rateup WARNING: /usr/local/mrtg-2/bin/rateup could not read the primary log file
 for localhost_5
Rateup WARNING: /usr/local/mrtg-2/bin/rateup The backup log file for localhost_5
 was invalid as well
Rateup WARNING: /usr/local/mrtg-2/bin/rateup Can't remove localhost_5.old updati
ng log file
Rateup WARNING: /usr/local/mrtg-2/bin/rateup Can't rename localhost_5.log to loc
alhost_5.old updating log file
[root@pokota mrtg-2]# ./bin/mrtg ./conf/traffic.cfg
Rateup WARNING: /usr/local/mrtg-2/bin/rateup Can't remove localhost_5.old updati
ng log file
[root@pokota mrtg-2]# ./bin/mrtg ./conf/traffic.cfg
[root@pokota mrtg-2]# 

3回起動すると、警告が表示されなくなる。これは、過去ログがないために表示されるもので、正常である。

その他の監視

CPU使用率、メモリ使用率、ディスク使用率の監視については、別の機会に行なう。

cron に登録

これらの監視は、当然連続的に行なわなくては意味がないので、cron に登録する。時間は5分置きにした。下記は、/etc/crontab 中の追加部分である。

0,5,10,15,20,25,30,35,40,45,50,55 * * * * root /usr/local/mrtg-2/bin/mrtg /usr/l
ocal/mrtg-2/conf/traffic.cfg

その後は、設定ファイルに指定した WorkDir に相当する場所を、ブラウザで閲覧する。監視の内容が表示されればOK。

omoshiro-joho.com の通信負荷状況


履歴


トップ   編集 凍結解除 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2005-07-03 (日) 17:47:05