一、安装mrtg和net-snmp:
    yum -y install mrtg net-snmp-utils net-snmp gcc-* gd-* libpng-* zlib-*
二、修改/etc/snmp/snmpd.conf
    #去掉行首的注释符
    view mib2   included  .iso.org.dod.internet.mgmt.mib-2 fc
    #修改
    access  notConfigGroup ""      any       noauth    exact  systemview none none
    为:
    access  notConfigGroup ""      any       noauth    exact  mib2 none none
三、启用snmpd服务
    service snmpd start
    chkconfig snmpd on

    #查看端口的开启状况
    netstat -tunlp |grep snmp
    tcp        0      0 0.0.0.0:199             0.0.0.0:*               LISTEN      4973/snmpd         
    udp        0      0 0.0.0.0:161             0.0.0.0:*                           4973/snmpd

四、安装apache 服务
    yum install httpd -y
    #修改 /etc/httpd/conf/httpd.conf 文件
      DocumentRoot "/var/www/html"
    #为
      DocumentRoot "/var/www/mrtg"  #即把web的默认页面定向到mrtg目录下
    #建立目录 mkdir  
    /var/www/mrtg

五、配置MRTG
    #生成配置文件
    cfgmaker --global 'WorkDir: /usr/local/nginx/html/mrtg' --global "language: GB2312" --global 'Options[_]: growright,bits' --ifref=ip --output /etc/mrtg/mrtg.cfg  public@127.0.0.1  #(被监控的IP)
    #配置文件可以根据需要修改

    #生成MRTG网页主页面文件
    indexmaker /etc/mrtg/mrtg.cfg  --output=/usr/local/nginx/html/mrtg/index.html  --title="Mrtg--monitor--system"

    #启动MRTG
    env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
    #这个命令会输出一些错误信息,一般可以安全忽略,连续执行三次此命令即可。

    #MRTG生成的web页面是静态的,为了能让其不断的刷新,需要将以上命令添加进crontab
    crontab -e
    #添加如下一行
    */2 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg >/dev/null 2>&1

    注:此行表示每二分钟刷新一次,你可以根据自己的需要修改刷新时间间隔。