SNMP 基础

Simple Network Management Protocol (SNMP) is a widely used protocol for monitoring the health and welfare of network equipment (eg. routers), computer equipment and even devices like UPSs. Net-SNMP is a suite of applications used to implement SNMP v1, SNMP v2c and SNMP v3 using both IPv4 and IPv6.

SNMP is an application-layer protocol that provides a message format for communication between SNMP managers and agents. SNMP provides a standardized framework and a common language used for the monitoring and management of devices in a network.

 

The SNMP framework has three parts:

 

An SNMP manager

 

An SNMP agent

 

A MIB

 

The SNMP manager is the system used to control and monitor the activities of network hosts using SNMP. The most common managing system is called a Network Management System (NMS). The term NMS can be applied to either a dedicated device used for network management, or the applications used on such a device. A variety of network management applications are available for use with SNMP. These features range from simple command-line applications to feature-rich graphical user interfaces (such as the CiscoWorks2000 line of products).

 

The SNMP agent is the software component within the managed device that maintains the data for the device and reports these data, as needed, to managing systems. The agent and MIB reside on the routing device (router, access server, or switch). To enable the SNMP agent on a Cisco routing device, you must define the relationship between the manager and the agent.

 

The Management Information Base (MIB) is a virtual information storage area for network management information, which consists of collections of managed objects. Within the MIB there are collections of related objects, defined in MIB modules. MIB modules are written in the SNMP MIB module language, as defined in STD 58, RFC 2578, RFC 2579, and RFC 2580 (see the "MIBs and RFCs" section for an explanation of RFC and STD documents). Note that individual MIB modules are also referred to as MIBs; for example, the Interfaces Group MIB (IF-MIB) is a MIB module withinthe MIB on your system.

 

The SNMP agent contains MIB variables whose values the SNMP manager can request or change through Get or Set operations. A manager can get a value from an agent or store a value into that agent. The agent gathers data from the MIB, the repository for information about device parameters and network data. The agent can also respond to manager requests to Get or Set data.

 

Figure 14 illustrates the communications relationship between the SNMP manager and agent. A manager can send the agent requests to get and set MIB values. The agent can respond to these requests. Independent of this interaction, the agent can send unsolicited notifications (traps or informs) to the manager to notify the manager of network conditions.

            Figure 14 Communication Between an SNMP Agent and Manager

 

 

MIBs and RFCs

 

MIB modules typically are defined in RFC documents submitted to the Internet Engineering Task Force (IETF), an international standards body. RFCs are written by individuals or groups for consideration by the Internet Society and the Internet community as a whole, usually with the intention of establishing a recommended Internet standard. Before being given RFC status, recommendations are published as Internet Draft (I-D) documents. RFCs that have become recommended standards are also labeled as standards (STD) documents. You can learn about the standards process and the activities of the IETF at the Internet Society website at http://www.isoc.org. You can read the full text of all RFCs, I-Ds, and STDs referenced in Cisco documentation at the IETF website at http://www.ietf.org.

 

The Cisco implementation of SNMP uses the definitions of MIB II variables described in RFC 1213 and definitions of SNMP traps described in RFC 1215.

 

Cisco provides its own private MIB extensions with every system. Cisco enterprise MIBs comply with the guidelines described in the relevant RFCs unless otherwise noted in the documentation. You can find the MIB module definition files and list of which MIBs are supported on each Cisco platform on the Cisco MIB website on Cisco.com.

 

For a list of new MIB-related functionality, see the "New MIB Features in Cisco IOS Release 12.2" section.

 

SNMP(Simple Network Management Protocal, 简单网络管理协议)在架构体系的监控子系统中将扮演重要角色。大体上,其基本原理是,在每一个被监控的主机或节点上 (如交换机)都运行了一个agent,用来收集这个节点的所有相关的信息,同时监听 snmp 的 port,也就是 UDP 161,并从这个端口接收来自监控主机的指令(查询和设置)。

        如果使用 RHEL4 的 net-snmp,那么被监控主机需要安装 net-snmp(包含了 snmpd 这个 agent),而监控端需要安装 net-snmp-utils。如果自行编译,需要 beecrypt(libbeecrypt)和 elf(libraryelf)的库。

        每一个 agent 维护一个树形的数据库,称为 MID(Management Information Base, 管理信息库),其每一个节点称为 Object Identifier(OID),这在使用 net-snmp-utils 的工具时会用到。这些节点就表示了这台主机系统的设备如网卡的接口描述(eth0 等)、物理地址(MAC)、接口类型等,也可能是系统的信息,或者是需要监控的进程等...       

       net-snmp-utils 的工具集的所有参数不能直接在其 man 手册中查到,可以查 man snmpcmd ,这个命令并不实际存在,只是说明的所有 utils 命令共同的参数。

SNMP MIBs base && some utils

      MIB(Management Information Base, 管理信息库)这个树形数据库是按照数字(numeric)来组织的,即每一个节点(OID)都是数字,因此有一个名字到数字的映射关系,例如 system , interfaces 这样的名字要映射到各个被控端的实际设备节点上,或反之需要知道实际的名字。所有这些映射关系的定义都在 MIB 文件中,即 /usr/share/snmp/mibs (根据实际的安装情况会有不同)。例如:

   sh$ grep 'system' /usr/share/snmp/mibs/SNMPv2-MIB.txt system OBJECT IDENTIFIER ::= { mib-2 1 } ......

   snmptranslate 这个命令可以用来查看映射关系:

  sh$ snmptranslate .1.3.6.1.2.1.1.3.0
  SNMPv2-MIB::sysUpTime.0
  sh$ snmptranslate -On SNMPv2-MIB::system.sysUpTime.0
  .1.3.6.1.2.1.1.3.0

可以看到这个 SNMPv2-MIB 其实就是 /usr/share/snmp/mibs/SNMPv2-MIB.txt。

使用 snmpwalk 可以取得一个树的结果:

  sh$ snmpwalk -v2c -c public localhost system
  SNMPv2-MIB::sysDescr.0 = STRING: Linux localhost.localdomain 2.6.14.2 #1 SMP Thu Jan 11 15:39:36 EST 2007 i686
  SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
  SNMPv2-MIB::sysUpTime.0 = Timeticks: (687617) 1:54:36.17
  SNMPv2-MIB::sysContact.0 = STRING: zhoupeng@zovatech.com
  SNMPv2-MIB::sysName.0 = STRING: localhost.localdomain
  SNMPv2-MIB::sysLocation.0 = STRING: Unknown (edit /etc/snmp/snmpd.conf)
  SNMPv2-MIB::sysORLastChange.0 = Timeticks: (1) 0:00:00.01
  SNMPv2-MIB::sysORID.1 = OID: IF-MIB::ifMIB
.............
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
v2, 0 , 2018-05-10 v2\ACCOUNTING-CONTROL-MIB.cds, 18985 , 2018-05-10 v2\ACCOUNTING-CONTROL-MIB.cmi, 6194 , 2018-05-10 v2\ACCOUNTING-CONTROL-MIB.my, 30336 , 2002-11-22 v2\ACTONA-ACTASTOR-MIB.cds, 13848 , 2018-05-10 v2\ACTONA-ACTASTOR-MIB.cmi, 10955 , 2018-05-10 v2\ACTONA-ACTASTOR-MIB.my, 39991 , 2010-08-13 v2\ADMIN-AUTH-STATS-MIB.cds, 4461 , 2018-05-10 v2\ADMIN-AUTH-STATS-MIB.cmi, 3424 , 2018-05-10 v2\ADMIN-AUTH-STATS-MIB.my, 10304 , 2011-01-28 v2\ADSL-DMT-LINE-MIB.cds, 6749 , 2018-05-10 v2\ADSL-DMT-LINE-MIB.cmi, 5994 , 2018-05-10 v2\ADSL-DMT-LINE-MIB.my, 24097 , 2000-04-14 v2\ADSL-LINE-MIB.cds, 68176 , 2018-05-10 v2\ADSL-LINE-MIB.cmi, 41579 , 2018-05-10 v2\ADSL-LINE-MIB.my, 159225 , 2001-12-04 v2\ADSL-TC-MIB.cds, 3218 , 2018-05-10 v2\ADSL-TC-MIB.cmi, 655 , 2018-05-10 v2\ADSL-TC-MIB.my, 4292 , 2001-12-04 v2\ADSL2-LINE-MIB.cds, 112735 , 2018-05-10 v2\ADSL2-LINE-MIB.cmi, 50458 , 2018-05-10 v2\ADSL2-LINE-MIB.my, 219014 , 2010-10-29 v2\ADSL2-LINE-TC-MIB.cds, 18387 , 2018-05-10 v2\ADSL2-LINE-TC-MIB.cmi, 6727 , 2018-05-10 v2\ADSL2-LINE-TC-MIB.my, 31400 , 2010-05-04 v2\AIRESPACE-REF-MIB.cds, 1166 , 2018-05-10 v2\AIRESPACE-REF-MIB.cmi, 356 , 2018-05-10 v2\AIRESPACE-REF-MIB.my, 1567 , 2006-06-14 v2\AIRESPACE-SWITCHING-MIB.cds, 55152 , 2018-05-10 v2\AIRESPACE-SWITCHING-MIB.cmi, 40917 , 2018-05-10 v2\AIRESPACE-SWITCHING-MIB.my, 150336 , 2006-06-14 v2\AIRESPACE-WIRELESS-MIB.cds, 190260 , 2018-05-10 v2\AIRESPACE-WIRELESS-MIB.cmi, 197047 , 2018-05-10 v2\AIRESPACE-WIRELESS-MIB.my, 623328 , 2010-04-06 v2\ALTIGA-ADDRESS-STATS-MIB.cds, 5772 , 2018-05-10 v2\ALTIGA-ADDRESS-STATS-MIB.cmi, 5948 , 2018-05-10 v2\ALTIGA-ADDRESS-STATS-MIB.my, 16780 , 2011-01-28 v2\ALTIGA-BMGT-STATS-MIB.cds, 2285 , 2018-05-10 v2\ALTIGA-BMGT-STATS-MIB.cmi, 2900 , 2018-05-10 v2\ALTIGA-BMGT-STATS-MIB.my, 6575 , 2011-01-28 v2\ALTIGA-CAP.cds, 1858 , 2018-05-10 v2\ALTIGA-CAP.cmi, 3518 , 2018-05-10 v2\ALTIGA-CAP.my, 7350 , 2011-01-28 v2\ALTIGA-CERT-STATS-MIB.cds, 3352 , 2018-05-10 v2\ALTIGA-CERT-STATS-MIB.cmi, 2949 , 2018-05-10 v2\ALTIGA-CERT-STATS-MIB.my, 8466 , 2002-12-05 v2\ALTIGA-DHCP-SERVER-STATS-MIB.cds, 2381 , 2018-05-10 v2\ALTIGA-DHCP-SERVER-STATS-MIB.cmi, 3289 , 2018-05-10 v2\ALTIGA-DHCP-SERVER-STATS-MIB.my, 6669 , 2002-12-05 v2\ALTIGA-DHCP-STATS-MIB.cds, 3663 , 2018-05-10 v2\ALTIGA-DHCP-STATS-MIB.cmi, 4201 , 2018-05-10 v2\ALTIGA-DHCP-STATS-MIB.my, 9799 , 2002-12-05 v2\ALTIGA-DNS-STATS-MIB.cds, 1640 , 2018-05-10 v2\ALTIGA-DNS-STATS-MIB.cmi, 1373 , 2018-05-10 v2\ALTIGA-DNS-STATS-MIB.my, 3643 , 2011-01-28 v2\ALTIGA-EVENT-STATS-MIB.cds, 1885 , 2018-05-10 v2\ALTIGA-EVENT-STATS-MIB.cmi, 1973 , 2018-05-10 v2\ALTIGA-EVENT-STATS-MIB.my, 5027 , 2011-01-28 v2\ALTIGA-FILTER-STATS-MIB.cds, 3311 , 2018-05-10 v2\ALTIGA-FILTER-STATS-MIB.cmi, 3248 , 2018-05-10 v2\ALTIGA-FILTER-STATS-MIB.my, 8799 , 2011-01-28 v2\ALTIGA-FTP-STATS-MIB.cds, 2478 , 2018-05-10 v2\ALTIGA-FTP-STATS-MIB.cmi, 2152 , 2018-05-10 v2\ALTIGA-FTP-STATS-MIB.my, 5888 , 2011-01-28 v2\ALTIGA-GENERAL-STATS-MIB.cds, 2227 , 2018-05-10 v2\ALTIGA-GENERAL-STATS-MIB.cmi, 1502 , 2018-05-10 v2\ALTIGA-GENERAL-STATS-MIB.my, 4323 , 2011-01-28 v2\ALTIGA-GLOBAL-REG.cds, 3086 , 2018-05-10 v2\ALTIGA-GLOBAL-REG.cmi, 3151 , 2018-05-10 v2\ALTIGA-GLOBAL-REG.my, 10169 , 2011-01-28 v2\ALTIGA-HARDWARE-STATS-MIB.cds, 7590 , 2018-05-10 v2\ALTIGA-HARDWARE-STATS-MIB.cmi, 7918 , 2018-05-10 v2\ALTIGA-HARDWARE-STATS-MIB.my, 22150 , 2011-01-28 v2\ALTIGA-HTTP-STATS-MIB.cds, 2953 , 2018-05-10 v2\ALTIGA-HTTP-STATS-MIB.cmi, 4048 , 2018-05-10 v2\ALTIGA-HTTP-STATS-MIB.my, 9155 , 2011-01-28 v2\ALTIGA-IP-STATS-MIB.cds, 1411 , 2018-05-10 v2\ALTIGA-IP-STATS-MIB.cmi, 1387 , 2018-05-10 v2\ALTIGA-IP-STATS-MIB.my, 3614 , 2011-01-28 v2\ALTIGA-L2TP-STATS-MIB.cds, 16598 , 2018-05-10 v2\ALTIGA-L2TP-STATS-MIB.cmi, 16266 , 2018-05-10 v2\ALTIGA-L2TP-STATS-MIB.my, 43443 , 2011-01-28 v2\ALTIGA-LBSSF-STATS-MIB.cds, 2756 , 2018-05-10 v2\ALTIGA-LBSSF-STATS-MIB.cmi, 3747 , 2018-05-10 v2\ALTIGA-LBSSF-STATS-MIB.my, 8539 , 2011-01-28 v2\ALTIGA-MIB.cds, 2075 , 2018-05-10 v2\ALTIGA-MIB.cmi, 7753 , 2018-05-10 v2\ALTIGA-MIB.my, 18329 , 2011-01-28 v2\ALTIGA-MULTILINK-STATS-MIB.cds, 2728 , 2018-05-10 v2\ALTIGA-MULTILINK-STATS-MIB.cmi, 4284 , 2018-05-10 v2\ALTIGA-MULTILINK-STATS-MIB.my, 9503 , 2011-01-28 v2\ALTIGA-NAT-STATS-MIB.cds, 3233 , 2018-05-10 v2\ALTIGA-NAT-STATS-MIB.cmi, 5534 , 2018-05-10 v2\ALTIGA-NAT-STATS-MIB.my, 13264 , 2011-01-28 v2\ALTIGA-PPP-STATS-MIB.cds, 3174 , 2018-05-10 v2\ALTIGA-PPP-STATS-MIB.cmi, 4328 , 2018-05-10 v2\ALTIGA-PPP-STATS-MIB.my, 9950 , 2011-01-28 v2\ALTIGA-PPPOE-STATS-MIB.cds, 3172 , 2018-05-10 v2\ALTIGA-PPPOE-STATS-MIB.cmi, 4255 , 2018-05-10 v2\ALTIGA-PPPOE-STATS-MIB.my, 10219 , 2007-07-25

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值