SNMP测试环境搭建
SNMP协议,即简单网络管理协议,在现在的数据中心监控设备中是常用的一种协议,可以实时取回服务器的运行数据,从而进行分析管理。
测试环境如下。
在一台RHEL 6.5的系统上安装net-snmp服务,在一台win7下通过ireasoning mib browser试着访问。
RHEL 6.5服务器
[root@server14 ~]# lsb_release -a
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 6.5 (Santiago)
Release: 6.5
Codename: Santiago
安装net-snmp-5.6.2.tar.gz
http://sourceforge.net/projects/net-snmp/files/net-snmp/5.6.2.1/net-snmp-5.6.2.1.tar.gz/download
1)tar -xzvf net-snmp-5.6.2.tar.gz解压到当前目录
2)运行./configure && make && make install注意提示问题的回答
3)运行snmpconf进行snmp agent的访问控制
选择1:Access Control Setup
选择3: a SNMPv1/SNMPv2c read-only access community name
注意设定community为default,后面测试会用到
按照提示即可
[root@server14 net-snmp-5.6.2.1]# snmpconf
I can create the following types of configuration files for you.
Select the file type you wish to create:
(you can create more than one as you run this program)
1: snmpd.conf
2: snmp.conf
3: snmptrapd.conf
Other options: quit
Select File: 1
The configuration information which can be put into snmpd.conf is divided
into sections. Select a configuration section for snmpd.conf
that you wish to create:
1: Access Control Setup
2: Agent Operating Mode
3: Monitor Various Aspects of the Running Host
4: System Information Setup
5: Extending the Agent
6: Trap Destinations
Other options: finished
Select section: 1
Section: Access Control Setup
Description:
This section defines who is allowed to talk to your running
snmp agent.
Select from:
1: a SNMPv3 read-write user
2: a SNMPv3 read-only user
3: a SNMPv1/SNMPv2c read-only access community name
4: a SNMPv1/SNMPv2c read-write access community name
Other options: finished, list
Select section: 3
Configuring: rocommunity
Description:
a SNMPv1/SNMPv2c read-only access community name
arguments: community [default|hostname|network/bits] [oid]
The community name to add read-only access for: default
The hostname or network address to accept this community name from [RETURN for all]:
The OID that this community should be restricted to [RETURN for no-restriction]:
Finished Output: rocommunity default
Section: Access Control Setup
Description:
This section defines who is allowed to talk to your running
snmp agent.
Select from:
1: a SNMPv3 read-write user
2: a SNMPv3 read-only user
3: a SNMPv1/SNMPv2c read-only access community name
4: a SNMPv1/SNMPv2c read-write access community name
Other options: finished, list
Select section: finished
The configuration information which can be put into snmpd.conf is divided
into sections. Select a configuration section for snmpd.conf
that you wish to create:
1: Access Control Setup
2: Agent Operating Mode
3: Monitor Various Aspects of the Running Host
4: System Information Setup
5: Extending the Agent
6: Trap Destinations
Other options: finished
Select section: finished
I can create the following types of configuration files for you.
Select the file type you wish to create:
(you can create more than one as you run this program)
1: snmpd.conf
2: snmp.conf
3: snmptrapd.conf
Other options: quit
Select File: quit
The following files were created:
snmpd.conf
These files should be moved to /usr/local/share/snmp if you
want them used by everyone on the system. In the future, if you add
the -i option to the command line I'll copy them there automatically for you.
Or, if you want them for your personal use only, copy them to
/root/.snmp . In the future, if you add the -p option to the
command line I'll copy them there automatically for you.
把当前目录下的snmpd.conf拷贝到/usr/local/share/snmp目录
[root@server14 net-snmp-5.6.2.1]# cd snmpd.conf /usr/local/share/snmp/
启动snmpd服务
通过命令snmpd localhost让snmpd在本机上监听
[root@server14 net-snmp-5.6.2.1]# snmpd localhost
通过命令netstat -an | grep 161 确认snmpd在161端口上监听
[root@server14 net-snmp-5.6.2.1]# netstat -an | grep 161
在本机上测试
在Windows 7下用mib browser浏览器进行测试:
iReasoning MIB Browser下载地址:http://www.ireasoning.com/download.shtml
iReasoning MIB Browser是管理启用SNMP的网络设备和应用不可或缺的工具。它允许用户装载标准,专有的MIB,甚至一些不当形成的MIB。它发出SNMP请求来检索代理的数据,或代理的变化。内置的捕捉接收器可以接收和处理SNMP陷阱陷阱风暴。添加新的功能:端口查看和新的用户界面。
在Address栏输入IP如下图如示
当输入IP后首次失败,经查原因是centos这边的防火墙没有配置好,直接关闭后成功:
[root@server14 net-snmp-5.6.2.1]# service iptables stop
至此,snmp测试环境搭建成功!
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9034054/viewspace-1974317/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9034054/viewspace-1974317/