- 论坛徽章:
- 0
|
我写的东东,虽然顶的人少!但我依然涛声依旧!还写..
FREEBSD6.0上安装snmp+mrtg还是比较简单的,不过网络上的安装教程大多缺胳膊少腿,有的难度挺高,理论说了一大推,让人忘而怯步呀!今天偶来发一篇简单易懂的.为新手准备的.如果你已经安装好了apache的话,看下面:
一:安装snmp:
以下%为SHELL提示符,
安装snmp:
%cd /usr/ports/net-mgmt/net-snmp
%make install
修改/etc/rc.conf:
%ee /etc/rc.conf
加入:
------------------------------------------------------------------
snmpd_enable="YES"
snmpd_flags="-a -p /var/run/snmpd.pid"
snmptrapd_enable="YES"
snmptrapd_flags="-a -p /var/run/snmptrapd.pid"
------------------------------------------------------------------
运行下:
%/etc/netstart
编辑snmpd.conf:
%ee /usr/local/share/snmp/snmpd.conf
加入一行:
-------------------------------------------------------------
rocommunity public #默认让snmp使用public用户
--------------------------------------------------------------
启动snmpd:
%/usr/local/etc/rc.d/snmpd.sh start
二:安装mrtg:
确定ports下的mrtg在什么位置:
%whereis mrtg
mrtg: /usr/ports/net-mgmt/mrtg
安装mrtg:
%cd /usr/ports/net-mgmt/mrtg
%make install
进入你apache的data目录(视个人情况而定,我的是/usr/local/www/apache22/data/wh-hisense/):
%cd /usr/local/www/apache22/data/wh-hisense
在当前的WEB目录创建mrtg的目录:
%mkdir mrtg
三:配置mrtg:
进入mrtg的配置文件所在目录:
%cd /usr/local/etc/mrtg
用cfgmaker创建mrtg的配置文件:
%/usr/local/bin/cfgmaker public@mail.ahcbd.net > mrtg.cfg
记得将上面的mail.ahcbd.net换成你的主机名,或IP地址.
编辑mrtg.conf:
%ee mrtg.cfg
修改如下:
#####################################
WorkDir: /usr/local/www/apache22/data/wh-hisense/mrtg #注:去掉前面的#号哟,冒号后面不要有空格,否则会出错.
Language: gb2312 #注:这表示简体中文版,,这可是自己加上去的哦!!!
#####################################
并在文件尾加入,既cpu,内存等的监视:
-----------------------------------------------------------------------------------------------------
#Monitoring TCP connections
Target[tcpopen]: .1.3.6.1.2.1.6.9.0&.1.3.6.1.2.1.6.9.0:public@mail.ahcbd.net
Options[tcpopen]: nopercent,growright,gauge,noinfo
Title[tcpopen]: Open TCP connections
PageTop[tcpopen]: <h1>Open TCP connections</H1>
MaxBytes[tcpopen]: 1000000
YLegend[tcpopen]: # conns
ShortLegend[tcpopen]: connections
LegendI[tcpopen]: Connections:
Legend1[tcpopen]: Open TCP connections
#monitoring User vs Idle CPU usage
Target[kontor.cpu]:ssCpuRawUser.0&ssCpuRawIdle.0:public@mail.ahcbd.net
RouterUptime[kontor.cpu]: public@mail.ahcbd.net
MaxBytes[kontor.cpu]: 100
Title[kontor.cpu]: CPU LOAD
PageTop[kontor.cpu]: <H1>User CPU Load %</H1>
Unscaled[kontor.cpu]: ymwd
ShortLegend[kontor.cpu]: %
YLegend[kontor.cpu]: CPU Utilization
Legend1[kontor.cpu]: User CPU in % (Load)
Legend2[kontor.cpu]: Idle CPU in % (Load)
LegendI[kontor.cpu]: User
LegendO[kontor.cpu]: Idle
Options[kontor.cpu]: growright,nopercent
#monitoring User vs System CPU usage
Target[kontor.usrsys]:ssCpuRawUser.0&ssCpuRawSystem.0:public@mail.ahcbd.net
RouterUptime[kontor.usrsys]: public@mail.ahcbd.net
MaxBytes[kontor.usrsys]: 100
Title[kontor.usrsys]: CPU LOAD
PageTop[kontor.usrsys]: <H1>CPU (user and system) Load %</H1>
Unscaled[kontor.usrsys]: ymwd
ShortLegend[kontor.usrsys]: %
YLegend[kontor.usrsys]: CPU Utilization
Legend1[kontor.usrsys]: User CPU in % (Load)
Legend2[kontor.usrsys]: System CPU in % (Load)
LegendI[kontor.usrsys]: User
LegendO[kontor.usrsys]: System
Options[kontor.usrsys]: growright,nopercent
#monitoring Active CPU usage
Target[kontor.cpusum]:ssCpuRawUser.0&ssCpuRawUser.0:public@mail.ahcbd.net +
ssCpuRawSystem.0&ssCpuRawSystem.0:public@mail.ahcbd.net
+ ssCpuRawNice.0&ssCpuRawNice.0:public@mail.ahcbd.net
RouterUptime[kontor.cpusum]: public@mail.ahcbd.net
MaxBytes[kontor.cpusum]: 100
Title[kontor.cpusum]: CPU LOAD
PageTop[kontor.cpusum]: <H1>Active CPU Load %</H1>
Unscaled[kontor.cpusum]: ymwd
ShortLegend[kontor.cpusum]: %
YLegend[kontor.cpusum]: CPU Utilization
Legend1[kontor.cpusum]: Active CPU in % (Load)
LegendI[kontor.cpusum]: Active
Options[kontor.cpusum]: growright,nopercent
Target[freemem]: .1.3.6.1.4.1.2021.4.11.0&.1.3.6.1.4.1.2021.4.11.0:public@mail.ahcbd.net
Options[freemem]: nopercent,growright,gauge,noinfo
Title[freemem]: Free Memory
PageTop[freemem]: <h1>Free Memory</h1>
MaxBytes[freemem]: 1000000
kMG[freemem]: k,M,G,T,P,X
YLegend[freemem]: bytes
ShortLegend[freemem]: bytes
LegendI[freemem]: Free Memory:
Legend1[freemem]: Free memory, not including swap, in bytes
--------------------------------------------------------------------------------------
记得将上面每处的mail.ahcbd.net换成你的主机名。且更改上面CPU,MEM等各部分的排列顺序等同于其在网页中的排列顺序
生成index.html文件:
/usr/local/bin/indexmaker –-title="流量监控" --output=/home/http/mrtg/index.html mrtg.cfg
多运行几次:
/usr/local/bin/mrtg mrtg.cfg
直到没有出错提示为止
加入crontab每隔2分钟让数据刷新一次:
%ee /etc/crontab
------------------------------------------------------------------------
*/2 * * * * root /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg
--------------------------------------------------------------------
现在你可以用http://yourdomain.domain/mrtg/看到了。
End!
看希望顶的人越多,鼓励一下嘛!CU的老少爷们.... |
|