- 论坛徽章:
- 0
|
MRTG 流量統計安裝
什麼是MRTG ?
MRTG是一種流量統計軟體,是透過SNMP協定去偵測流量並畫出圖表
所以安裝前要先安裝SNMP
--------------------------------------------------------------------------------
1.安裝SNMP
先到 /usr/ports/net/net-snmp/ 目錄
然後執行 make install
接下來會叫你按 "Enter" 進入設定
*** System Contact Information:
Describes who should be contacted about the host the agent is
running on. This information is available in the MIB-II tree. This
Can Also Be Over-Ridden Using The "syscontact" Syntax In The Agent'S
Configuration Files.
System Contact Information (root@xianfeng.net): //在這輸入管理者的E-mail
setting System Contact Information to... root@xianfeng.net
checking System Location...
*** System Location:
Describes the location of the system. This information is
available in the MIB-II tree. This Can also be over-ridden using the
"syslocation" syntax in the agent's configuration files.
System Location (Unknown): localhost //在這輸入主機的位址或名稱
setting System Location to... localhost
checking Location to write logfile...
*** Logfile location:
Enter the default location for the snmpd agent to dump
information & errors to. If not defined (enter the keyword "none"
at the prompt below) the agent will use stdout and stderr instead.
(Note: This value can be over-ridden using command line options.)
Location to write logfile (/var/log/snmpd.log): //在這輸入log檔所要存放的位置,直接按過即可
setting Location to write logfile to... /var/log/snmpd.log
checking Location to write persistent information...
*** snmpd persistent storage location:
Enter a directory for the snmp library to store persistent
data in the form of a configuration file.
Location to write persistent information (/var/ucd-snmp): //設定檔所要放的位置
setting Location to write persistent information to... /var/ucd-snmp
updating cache ./config.cache.........然後就會一直安裝下去
如果是net-snmp 的版本是 5.x 版的請注意
請新增一個文字檔 /usr/local/share/snmp/snmpd.conf
加入下面內容
rocommunity mrtg
ro 表示 read only
這裡我設定 community 為 mrtg
為了安全問題, 不想用 public
接著啟動 snmpd
# /usr/local/etc/rc.d/snmpd start
--------------------------------------------------------------------------------
2.安裝MRTG
目錄 /usr/ports/net/mrtg/
執行:make install
--------------------------------------------------------------------------------
3.建立MRTG設定檔
到 /usr/local/etc/mrtg/ 目錄
鍵入: cfgmaker mrtg@xianfeng.net >; mrtg
cfgmaker //是製造設定檔的程式
mrtg@xianfeng.net // 是設定監視xianfeng.net 這台主機
>; mrtg //將設定檔檔名設為mrtg
產生完設定檔後去編輯設定檔,在裡面加入一行來設定工作目錄
Workdir: /usr/local/www/data/mrtg (此目錄必須設在web可以瀏覽到的目錄,因為mrtg是web介面)
另外再加一行
Language: GB2312 來設定中文介面
--------------------------------------------------------------------------------
4.產生HTML檔案
目錄 /usr/local/etc/mrtg/
指令:indexmaker -title '流量統計' -output /usr/local/www/data/mrtg/index.html mrtg
說明:
indexmaker //建立html檔的程式
-t '流量統計' // 要建立的網頁的標題
-o /usr/local/www/data/mrtg/index.html // 在usr/local/www/data/mrtg/ 目錄中建立一個 index.html 的檔案
mrtg //之前建立的設定檔
再將/usr/ports/distfiles中的mrtg檔解開,將所有的image檔案放入 /usr/local/www/data/mrtg/
--------------------------------------------------------------------------------
5.執行mrtg
指令:/usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg
(如果有錯誤就一直重複執行到沒錯誤為止)
--------------------------------------------------------------------------------
6.用crontab定期執行 (每5分鐘執行一次)
指令:crontab -e
內容:
5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg
--------------------------------------------------------------------------------
7.測試 :
做一個連結直接連到剛剛所做的index.html檔即可
如果看到東西就表示設定成功喔,如果不成功也別氣餒
再好好努力吧
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/31266/showart_264501.html |
|