MRTG - 監視ツール

トップ > チップス > MRTG - 監視ツール
2012-02-13, mrtg

/tips/linux/mrtg SNMPとMRTGを使ってネットワーク使用量、CPU使用率、空きメモリ、ディスク使用率をモニタリングする方法。文章中のホスト名(example.com)は適宜、設定を行うホスト名に読み替えて下さい。

まずは必要なパッケージの導入。 :# yum -y install net-snmp :# yum -y install mrtg

/etc/snmp/snmpd.confを編集(意味が分からない・・・) :#com2sec notConfigUser default public :com2sec local localhost private :com2sec mynetwork example.com public

:#group notConfigGroup v1 notConfigUser :#group notConfigGroup v2c notConfigUser :group mygroup v1 mynetwork :group mygroup v1c mynetwork

:#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 mygroup "" any noauth exact all none none :access mygroup "" any noauth exact all all none

:#disk / 10000 :disk / 10000

snmpデーモンを起動する。 :# service snmpd start :# chkconfig snmpd on

MRTGの設定ファイルを生成する。 :# cfgmaker public@example.com > /etc/mrtg/mrtg.cfg

生成された/etc/mrtg/mrtg.cfgを編集する。ワークディレクトリの設定をコメントアウトし、CPU使用率、空きメモリ、ディスク使用率もチェックするために以下の記述を追加(これも意味が分からない・・・)。 :WorkDir: /var/www/mrtg

:### 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@example.com :MaxBytes[cpu]: 100 :Unscaled[cpu]: dwmy :Options[cpu]: gauge, absolute, growright, noinfo, nopercent :YLegend[cpu]: CPU Load(%) :ShortLegend[cpu]: (%) :LegendI[cpu]: average 1 :LegendO[cpu]: average 5 :Legend1[cpu]: average 1(%) :Legend2[cpu]: average 5(%) :Title[cpu]: usage of cpu :PageTop[cpu]:

usage of cpu

: : :### 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@example.com :MaxBytes1[mem]: 1033860 :MaxBytes2[mem]: 2096472 :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]: Free Memory[MBytes] :Legend2[mem]: Free Swap Memory[MBytes] :Title[mem]: free memory :PageTop[mem]:

free memory

: : :### 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@example.com :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]: usage of disk :PageTop[disk]:

usage of disk

※メモリ内の「MaxBytes1[mem]、MaxBytes2[mem]」の値は利用する環境に応じて書き換える必要があります。メモリ量のを調べるには「free」コマンドを利用します。

以下のコマンドを何回か実行してみる(最初は警告が出るのが正しい動作)。自動実行は既に登録されているっぽい。 :# export LANG=C :# mrtg /etc/mrtg/mrtg.cfg

httpdでバーチャルホストを使っている場合は、任意の場所に以下のエイリアスを登録する。 :Alias /mrtg "/var/www/mrtg"

インデックスファイルを生成する。 :# indexmaker /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html

参考:{link:http://fedorasrv.com/mrtg.shtml}

この記事は役に立ちましたか?