mrtg snmp监控网络流量的简单安装配置文档

mrtg snmp安装配置文档

1、net-snmp安装在被监测的机器上,并启动服务。
2、mrtg安装在提供web服务的机器上,放在计划任务里,定时向被监测的机器获取信息
3、当然提供web服务是需要web服务器的,简单的httpd就可以了。


================centOS 安装net-snmp 和 mrtg ======================================
参考文档:
http://wiki.centos.org/TipsAndTricks/MRTG
http://oss.oetiker.ch/mrtg/
http://oss.oetiker.ch/mrtg/doc/mrtg-unix-guide.en.html
http://wiki.centos.org/TipsAndTricks/MRTG

我的实践:
1、如果没有apache httpd请安装
yum install httpd

2、yum -y install mrtg

3、yum -y install net-snmp-utils


4、vi /etc/snmp/snmpd.conf
{

4.1、取消下面的注释
#view mib2   included  .iso.org.dod.internet.mgmt.mib-2 fc
4、2
#       group          context sec.model sec.level prefix read   write  notif
access  notConfigGroup ""      any       noauth    exact  systemview none none
修改为
access  notConfigGroup ""      any       noauth    exact  mib2 none none

}

5、/etc/init.d/snmpd start

6、cfgmaker --global 'WorkDir: /var/www/mrtg'  \
          --global 'Options[_]: bits,growright' \
          --output /var/www/mrtg/mrtg.cfg    \
           public@192.168.0.129;

这第6步需要说明,这里会生成配置文件
web服务目录:WorkDir: /var/www/mrtg
单位等:Options[_]: bits,growright
配置文件生成位置:output /var/www/mrtg/mrtg.cfg (我方这里很不明智,会暴露配置http://192.168.0.129/mrtg/mrtg.cfg,不过也不关紧要,要求高的话可以换个地方)

在mrtg.cfg中,举个监控某网卡的例子:
{{{

Target[192.168.0.129_2]: 2:public@192.168.0.129:
SetEnv[192.168.0.129_2]: MRTG_INT_IP="192.168.0.129" MRTG_INT_DESCR="eth0"
MaxBytes[192.168.0.129_2]: 12500000
Title[192.168.0.129_2]: Traffic Analysis for 192.168.0.129 -- eth0
PageTop[192.168.0.129_2]: <h1>Traffic Analysis for 192.168.0.129 -- eth0</h1>
                <div id="sysdetails">
                        <table>
                                <tr>
                                        <td>System:</td>
                                        <td>nfs129 in Unknown (edit /etc/snmp/snmpd.conf)</td>
                                </tr>
                                <tr>
                                        <td>Maintainer:</td>
                                        <td>Root &lt;root@localhost&gt; (configure /etc/snmp/snmp.local.conf)</td>
                                </tr>
                                <tr>
                                        <td>Description:</td>
                                        <td>eth0  </td>
                                </tr>
                                <tr>
                                        <td>ifType:</td>
                                        <td>ethernetCsmacd (6)</td>
                                </tr>
                                <tr>
                                        <td>ifName:</td>
                                        <td>eth0</td>
                                </tr>
                                <tr>
                                        <td>Max Speed:</td>
                                        <td>100.0 Mbits/s</td>
                                </tr>
                                <tr>
                                        <td>Ip:</td>
                                        <td>192.168.0.129 (home0.hadoop)</td>
                                </tr>
                        </table>
                </div>

}}}
想监控安装了snmpd服务的机器,可以仿照上面的写法增加。

7、indexmaker --output=/var/www/mrtg/index.html /var/www/mrtg/mrtg.cfg
这是生成页面的,每次配置改变了,可以执行这个,或者手动去改也行(按照里面的格式)。

8、执行三次(报错不管)
env LANG=C /usr/bin/mrtg /var/www/mrtg/mrtg.cfg
env LANG=C /usr/bin/mrtg /var/www/mrtg/mrtg.cfg
env LANG=C /usr/bin/mrtg /var/www/mrtg/mrtg.cfg

9、crontab -e
 */2 * * * *  /usr/bin/mrtg /var/www/mrtg/mrtg.cfg --logging /var/log/mrtg.log

10.vi /etc/httpd/conf.d/mrtg.conf

{{{
Alias /mrtg /var/www/mrtg

#<Location /mrtg>
#    Order deny,allow
#    Deny from all
#    Allow from 127.0.0.1
#    Allow from ::1
#    # Allow from .example.com
#</Location>

}}}

11、访问http://192.168.0.129/mrtg 就可以看见监控页面。


================gentoo 安装snmpd服务======================================
# emerge mrtg
emerge net-snmp


# cp /etc/snmp/snmpd.conf.example /etc/snmp/snmpd.conf
nano /etc/snmp/snmpd.conf
{{{
#       sec.name  source          community
com2sec notConfigUser  default       public
com2sec local     localhost       COMMUNITY
com2sec mynetwork NETWORK/24      COMMUNITY

#               sec.model  sec.name
group   notConfigGroup v1           notConfigUser
group MyRWGroup v1         local
group MyRWGroup v2c        local
group MyRWGroup usm        local
group MyROGroup v1         mynetwork
group MyROGroup v2c        mynetwork
group MyROGroup usm        mynetwork

#           incl/excl subtree                          mask
view all    included  .1                               80

#                context sec.model sec.level match  read   write  notif
access  notConfigGroup ""      any       noauth    exact  mib2 none none
access MyROGroup ""      any       noauth    exact  all    none   none
access MyRWGroup ""      any       noauth    exact  all    all    none

# -----------------------------------------------------------------------------
# status of notWritable.
view mib2   included  .iso.org.dod.internet.mgmt.mib-2 fc

syslocation Right here, right now.
syscontact Me <me@somewhere.org>

#  Make sure mountd is running
proc mountd

#  Make sure there are no more than 4 ntalkds running, but 0 is ok too.
proc ntalkd 4

#  Make sure at least one sendmail, but less than or equal to 10 are running.
proc sendmail 10 1

# a simple hello world
exec echotest /bin/echo hello world

#exec shelltest /bin/sh /tmp/shtest

# Check the / partition and make sure it contains at least 10 megs.

disk / 10000

# Check for loads:
load 12 14 14

}}}


/etc/init.d/snmpd start

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值