环境: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.nam...dex.html 以上这样就会有基本的 eth0 的流量分析了
----------------------------------------------------------------------
----------------------------------------------------------------------
[另一种懒人安装法]
1. 安装 mbmon (cpu测温软体) 、sysstat(CPU负载)
apt-get install mbmon sysstat
1. wget
http://m955.com/o...tg.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.nam...dex.html 这是一个懒人套件包,是抓鸟哥的下来改的
装好之后,基本SERVER的分析都有了,有主机流量、CPU负载、记忆体、SSH、FTP、WWW人数...等