一 配置SNMP
1.安装net-snmp
sudo yum -y install net-snmp
2.备份snmpd.conf文件
sudo cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf20150625
3.清空并重新编辑snmpd.conf
rocommunity public 127.0.0.1 rocommunity public 10.10.47.65 rocommunity public 10.10.47.66 rocommunity public 60.195.252.107 rocommunity public 60.195.252.110
10.10.47.65是安装监控宝插件的那台主机的内网IP
4.重新启动snmpd
sudo service snmpd restart
5.验证snmpd是否已经启动
sudo netstat -tulnp|grep 161
在任意一台机器上执行以下操作
执行snmpwalk的机器需要在snmpd.conf中有记录
sudo snmpwalk -v2c -c public 10.10.47.65
NMPv2-MIB::sysORUpTime.8 = Timeticks: (2) 0:00:00.02 IF-MIB::ifNumber.0 = INTEGER: 2 IF-MIB::ifIndex.1 = INTEGER: 1 IF-MIB::ifIndex.2 = INTEGER: 2 IF-MIB::ifDescr.1 = STRING: lo IF-MIB::ifDescr.2 = STRING: eth0 IF-MIB::ifType.1 = INTEGER: softwareLoopback(24) IF-MIB::ifType.2 = INTEGER: ethernetCsmacd(6) IF-MIB::ifMtu.1 = INTEGER: 16436 IF-MIB::ifMtu.2 = INTEGER: 1500 IF-MIB::ifSpeed.1 = Gauge32: 10000000 IF-MIB::ifSpeed.2 = Gauge32: 0 IF-MIB::ifPhysAddress.1 = STRING: IF-MIB::ifPhysAddress.2 = STRING: 52:54:0:8b:f2:fc IF-MIB::ifAdminStatus.1 = INTEGER: up(1) IF-MIB::ifAdminStatus.2 = INTEGER: up(1) IF-MIB::ifOperStatus.1 = INTEGER: up(1) IF-MIB::ifOperStatus.2 = INTEGER: up(1) IF-MIB::ifLastChange.1 = Timeticks: (0) 0:00:00.00 IF-MIB::ifLastChange.2 = Timeticks: (0) 0:00:00.00 IF-MIB::ifInOctets.1 = Counter32: 628285088 IF-MIB::ifInOctets.2 = Counter32: 3060855740 IF-MIB::ifInUcastPkts.1 = Counter32: 137622023 IF-MIB::ifInUcastPkts.2 = Counter32: 1929135244 IF-MIB::ifInNUcastPkts.1 = Counter32: 0
6.设置防火墙
如果被监控主机设置了防火墙需要开通UDP的161端口
iptables -I INPUT -p udp --dport 161 -j ACCEPT
参考文章:
http://www.jiankongbao.com/search/SNMP
时间: 2024-11-09 02:15:29