目錄表

mrtg-reference

http://oss.oetiker.ch/mrtg/doc/mrtg-reference.en.html

SNMP Reference

http://www.debianhelp.co.uk/snmp.htm

http://blog.miniasp.com/post/2009/02/Ubuntu-804-snmpd-installation-and-configuration-notes.aspx

http://dieabsorb.wordpress.com/2011/04/05/snmp-%E5%B0%8F%E8%A8%98/

indexmaker

http://oss.oetiker.ch/mrtg/doc/indexmaker.en.html

Debian MRTG 簡易設定

SNMP - Simple Network Management Protocol
MRTG - Multi Router Traffic Grapher

http://phorum.study-area.org/viewtopic.php?t=21142

安裝 SNMP 和 MRTG

# apt-get install snmp snmpd mrtg mrtg-contrib

出現詢問

Make /etc/mrtg.conf owned by and readable only by the MRTG user?

選擇Yes,讓一般使用者看不到 MRTG 的設定檔

備份 SNMP 的設定檔

# cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak

產生 SNMP 的設定檔

# snmpconf

如果是簡易設定,只要設定 Access Control Setup 的選項

Community name: public

即可,等 SNMP 可以運作之後再去詳細 config snmp

重新啟動 SNMP

# /etc/init.d/snmpd restart

測試 SNMP

# snmpwalk -c public -v 1 localhost

簡易 smnpd.conf

''rocommunity  public''

產生 mrtg.cfg

# cfgmaker --global 'WorkDir: /var/www/mrtg' --global "Refresh: 300" --global 'Options[_]: bits,growright' --global 'Language: big5' --output /etc/mrtg.cfg public@domain.name

cfgmaker 另一種寫法

1)

# cfgmaker --global "WorkDir: /var/www/mrtg" --global "Refresh: 600" --global "Interval: 5" --global "WriteExpires: Yes" --global "Language: big5" --global "options[_]: bits" --ifdesc=descr --ifref=descr public@127.0.0.1 > /etc/mrtg.cfg
  1. /var/www/mrtg 是輸出的網頁存放地,該資料夾應該已經有一些基本的 MRTG 圖檔,檢查目錄是否存在、網頁伺服器是否可以存取
  2. public@domain.name 把 domain.name 換成您主機的 domain.name,而 public 則是您當初用 snmpconf 指定的 community name。(如果失敗試試 127.0.0.1 )
  3. mrtg.cfg 存在 /etc 下面

如果看到 SNMP Error: no response received 的訊息, 表示 snmpd.conf 還是沒有設好

確認 MRTG 的狀態

# mrtg /etc/mrtg.cfg

執行三次,前兩次執行會出現 rateup 的警告,不用理。

產生結果網頁

# indexmaker --columns=1 --output=/var/www/mrtg/index.html --title='Traffic Info' /etc/mrtg.cfg

完成

開啟網頁,EX: http://domain.name/mrtg/index.html

如果沒圖表出來,通常都是 SNMP 設定失敗

FreeBSD MRTG 簡易設定

使用 bsnmpd

參考:http://blog.gslin.org/archives/2007/08/19/1275/

Install SNMP and MRTG

cd /usr/ports/net-mgmt/net-snmp; make install clean
cd /usr/ports/net-mgmt/mrtg; make install clean

rc.conf

snmpd_enable="YES"
snmpd_flags="-a -p /var/run/snmpd.pid"
snmptrapd_enable="YES"
snmptrapd_flags="-a -p /var/run/snmptrapd.pid"

configure snmp

cp /usr/local/share/snmp/snmpd.conf.example /usr/local/share/snmp/snmpd.conf

In /usr/local/share/snmp/snmpd.conf:

#             sec.name  source          community
com2sec local        localhost      public    # can name other symbol at community column
#               sec.model  sec.name
group MyRWGroup v1         local
group MyRWGroup v2c        local
group MyRWGroup usm        local
#           incl/excl subtree                          mask
view all    included  .1                               80
#                context sec.model sec.level match  read   write  notif
access MyRWGroup ""      any       noauth    exact  all    all    none

Start snmpd

/usr/local/etc/rc.d/snmpd start

Create mrtg.cfg

cfgmaker public@localhost

如果沒有錯誤訊息

cfgmaker public@localhost > /usr/local/etc/mrtg/mrtg.cfg

依照 Http Server Documents Root 建立網頁資料夾

mkdir /usr/local/www/apache22/data/mrtg

Modify /usr/local/etc/mrtg/mrtg.cfg

#  for UNIX
WorkDir: /usr/local/www/apache22/data/mrtg
Language:Big5

Draw diagram

/usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg

Add into crontab

*/5 * * * * root /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg    # Every five minutes

Create MRTG's index file

indexmaker --title='MRTG - 網路流量分析' --addhead=' \
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=utf-8">' \
--output /usr/local/www/apache22/data/mrtg/index.htm --columns=1 \
--nolegend /usr/local/etc/mrtg/mrtg.cfg

smokeping

利用 rrdtools 繪出各網站的 ping 值

# aptitude install smokeping

設定檔放在 /etc/smokeping,其中主要設定檔為 config,修改 owner contact cgiurl mailhost to from 這些設定值。

一些文字設定:title、remark等。

之後是站台設定,「+」代表跟目錄,「++」表子目錄。

+ Local
menu = Local
title = Local Network
++ LocalMachine
menu = Local Machine
title = This own machine
host = localhost

+ BBS
menu = BBS
title = BBS
++ Bahamut
menu = Bahamut
title = bbs.gamer.com.tw
host = bbs.gamer.com.tw

重新啟動服務

# /etc/init.d/smokeping restart

網頁放在 http://your.website/cgi-bin/smokeping.cgi

圖案資料放在 http://your.website/smokeping/

Cacti

http://www.cacti.net/

Cacti is a complete network graphing solution designed to harness the power of RRDTool's data storage and graphing functionality.

1) 有空查 manual 比較差別