mrtgの動作確認 | サーバーエンジニアのスキルアップ日記

サーバーエンジニアのスキルアップ日記

サーバエンジニアがレンタルサーバーを使って試行錯誤しながら各種サービスを動作させ、スキルアップする日々を語ります。

mrtg.cfgの設定がひとまずできたのでmrtgの動作確認をします。

下記サイトの手順を参考に行います。


MRTGによるサーバ監視システムの構築




●mrtgコマンドの実行




(実行結果)

# /usr/bin/mrtg /etc/mrtg/mrtg.conf --logging /var/log/mrtg.log




-----------------------------------------------------------------------

ERROR: Mrtg will most likely not work properly when the environment

variable LANG is set to UTF-8. Please run mrtg in an environment

where this is not the case. Try the following command to start:


env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.conf --logging /var/log/mrtg.log




環境変数を"LANG=C"として実行しなさいとエラーコメントが表示されましたので

その通りに実行します。




# env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --logging /var/log/mrtg.log




何も表示されず、失敗したようです。ログを確認してみます。




$ more /var/log/mrtg.log




Started mrtg with config '/etc/mrtg/mrtg.conf'

ERROR: unable to open config file: /etc/mrtg/mrtg.conf

Started mrtg with config '/etc/mrtg/mrtg.cfg'

ERROR: CFG Error in "maxbytes[localhost_2]", line 80: 0 must be a Number bigger than 0




mrtg.cfgの"maxbytes[localhost_2]"の指定が0になっているようです。




mrtg.cfgを下記のように修正します。




MaxBytes[localhost_2]: 0

     ↓

MaxBytes[localhost_2]: 1250000




●mrtgコマンドの再実行




# env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --logging /var/log/mrtg.log


(実行結果)

2013-02-04 18:58:43, Rateup WARNING: /usr/bin/rateup could not read the primary log file for localhost_1

2013-02-04 18:58:43, Rateup WARNING: /usr/bin/rateup The backup log file for localhost_1 was invalid as well

         :

         :




# env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --logging /var/log/mrtg.log


(実行結果)

2013-02-04 18:59:01, Rateup WARNING: /usr/bin/rateup Can't remove localhost_1.old updating log file

2013-02-04 18:59:01, Rateup WARNING: /usr/bin/rateup Can't remove localhost_2.old updating log file




# env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --logging /var/log/mrtg.log




最初の2回のエラーは問題ないとの事で、3回目に正常に実行できました。




出力ディレクトリを確認すると、ファイルが作成されていました。




(実行結果)




# cd /var/www/mrtg

# ls




favicon.ico localhost_1-week.png localhost_2.old mrtg-m.png

localhost_1-day.png localhost_1-year.png localhost_2-week.png mrtg-r.gif

localhost_1.html localhost_2-day.png localhost_2-year.png mrtg-r.png

localhost_1.log localhost_2.html mrtg-l.gif mrtg-ti.gif

localhost_1-month.png localhost_2.log mrtg-l.png mrtg-ti.png

localhost_1.old localhost_2-month.png mrtg-m.gif



絶対つまずかないLinux超入門 (日経BPパソコンベストムック)/著者不明

¥1,490
Amazon.co.jp