FreeBSD/MRTG の変更点
*&SIZE(15){''MRTG''}; [#gf43237e]
The Multi Router Traffic Grapher (MRTG)はネットワークの負荷を監視するツールです。~
MRTGは現在のネットワークのトラフィックの状態を示すグラフィックイメージを含むHTMLページを生成します。~
[[SNMP>FreeBSD/SNMP]]で取得した値をグラフィカルに表示する為、先に[[SNMP>FreeBSD/SNMP]]をインストールしておく必要があります。~
~
[[サンプル>http://matsui.gotdns.com/users/matsui/mrtg/]]
+[[''環境''>#A]]
+[[''インストール''>#B]]
+[[''設定ファイルmrtg.cfgを修正''>#C]]
+[[''index.htmlを作成''>#D]]
+[[''起動''>#E]]
+[[''起動シェルを作る''>#F]]
**''環境''&aname(A); [#zddae2df]
FreeBSD 6.0~
net-snmpd 5.2.2~
mrtg-2.13.2,1~
~
**''インストール''&aname(B); [#nd2c9ba4]
# cd /usr/ports/net-mgmt/mrtg
# make install
**''設定ファイルmrtg.cfgを修正''&aname(C); [#q8e10382]
■自分の環境では下記のような設定になっております。~
※コミュニティ名や、IPなどは環境によって変更してください。~
# cat /usr/local/etc/mrtg/mrtg.cfg
WorkDir: /home/matsui/public_html/mrtg
Language: eucjp
IconDir: /mrtg/icons/
RunAsDaemon: Yes
#Interval 5
SetEnv[^]: HOST="Vaio"
#-----------------------------------------------------------------
# 閾値を超えた場合のスクリプトの定義
# どのパラメータを対象とする場合も同じスクリプトを利用する
#-----------------------------------------------------------------
ThreshDir: /usr/local/etc/mrtg/bin
ThreshProgI[_]: /usr/local/etc/mrtg/bin/mail_warning.pl
ThreshProgO[_]: /usr/local/etc/mrtg/bin/mail_warning.pl
ThreshProgOKI[_]: /usr/local/etc/mrtg/bin/mail_recovery.pl
ThreshProgOKO[_]: /usr/local/etc/mrtg/bin/mail_recovery.pl
#-----------------------------------------------------------------
# トラフィック状況
#-----------------------------------------------------------------
Target[traffic]: 1:PRIVATE@127.0.0.1:
MaxBytes[traffic]: 1250000
Options[traffic]: growright
Title[traffic]: Traffic
PageTop[traffic]: <H1>rl0 Traffic on WebServer</H1>
#-----------------------------------------------------------------
# 取得したデータをそのまま(差分を取らずに)利用するものから設定する
# グラフのOptionsとしてgaugeを指定
#-----------------------------------------------------------------
Options[_]: growright,gauge
#-----------------------------------------------------------------
# CPUのロードアベレージ x 100
# (グラフ化するのは1分間平均 x 100、および15分平均 x 100)
# ShortLegend[la]の値は全角スペースを指定し、単位なしにする
#-----------------------------------------------------------------
Target[la]: .1.3.6.1.4.1.2021.10.1.5.1&.1.3.6.1.4.1.2021.10.1.5.3:PRIVATE@127.0.0.1
ThreshMaxI[la]: 100
Options[la]: growright,gauge
SetEnv[la]: EMAIL="matsui@ma21.ath.cx"
URL="http://matsui.gotdns.com/users/matsui/mrtg/la.html"
MaxBytes[la]: 100
Title[la]: Load Average
PageTop[la]: <H1> CPU Load Average on WebServer</H1>
YLegend[la]: Load Average
ShortLegend[la]:
LegendI[la]:1分平均
LegendO[la]:15分平均
#-----------------------------------------------------------------
# ディスク使用状況
# (グラフ化するのはAgent側で設定した/var および/home の使用率)
#-----------------------------------------------------------------
Target[df]: .1.3.6.1.4.1.2021.9.1.9.2&.1.3.6.1.4.1.2021.9.1.9.3:PRIVATE@127.0.0.1
ThreshMaxI[df]: 80
SetEnv[df]: EMAIL="matsui@ma21.ath.cx"
URL="http://matsui.gotdns.com/users/matsui/mrtg/df.html"
MaxBytes[df]: 100
Options[df]: growright,gauge
Title[df]: Disk Usage(/var and /home)
PageTop[df]: <H1>Disk Usage(/var and /home) on WebServer</H1>
YLegend[df]: Disk Usage
ShortLegend[df]: %
LegendI[df]:/var
LegendO[df]:/home
#-----------------------------------------------------------------
# ディスク使用状況
# (グラフ化するのはAgent側で設定した/ および/usr の使用率)
#-----------------------------------------------------------------
Target[df1]: .1.3.6.1.4.1.2021.9.1.9.1&.1.3.6.1.4.1.2021.9.1.9.4:PRIVATE@127.0.0.1
ThreshMaxI[df1]: 80
SetEnv[df1]: EMAIL="matsui@ma21.ath.cx"
URL="http://matsui.gotdns.com/users/matsui/mrtg/df.html"
MaxBytes[df1]: 100
Options[df1]: growright,gauge
Title[df1]: Disk Usage(/ and /usr)
PageTop[df1]: <H1>Disk Usage(/ and /usr) on WebServer</H1>
YLegend[df1]: Disk Usage
ShortLegend[df1]: %
LegendI[df1]:/
LegendO[df1]:/usr
#-----------------------------------------------------------------
# ディスク使用状況
# (グラフ化するのはAgent側で設定した/work1 および/work2 の使用率)
#-----------------------------------------------------------------
Target[df2]: .1.3.6.1.4.1.2021.9.1.9.5&.1.3.6.1.4.1.2021.9.1.9.6:PRIVATE@127.0.0.1
ThreshMaxI[df2]: 90
SetEnv[df2]: EMAIL="matsui@ma21.ath.cx"
URL="http://matsui.gotdns.com/users/matsui/mrtg/df.html"
MaxBytes[df2]: 100
Options[df2]: growright,gauge
Title[df2]: Disk Usage(/work1 and /work2)
PageTop[df2]: <H1>Disk Usage(/work1 and /work2) on WebServer</H1>
YLegend[df2]: Disk Usage
ShortLegend[df2]: %
LegendI[df2]:/work1
LegendO[df2]:/work2
#-----------------------------------------------------------------
# メモリ使用状況(グラフ化するのは実メモリおよびスワップの空き領域)
# MaxByteには実験機の総スワップ量を指定
#-----------------------------------------------------------------
Target[Mem]: .1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.4.0:PRIVATE@127.0.0.1
ThreshMinO[mem]: 50
SetEnv[mem]: EMAIL="matsui@ma21.ath.cx"
URL="http://matsui.gotdns.com/users/matsui/mrtg/mem.html"
MaxBytes1[mem]:524224
MaxBytes2[mem]:1020116
Unscaled[mem]: dwmy
Options[mem]: growright,gauge
kilo[mem]: 1024
Title[mem]: Available Memory (real and swap)
PageTop[mem]: <H1>Available Memory(real and swap) on WebServer</H1>
YLegend[mem]: Available Memory
ShortLegend[mem]: Mem Free(Bytes)
LegendI[mem]:物理メモリ[MBytes]
LegendO[mem]:スワップメモリ[MBytes]
Legend1[mem]:実メモリ(MBytes)
Legend2[mem]:スワップメモリ(MBytes)
#-----------------------------------------------------------------
# ディスクI/O状況
# ab0
#-----------------------------------------------------------------
Target[diskion.ad0]: .1.3.6.1.4.1.2021.13.15.1.1.3.1&.1.3.6.1.4.1.2021.13.15.1.1.4.1:PRIVATE@127.0.0.1
MaxBytes[diskion.ad0]: 1000000000
Title[diskion.ad0]: Disk IO Bytes (/dev/ad0)
PageTop[diskion.ad0]: <H1>Disk IO Bytes (/dev/ad0)</H1>
Options[diskion.ad0]: growright, nopercent, noinfo
ShortLegend[diskion.ad0]: bytes
YLegend[diskion.ad0]: Disk R/W (bytes)
Legend1[diskion.ad0]: Read bytes
Legend2[diskion.ad0]: Write bytes
LegendI[diskion.ad0]: Read bytes
LegendO[diskion.ad0]: Write bytes
#-----------------------------------------------------------------
# ディスクI/O回数
# ab0
#-----------------------------------------------------------------
Target[diskio.ad0]: .1.3.6.1.4.1.2021.13.15.1.1.5.1&.1.3.6.1.4.1.2021.13.15.1.1.6.1:PRIVATE@127.0.0.1
MaxBytes[diskio.ad0]: 1000000000
Title[diskio.ad0]: Disk IO Counts (/dev/ad0)
PageTop[diskio.ad0]: <H1>Disk IO Counts (/dev/ad0)</H1>
Options[diskio.ad0]: growright, nopercent, noinfo
ShortLegend[diskio.ad0]: counts
YLegend[diskio.ad0]: Disk R/W (counts)
Legend1[diskio.ad0]: Read counts
Legend2[diskio.ad0]: Write counts
LegendI[diskio.ad0]: Read counts
LegendO[diskio.ad0]: Write counts
#-----------------------------------------------------------------
# ディスクI/O状況
# ab1
#-----------------------------------------------------------------
Target[diskion.ad1]: .1.3.6.1.4.1.2021.13.15.1.1.3.2&.1.3.6.1.4.1.2021.13.15.1.1.4.2:PRIVATE@127.0.0.1
MaxBytes[diskion.ad1]: 1000000000
Title[diskion.ad1]: Disk IO Bytes (/dev/ad1)
PageTop[diskion.ad1]: <H1>Disk IO Bytes (/dev/ad1)</H1>
Options[diskion.ad1]: growright, nopercent, noinfo
ShortLegend[diskion.ad1]: bytes
YLegend[diskion.ad1]: Disk R/W (bytes)
Legend1[diskion.ad1]: Read bytes
Legend2[diskion.ad1]: Write bytes
LegendI[diskion.ad1]: Read bytes
LegendO[diskion.ad1]: Write bytes
#-----------------------------------------------------------------
# ディスクI/O回数
# ab1
#-----------------------------------------------------------------
Target[diskio.ad1]: .1.3.6.1.4.1.2021.13.15.1.1.5.2&.1.3.6.1.4.1.2021.13.15.1.1.6.2:PRIVATE@127.0.0.1
MaxBytes[diskio.ad1]: 1000000000
Title[diskio.ad1]: Disk IO Counts (/dev/ad1)
PageTop[diskio.ad1]: <H1>Disk IO Counts (/dev/ad1)</H1>
Options[diskio.ad1]: growright, nopercent, noinfo
ShortLegend[diskio.ad1]: counts
YLegend[diskio.ad1]: Disk R/W (counts)
Legend1[diskio.ad1]: Read counts
Legend2[diskio.ad1]: Write counts
LegendI[diskio.ad1]: Read counts
LegendO[diskio.ad1]: Write counts
#-----------------------------------------------------------------
# httpdプロセス数の数(グラフ化するのはhttpdプロセス数のみ)
#-----------------------------------------------------------------
Target[httpd]: .1.3.6.1.4.1.2021.2.1.5.4&.1.3.6.1.4.1.2021.2.1.5.4:PRIVATE@127.0.0.1:
ThreshMaxI[httpd]: 20
SetEnv[httpd]: EMAIL="root@192.168.1.1"
URL="http://192.168.1.1/mrtg/httpd.html"
MaxBytes[httpd]: 150
Options[httpd]: growright,gauge
Title[httpd]: Number of httpd
PageTop[httpd]: <H1> Number of httpd on WebServer</H1>
YLegend[httpd]: Number of httpd
ShortLegend[httpd]: httpd
LegendI[httpd]:起動中のhttpd
LegendO[httpd]:起動中のhttpd
**''index.htmlを作成''&aname(D); [#i822eded]
# cd /home/matsui/public_html/
# mkdir mrtg
# cd mrtg
# mkdir icons
# cp /usr/local/share/mrtg/* ./icons/
# /usr/local/bin/indexmaker /usr/local/etc/mrtg/mrtg.cfg > ./index.html
**''起動''&aname(E); [#ad8f297e]
■これで値を取得してグラフを作成してくれます。
# /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg
**''起動シェルを作る''&aname(F); [#v1d2d2d0]
起動シェル「/usr/local/etc/rc.d/mrtg.sh」を作成、内容は下記
#!/bin/sh
/usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg