bsnmp 监控远程主机

>> 监控机
===================================
>mrtg:
--------------------------
install (Perl/gd/libpng/zlib)
http://oss.oetiker.ch/mrtg/doc/mrtg-unix-guide.en.html


生成 cfg文件
/usr/local/mrtg/bin/cfgmaker USER@IP > /tmp/mrtg.cfg

config
http://oss.oetiker.ch/mrtg/doc/mrtg-reference.en.html

生成 html 页面
/usr/local/mrtg/bin/indexmaker /tmp/mrtg.cfg > /path/to/www/stats/mrtg/index.html

启动mrtg (crontab or RunAsdomain )
/usr/local/mrtg/bin/mrtg /tmp/mrtg.cfg


>>被监控机:(eg 172.16.0.33)
====================================
> snmpd
--------------------------------
FreeBSD 7.0+ 已经内置了 bsnmpd: http://people.freebsd.org/~harti/bsnmp/
vi /etc/rc.conf
-------------------------
bsnmpd_enable="yes"


install bsnmp-ucd (for cpu, tcp, ..) : http://code.google.com/p/bsnmp-ucd
--------------------------
fetch http://bsnmp-ucd.googlecode.com/files/bsnmp-ucd-VERSION.tar.gz
cd xxx
make
make install


vi /etc/snmpd.config
-------------------------------
contact := "SandersWang@xxxxx.com"
read := "sanderswang"

添加
begemotSnmpdModulePath."ucd" = "/usr/local/lib/snmp_ucd.so"


start
-------------
/etc/rc.d/bsnmpd start

>> cfg demo:
=========================================================
>main.cfg
---------------------------
# by sanders

### Global Config Options

EnableIPv6: no
WorkDir: /path/to/www/stats/mrtg
RunAsDaemon: yes
Interval: 5
Refresh: 300
Language: gb2312
Forks: 2


### Global Defaults

Timezone[_]: GMT+8
MaxBytes[_]: 12500000
Options[_]: growright
Title[_]: UPD SRV Status


### servers

#Include: upd_xxx.cfg.inc
Include: upd_172.16.0.33.cfg.inc


upd_172.16.0.33.cfg.inc
----------------------------
# by sanders


######################################################################
# System: upd_test
# Description: upd_test 2780056749 FreeBSD 7.0-RELEASE
# Contact: sanderswang@xxxxx.com
# Location: Room 200
######################################################################


### Interface 1 > Descr: 'em0' | Name: 'em0' | Ip: '172.16.0.33' | Eth: '00-0c-29-9d-f7-2c' ###

Target[172.16.0.33_1]: 1:sanderswang@172.16.0.33:
SetEnv[172.16.0.33_1]: MRTG_INT_IP="172.16.0.33" MRTG_INT_DESCR="em0"
PageTop[172.16.0.33_1]: <h1>em1 -- upd_test -- 172.16.0.33</h1>


### Monitoring TCP connections

Target[172.16.0.33_tcpopen]: .1.3.6.1.2.1.6.9.0&.1.3.6.1.2.1.6.9.0:sanderswang@172.16.0.33
Options[172.16.0.33_tcpopen]: nopercent,growright,gauge,noinfo
Title[172.16.0.33_tcpopen]: Open TCP connections
PageTop[172.16.0.33_tcpopen]: <H1>Open TCP connections</H1>
MaxBytes[172.16.0.33_tcpopen]: 100000000
YLegend[172.16.0.33_tcpopen]: # conns
ShortLegend[172.16.0.33_tcpopen]: connections
LegendI[172.16.0.33_tcpopen]: Connections:
LegendO[172.16.0.33_tcpopen]:
Legend1[172.16.0.33_tcpopen]: Open TCP connections

### RAM & SWAP

Target[172.16.0.33_ramswap]: memAvailReal.0&memAvailSwap.0:sanderswang@172.16.0.33
Options[172.16.0.33_ramswap]: nopercent,growright,gauge,noinfo
Title[172.16.0.33_ramswap]: RAM & SWAP idle status
PageTop[172.16.0.33_ramswap]: <h1>RAM & SWAP Idle status </h1>
MaxBytes[172.16.0.33_ramswap]: 1000000000
kMG[172.16.0.33_ramswap]: k,M,G,T,P,X
Ylegend[172.16.0.33_ramswap]: Bytes
ShortLegend[172.16.0.33_ramswap]: Bs
LegendI[172.16.0.33_ramswap]: RAM Idle
LegendO[172.16.0.33_ramswap]: Swap Idle
Legend1[172.16.0.33_ramswap]: RAM Idle
Legend2[172.16.0.33_ramswap]: Swap Idle


#monitoring User vs Idle CPU usage
Target[172.16.0.33_cpu]:ssCpuRawUser.0&ssCpuRawIdle.0:sanderswang@172.16.0.33
RouterUptime[172.16.0.33_cpu]: sanderswang@172.16.0.33
MaxBytes[172.16.0.33_cpu]: 100
Title[172.16.0.33_cpu]: CPU LOAD
PageTop[172.16.0.33_cpu]: <H1>User CPU Load %</H1>
Unscaled[172.16.0.33_cpu]: ymwd
ShortLegend[172.16.0.33_cpu]: %
YLegend[172.16.0.33_cpu]: CPU Utilization
Legend1[172.16.0.33_cpu]: User CPU in % (Load)
Legend2[172.16.0.33_cpu]: Idle CPU in % (Load)
LegendI[172.16.0.33_cpu]: User
LegendO[172.16.0.33_cpu]: Idle
Options[172.16.0.33_cpu]: growright,nopercent


>make index && start mrtg
----------------------------------------
/usr/local/mrtg/bin/indexmaker --perhost --columns=2 --enumerate --title="UPD SRV status" --nolegend --pageend="<br><hr>by MRTG: <a href=http://oss.oetiker.ch/mrtg>http://oss.oetiker.ch/mrtg</a><br>" /usr/local/mrtg/etc/main.cfg > /path/to/www/stats/mrtg/index.html
/usr/local/mrtg/bin/mrtg /usr/local/mrtg/etc/main.cfg --logging=/tmp/mrtg.log


>robots.txt
----------------------------------------
User-agent: *
Disallow: /


>> 注意:
============================
"Keywords must start at the beginning of a line."
"Note that unless you are using rrdtool you can not set Interval to less than 5 minutes."

>>see to:
============================
http://oss.oetiker.ch/mrtg
http://www.chinaunix.net/jh/5/488199.html
http://linux.vbird.org/linux_security/old/04mrtg.php
http://code.google.com/p/bsnmp-ucd/

============================================
update [2009-6-26]:
============================================

不需要设置 #Timezone[_]: GMT+8
可能要 LoadMIBs: /usr/local/snmp/share/snmp/mibs/UCD-SNMP-MIB.txt
Options[_]: growright, bits

这个mib可能需要安装 net-snmp 或 ucd-snmp

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值