FREEBSD下snmp+mrtg实现对网络流量、CPU、内存等的监视(转)

FREEBSD下snmp+mrtg实现对网络流量、CPU、内存等的监视(转)[@more@]

  FREEBSD上安装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换成你的主机名,

  编辑mrtg.conf:

  %ee mrtg.cfg

  修改如下:

  -----------------------------------------------------------------------------

  LoadMIBs: /usr/local/share/snmp/mibs/UCD-SNMP-MIB.txt

  WorkDir: /usr/local/www/apache22/data/wh-hisense/mrtg

  Language: chinese

  --------------------------------------------------------------------------------

  并在文件尾加入:

  -----------------------------------------------------------------------------------------------------

  #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]:

Open TCP connections

  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]:

User CPU Load %

  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]:

CPU (user and system) Load %

  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]:

Active CPU Load %

  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]:

Free Memory

  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

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10748419/viewspace-944483/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10748419/viewspace-944483/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值