centos6安装教程|centos6系统snmp监控安装配置与使用示例

更新时间:2019-10-25    来源:CentOS    手机版     字体:

【www.bbyears.com--CentOS】

安装 Net-SNMP

CentOS其它RedHat系列产品提供了net-snmp的二进制包。我们可以直接从源里安装。

Example

yum install net-snmp net-snmp-devel net-snmp-utils

说明:net-snmp-devel是为了使用net-snmp-config, net-snmp-utils是为了使用snmpwalk。

配置 Net-SNMP

Example

create-snmpv3-user -ro -A snmp@jiankongbao -a MD5 jiankongbao

以上命令,创建一个snmpv3用户,只读,使用MD5,用户名为jiankongbao,密码为snmp@jiankongbao。

注意:运行之前请先停用net-snmp服务。

Example

service snmpd stop

运行 Net-SNMP

运行 Net-SNMP 服务的方法比较简单,不过Net-SNMP服务的名字是snmpd。

Example

service snmpd start

如果要加入开机自动运行服务列表:

Example

chkconfig snmpd on

检测 Net-SNMP

我们可以使用 snmpwalk 来检测snmp服务是否正常开启。

Example

snmpwalk -v 3 -u jiankongbao -a MD5 -A "snmp@jiankongbao" -l authNoPriv 127.0.0.1 sysDescr
如果一切正常,就会返回正常结果


有防火墙的情况下,得把udp 161 端口打开了

[root@zhudoubaby ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination        
RH-Firewall-1-INPUT  all  --  anywhere             anywhere           

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination        
RH-Firewall-1-INPUT  all  --  anywhere             anywhere           

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination        

Chain RH-Firewall-1-INPUT (2 references)
target     prot opt source               destination        
 
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:snmp    (必须的)
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:smtp  (不用)
 

使用过程错误记录


注意:有时输入service snmpd status 后出现
snmpd dead but pid file exists
或者
snmpd dead but subsys locked
原因是没有先输入snmpd,原理还不是很明白,但是先记着吧。

本文来源:http://www.bbyears.com/caozuoxitong/75265.html

热门标签

更多>>

本类排行