1.rpm -ivh "http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm"
2.解决依赖 yum -y install libcurl libcurl-devel rrdtool rrdtool-devel perl-rrdtool rrdtool-prel libgcrypt-devel gcc make gcc-c++ liboping liboping-devel perl-CPAN net-snmp net-snmp-devel
加入到启动项wget http://collectd.org/files/collectd-5.4.1.tar.gz tar zxvf collectd-5.4.1.tar.gz cd collectd-5.4.1 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib --mandir=/usr/share/man --enable-all-plugins make && make install
cp contrib/redhat/init.d-collectd /etc/init.d/collectd chmod +x /etc/init.d/collectd
启动:service collectd start
一般配置:Hostname "host.example.com" LoadPlugin interface LoadPlugin cpu LoadPlugin memory LoadPlugin network LoadPlugin df LoadPlugin disk <Plugin interface> Interface "eth0" IgnoreSelected false </Plugin> <Plugin network> <Server "10.0.0.1" "25826"> ## logstash 的 IP 地址和 collectd 的数据接收端口号 </Server> </Plugin>
下面是使用snmp
YUM 安装
1 yum install -y net-snmp net-snmp-utils
使用命令:$ rpm -qa|grep snmp
检查是否安装net-snmp-utils-5.3.2.2-5.el5,net-snmp-libs-5.3.2.2-5.el5,net-snmp-5.3.2.2-5.el5三个rpm包
使用命令:$ rpm -qa|grep libsen
检查是否安装libsensors3-2.10.6-55.el5 (这里好像没有安装上,但也能使用)
使用命令:$ rpm -qa|grep lm
检查是否安装lm_sensors-2.10.6-55.el5
2.启动1)使用snmpwalk命令,查看本机localhost的主机名:
snmpwalk -v 2c -c public localhost sysName.0
显示:SNMPV2-MIB::sysName.0=STRING:orcale.domain.com
(2)使用snmptranslate命令,检查snmp工具是否可以使用:
snmptranslate -To |head
.1.3
.1.3.6
.1.3.6.1
.1.3.6.1.1
.......
如上,查出了部分oid,则表示snmp工具可以正常使用。
3)测试远端主机是否可以获取数据。
我这里登陆了另外一台Linux主机,该主机也按照上面的步骤安装好snmp服务及snmp工具。通过这台主机,获取远端主机的数据,这时需指定远端主机的IP地址:
snmpwalk -v 2c -c public 192.168.136.130 sysName.0
显示:SNMPv2-MIB::sysName.0=STRING:oracle.domain.com
这里要记住防火墙是否关闭或者端口是否可以监听。