公式サイト
MRTG.JP - MRTG Official Japanese site
MRTG - Tobi Oetiker's MRTG - The Multi Router Traffic Grapher
MRTGインストール
Windowsの場合
Perl(ActivePerl)が必要
ActivePerlのダウンロードは下記のURLから
http://www.activestate.com/
TOPページ → DEVELOPERS → Downloads
ActivePerl → DOWNLOADをクリック
MRTGのモジュールを入手し、任意のフォルダに展開する
CentOSの場合
yumでパッケージを入手する
MRTGを動かすのに 必要なライブラリ | gcc perl gd libpng zlib |
MRTG | mrtg |
WEBサーバ(表示用) | httpd |
SNMPサービス(テスト用) | net-snmp net-snmp-utils |
gd:画像生成用ライブラリ
zlib:データ圧縮ライブラリ
libpng:PNG形式の画像用ライブラリ
WEBサーバ
設定ファイル
新規作成
cfgmaker --ifref=descr --ifdesc=descr public@192.168.0.101 > /etc/mrtg/mrtg.cfg
mrtg.cfg 編集
WorkDirを指定
### Global Config Options # for UNIX WorkDir: /var/www/mrtg
INDEXページを作成
indexmaker --columns=1 /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html
MRTG起動
env LANG=ja_JP.EUC_JP /usr/bin/mrtg /etc/mrtg/mrtg.cfg
Webサーバの設定
Allow from にアクセスを許可するIPアドレスを記載
例)192.168.0.0/24 を追加
<Location /mrtg> Order deny,allow Deny from all Allow from 127.0.0.1 192.168.0.0/24 Allow from ::1 # Allow from .example.com </Location>
httpdを再起動
service httpd restart
ブラウザで開く
http://192.168.0.101/mrtg/
テスト
Linuxから情報を取得する
以下のパッケージをインストールしておく
snmpd
net-snmp
net-snmp-utils
mrtg.cfg
# Created by # /usr/bin/cfgmaker --ifref=descr --ifdesc=descr public@192.168.0.101 ### Global Config Options # for UNIX WorkDir: /var/www/mrtg # or for NT # WorkDir: c:\mrtgdata ### Global Defaults # to get bits instead of bytes and graphs growing to the right # Options[_]: growright, bits EnableIPv6: no ###################################################################### # System: enterprise.localdomain # Description: Linux enterprise.localdomain 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 # Contact: Root <root@localhost> (configure /etc/snmp/snmp.local.conf) # Location: Unknown (edit /etc/snmp/snmpd.conf) ###################################################################### ### Interface 1 >> Descr: 'lo' | Name: 'lo' | Ip: '127.0.0.1' | Eth: '' ### ### The following interface is commented out because: ### * it is a Software Loopback interface # # Target[192.168.0.101_lo]: \lo:public@192.168.0.101: # SetEnv[192.168.0.101_lo]: MRTG_INT_IP="127.0.0.1" MRTG_INT_DESCR="lo" # MaxBytes[192.168.0.101_lo]: 1250000 # Title[192.168.0.101_lo]: lo -- enterprise.localdomain # PageTop[192.168.0.101_lo]: <h1>lo -- enterprise.localdomain</h1> # <div id="sysdetails"> # <table> # <tr> # <td>System:</td> # <td>enterprise.localdomain in Unknown (edit /etc/snmp/snmpd.conf)</td> # </tr> # <tr> # <td>Maintainer:</td> # <td>Root <root@localhost> (configure /etc/snmp/snmp.local.conf)</td> # </tr> # <tr> # <td>Description:</td> # <td>lo </td> # </tr> # <tr> # <td>ifType:</td> # <td>softwareLoopback (24)</td> # </tr> # <tr> # <td>ifName:</td> # <td>lo</td> # </tr> # <tr> # <td>Max Speed:</td> # <td>1250.0 kBytes/s</td> # </tr> # <tr> # <td>Ip:</td> # <td>127.0.0.1 (localhost)</td> # </tr> # </table> # </div> ### Interface 2 >> Descr: 'eth0' | Name: 'eth0' | Ip: '192.168.0.101' | Eth: '00-0c-29-ef-33-28' ### Target[192.168.0.101_eth0]: \eth0:public@192.168.0.101: SetEnv[192.168.0.101_eth0]: MRTG_INT_IP="192.168.0.101" MRTG_INT_DESCR="eth0" MaxBytes[192.168.0.101_eth0]: 125000000 Title[192.168.0.101_eth0]: eth0 -- enterprise.localdomain PageTop[192.168.0.101_eth0]: <h1>eth0 -- enterprise.localdomain</h1> <div id="sysdetails"> <table> <tr> <td>System:</td> <td>enterprise.localdomain in Unknown (edit /etc/snmp/snmpd.conf)</td> </tr> <tr> <td>Maintainer:</td> <td>Root <root@localhost> (configure /etc/snmp/snmp.local.conf)</td> </tr> <tr> <td>Description:</td> <td>eth0 </td> </tr> <tr> <td>ifType:</td> <td>ethernetCsmacd (6)</td> </tr> <tr> <td>ifName:</td> <td>eth0</td> </tr> <tr> <td>Max Speed:</td> <td>125.0 MBytes/s</td> </tr> <tr> <td>Ip:</td> <td>192.168.0.101 (enterprise)</td> </tr> </table> </div>
キーワード | 説明 |
---|---|
WorkDir | HTML出力先 |
Target | 監視対象を指定。フォーマット「<インターフェース名>:<コミュニティ名>@<IPアドレス>」 |
MaxBytes | 監視対象の転送許容量(byte/s表示) |
Title | グラフ表示用に生成されるHTMLページのタイトル |
PageTop | HTMLページのグラフの前に表示される文字列 |
【MaxBytesの補足】
たいていの回線レートはbps(bit/s)の為、byte/sを求めるには最大帯域幅(bit)を8で割る必要がある。
インターフェースの最大転送バイト/秒
ネットワークの種類 | 計算式 | byte/s |
---|---|---|
GigabitEthernet | 1Gbps(1,000,000,000bps) / 8 | 125,000,000 |
FastEthernet | 100Mbps(100,000,000bps) / 8 | 12,500,000 |
メモメモ
最低下記を記載するだけでよい?
Target[<target name>]: <port>:<community>@<ip address> MaxBytes[<target name>]: 1250000 Title[<target name>]: ページタイトルだよん
ターゲットの設定
・Target
Target[<target name>]: <port>:<community>@<ip address> Target[<target name>]: <oid1>&<oid2>:<community>@<ip address>
・MaxBytes
監視している2つの値が到達できる最大値
MaxBytes[<target name>]: 1250000
・Title
グラフ表示の際のHTMLページタイトル
Title[<target name>]: ページタイトルだよん
トラブルシューティング
初回実行時は必ず過去の統計データがない関連のエラーが出力される。
WorkDirを指定しなかったときに出力された
C:\mrtg-2.17.4\bin>perl mrtg C:\mrtg-2.17.4\mrtg.cfg Use of uninitialized value $dir in concatenation (.) or string at mrtg line 2658. Use of uninitialized value $dir in concatenation (.) or string at mrtg line 2658. Use of uninitialized value $dir in concatenation (.) or string at mrtg line 2676. Use of uninitialized value $dir in concatenation (.) or string at mrtg line 2676. Use of uninitialized value $dir in concatenation (.) or string at mrtg line 2692. Use of uninitialized value $dir in concatenation (.) or string at mrtg line 2692. ERROR: "WorkDir" not specified in mrtg config file
外部リンク
エンタープライズ: - 第6回:SNMPによるネットワークモニタリング
EOF