環境:debian
----------------------------------------------------------------------
[安裝 snmp]
# apt-get install snmpd snmp
[設定 snmpd.conf]
先備份
# cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak
編輯 snmpd.conf
# echo 'rocommunity public' > /etc/snmp/snmpd.conf
很多人mrtg裝不起來,大多是因為snmpd.conf弄不好,不過我發現到一個可以偷吃步的方法!!
打上這一行(注意空格),就全部ok嘍,夠輕鬆愉快吧!!
重跑snmp
# /etc/init.d/snmpd restart
測試一下snmp
snmpwalk localhost -c public -v 1
跑出一堆訊息就成功嘍!!
...
...
HOST-RESOURCES-MIB::hrSWRunPerfMem.21022 = INTEGER: 1304 KBytes
HOST-RESOURCES-MIB::hrSWRunPerfMem.21023 = INTEGER: 1752 KBytes
HOST-RESOURCES-MIB::hrSWRunPerfMem.26812 = INTEGER: 14788 KBytes
IPV6-MIB::ipv6Forwarding.0 = INTEGER: notForwarding(2)
IPV6-MIB::ipv6DefaultHopLimit.0 = INTEGER: 0
----------------------------------------------------------------------
snmp搞好了,就成功一半嘍,其他的就沒啥大礙了!
[安裝mrtg]
apt-get install mrtg
會詢問妳
Make /etc/mrtg.conf owned by and readable only by the MRTG user?
選擇Yes
----------------------------------------------------------------------
[產生mrtg.cfg]
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
整行複製吧,不斷行!!
----------------------------------------------------------------------
執行mrtg
#mrtg /etc/mrtg.cfg
執行3次,無錯誤訊息即可
----------------------------------------------------------------------
[產生流量分析網頁index.html]
indexmaker --columns=1 \
--output=/var/www/mrtg/index.html \
--title='Traffic Info' \
/etc/mrtg/mrtg.cfg
或是...
indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html
以上都一樣是產生 index.html
----------------------------------------------------------------------
[觀看mrtg 流量分析表囉]
http://your.domain.name/mrtg/index.html
以上這樣就會有基本的 eth0 的流量分析了
----------------------------------------------------------------------
----------------------------------------------------------------------
[另一種懶人安裝法]
1. 安裝 mbmon (cpu測溫軟體) 、sysstat(CPU負載)
apt-get install mbmon sysstat
1. wget http://m955.com/other/mrtg.zip
2. 解壓縮到 ../www/ 下
3. 更改權限 chmod 755 /var/www/mrtg/755.sh
4. 執行 sh 755.sh
5. 加入以下設定到 vi /etc/cron.d/mrtg
#mrtg
*/5 * * * * root /usr/bin/mrtg /var/www/mrtg/net/mrtg.cfg.net > /dev/null 2>&1
*/5 * * * * root /usr/bin/mrtg /var/www/mrtg/ram/mrtg.cfg.ram > /dev/null 2>&1
*/5 * * * * root /usr/bin/mrtg /var/www/mrtg/www/mrtg.cfg.www > /dev/null 2>&1
*/5 * * * * root /usr/bin/mrtg /var/www/mrtg/ftp/mrtg.cfg.ftp > /dev/null 2>&1
*/5 * * * * root /usr/bin/mrtg /var/www/mrtg/ssh/mrtg.cfg.ssh > /dev/null 2>&1
*/5 * * * * root /usr/bin/mrtg /var/www/mrtg/telnet/mrtg.cfg.telnet > /dev/null 2>&1
*/5 * * * * root /usr/bin/mrtg /var/www/mrtg/cputemp/mrtg.cfg.cputemp > /dev/null 2>&1
*/5 * * * * root /usr/bin/mrtg /var/www/mrtg/cpu/mrtg.cfg.cpu > /dev/null 2>&1
執行一次下列指令,產生流量統計圖 (執行時會產生錯誤訊息,忽略即可):
# mrtg /var/www/mrtg/net/mrtg.cfg.net
# mrtg /var/www/mrtg/ram/mrtg.cfg.ram
# mrtg /var/www/mrtg/www/mrtg.cfg.www
# mrtg /var/www/mrtg/ftp/mrtg.cfg.ftp
# mrtg /var/www/mrtg/ssh/mrtg.cfg.ssh
# mrtg /var/www/mrtg/telnet/mrtg.cfg.telnet
# mrtg /var/www/mrtg/cputemp/mrtg.cfg.cputemp
# mrtg /var/www/mrtg/cpu/mrtg.cfg.cpu
[觀看mrtg 流量分析表囉]
http://your.domain.name/mrtg/index.html
這是一個懶人套件包,是抓鳥哥的下來改的
裝好之後,基本SERVER的分析都有了,有主機流量、CPU負載、記憶體、SSH、FTP、WWW人數...等