MRTG ( Multi Router Traffic Grapher ) はネットワーク負荷監視ツールです。
Fedora Core 5には必要なパッケージは一通り入っているので便利です。
以下、Fedora Core 5でのMRTGのインストールと設定の手順です。
1. インストール
Feodra Core 5のインストールCDには必要なパッケージがすべて入っているので
必要なパッケージをインストールします。
よくわからない場合はすべてのパッケージをインストールすればよいと思います。
2. SNMP
# cd /etc/snmp
既存のsnmpd.confをリネームしてバックアップしておきます。
# cp -p snmpd.conf snmpd.conf.orig
snmpd.confの以下の場所を変更します。
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
↓
#view systemview included .1.3.6.1.2.1.1
#view systemview included .1.3.6.1.2.1.25.1.1
view all included .1 80
access notConfigGroup "" any noauth exact systemview none none
↓
#access notConfigGroup "" any noauth exact systemview none none
access notConfigGroup "" any noauth exact all none none
#disk / 10000
↓
disk / 10000
snmpdをserviceに登録します。
# chkconfig --level 35 snmpd on
snmpdをスタートします。
# service snmpd start
3. MRTG
# cd /etc/mrtg
既存のmrtg.confをリネームしてバックアップしておきます。
# cp mrtg.cfg mrtg.cfg.org
以下のコマンドでmrtg.cfgが作成されます。
# /usr/bin/cfgmaker -out /etc/mrtg/mrtg.cfg --global 'workdir: /var/www/mrtg' --global Language:eucjp public@127.0.0.1
エラーがなければOKです。
mrtg.cfgの以下のコメントをはずします。
# Options[_]: growright, bits
↓
Options[_]: growright, bits
mrtg.cfgに以下を文字コードeuc-jpで追加します。
### CPU Load Average ###
Target[cpu]: .1.3.6.1.4.1.2021.10.1.5.1&.1.3.6.1.4.1.2021.10.1.5.2:public@127.0.0.1
MaxBytes[cpu]: 100
Unscaled[cpu]: dwmy
Options[cpu]: gauge, absolute, growright, noinfo, nopercent
YLegend[cpu]: CPU Load(%)
ShortLegend[cpu]: (%)
LegendI[cpu]: 1分間平均
LegendO[cpu]: 5分間平均
Legend1[cpu]: 1分間平均(%)
Legend2[cpu]: 5分間平均(%)
Title[cpu]: CPU使用率
PageTop[cpu]: <H1> CPU使用率 </H1>
### Memory Free ####
Target[mem]: .1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.4.0:public@127.0.0.1
MaxBytes1[mem]: 1032408
MaxBytes2[mem]: 2031608
Unscaled[mem]: dwmy
Options[mem]: gauge, absolute, growright, noinfo
YLegend[mem]: Mem Free(Bytes)
ShortLegend[mem]: Bytes
kilo[mem]: 1024
kMG[mem]: k,M,G,T,P
LegendI[mem]: Real
LegendO[mem]: Swap
Legend1[mem]: 空き物理メモリ[MBytes]
Legend2[mem]: 空きスワップメモリ[MBytes]
Title[mem]: 空きメモリ量
PageTop[mem]: <H1> 空きメモリ量 </H1>
### Disk Used ####
Target[disk]: .1.3.6.1.4.1.2021.9.1.9.1&.1.3.6.1.4.1.2021.9.1.9.1:public@127.0.0.1
MaxBytes[disk]: 100
Unscaled[disk]: dwmy
Options[disk]: gauge, absolute, growright, nopercent, noinfo
YLegend[disk]: Disk Used(%)
ShortLegend[disk]: (%)
LegendI[disk]: / Disk used
LegendO[disk]: / Disk Used
Legend1[disk]: / Disk used
Legend2[disk]: / Disk used
Title[disk]: ディスク使用率
PageTop[disk]: <H1> ディスク使用率 </H1>
Memoryの
MaxBytes1[mem]: 1032408
MaxBytes2[mem]: 2031608
については free コマンドで調べます。
# free
total used free shared buffers cached
Mem: 1032408 455464 576944 0 29104 295376
-/+ buffers/cache: 130984 901424
Swap: 2031608 0 2031608
MemとSwapがそれぞれMaxBytes1とMaxBytes2にあたります。
mrtgコマンドを3回入力します。1回目と2回目はRateup WARNINGなどとWARNINGが出ると思いますが気にしなくてよいです。3回目は何もメッセージが出ないで終わると思います。
# env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
# env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
# env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
4. HTTPで見る準備
# cd /var/www/mrtg
index.htmlを作成します。
# indexmaker /etc/mrtg/mrtg.cfg > index.html
# cd /etc/httpd/conf
既存のhttpd.confをリネームしてバックアップしておきます。
# cp -p httpd.conf httpd.conf.orig
httpd.confの以下をコメントアウトします。
コメントアウトしないと日本語が文字化けします。
AddDefaultCharset UTF-8
↓
#AddDefaultCharset UTF-8
httpd.confを以下のように編集して、192.168.x.xからしかアクセスできないようにします。
# Order allow,deny
Order deny,allow
# Allow from all
Deny from all
Allow from 127.0.0.1
Allow from 192.168
# cd /etc/httpd/conf.d
既存のmrtg.confをリネームしてバックアップしておきます。
# cp -p mrtg.conf mrtg.conf.orig
mrtg.confを以下のように編集して、192.168.x.xからしかアクセスできないようにします。
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from 192.168
httpdをserviceに登録します。
# chkconfig --level 35 httpd on
httpdをスタートします。
# service httpd start
これで、しばらくしてからブラウザでhttp://(hostname)/mrtg/ とすると、
以下のように。すごい。
更新は/etc/cron.d/mrtgでデフォルトでは5分おきに行われます。
