MRTG的安装:
1、需要的套件 net-snmp libpng libpng-devel gd zlib mrtg
2、首先设置snmpd.conf (/etc/snmp/snmpd.conf) ,注意以下几项设置:
####
# First, map the community name "public" into a "security name"
# sec.name source community
# com2sec notConfigUser default public
com2sec mynetwork 192.168.92.68 mymrtg
####
# Second, map the security name into a group name:
# groupName securityModel securityName
# group notConfigGroup v1 notConfigUser
# group notConfigGroup v2c notConfigUser
group notConfigGroup v1 mynetwork
group notConfigGroup v2c mynetwork
####
# Third, create a view for us to let the group have rights to:
# Make at least snmpwalk -v 1 localhost -c public system fast again.
# name incl/excl subtree mask(optional)
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.2
view systemview included .1.3.6.1.2.1.25.1.1
####
# Finally, grant the group read-only access to the systemview view.
# group context sec.model sec.level prefix read write
## incl/excl subtree mask
#view all included .1 80
view all included .1 80
## -or just the mib2 tree-
## -or just the mib2 tree-35414912
#view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
## context sec.model sec.level prefix read writ
notif
#access notConfigGroup "" any noauth exact roview rwview
none
access notConfigGroup "" any noauth exact mib2 none
none
3、service snmpd start
4、测试 snmpwalk -c mymrtg -v 1 192.168.92.68
5、制作MRTG
cfgmaker > /etc/mrtg/mrtg.cfg
修改mrtg.cfg vi /etc/mrtg/mrtg.cfg
Workdir: /var/www/html/mrtg
Options[ ]: growright
Refresh: 300
Interval: 5
Language:gb2312
6、执行 env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg (连结执行三次,最后没有错误出现,要将这一条命令放到计划中,假设每5分钟执行一次 */5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg)
(如果你认为有必要,请注解掉/etc/httpd/conf.d/mrtg.conf的值)
7、产生index.html:
indexmaker --columns=1 --output=/var/www/html/mrtg/index.hmtl --title='traffic info' /etc/mrtg/mrtg.cfg
(想简单也可以这样 indexmaker /etc/mrtg/mrtg.cfg > /var/www/html/index.html)
8、修改/etc/httpd/conf/httpd.conf的值,因为mrtg不支持UTF-8,找到AddDefaultCharset UTF-8改为AddDefaultCharset gb2312
阅读(486) | 评论(0) | 转发(0) |