SNMP中的Context(上下文)

这是RFC文档中对context的描述:
Context
An SNMP context, or just “context” for short, is a collection of management information accessible by an SNMP entity. An item of management information may exist in more than one context. An SNMP entity potentially has access to many contexts.

Typically, there are many instances of each managed object type within a management domain. For simplicity, the method for identifying instances specified by the MIB module does not allow each instance to be distinguished amongst the set of all instances within a management domain; rather, it allows each instance to be identified only within some scope or “context”, where there are multiple such contexts within the management domain. Often, a context is a physical device, or perhaps, a logical device, although a context can also encompass multiple devices, or a subset of a single device, or even a subset of multiple devices, but a context is always defined as a subset of a single SNMP entity. Thus, in order to identify an individual item of management information within the management domain, its contextName and contextEngineID must be identified in addition to its object type and its instance.

For example, the managed object type ifDescr [RFC2233], is defined as the description of a network interface. To identify the description of device-X’s first network interface, four pieces of information are needed: the snmpEngineID of the SNMP entity which provides access to the management information at device-X, the contextName (device-X), the managed object type (ifDescr), and the instance (“1”).

Each context has (at least) one unique identification within the management domain. The same item of management information can exist in multiple contexts. An item of management information may have multiple unique identifications. This occurs when an item of management information exists in multiple contexts, and this also occurs when a context has multiple unique identifications.

The combination of a contextEngineID and a contextName unambiguously identifies a context within an administrative domain; note that there may be multiple unique combinations of contextEngineID an contextName that unambiguously identify the same context.

翻译:
Context是管理信息的集合,用于SNMP实体在本地访问。一条管理信息可能存在于多个context中。所以,一个SNMP实体可能访问多个context。
比较典型的,在管理域中,每个管理对象类型有多个实例(实例集合)。为了简单化,由MIB模块定义实例标识,但是这种方式不允许在管理域中区分实例集合中的实例;然而,它允许在一个范围内或者说在一个“context”中实例是唯一的。这样,管理域中就包含多个这样的context。通常来说,一个context是一个物理设备或者逻辑设备。虽然一个context可能包含多个设备,也可以包含一个设备的一部分信息,甚至是多个设备的部分信息,但是一个context肯定是一个SNMP实体的子集。因而,为了在管理域中标识一条独立的管理信息,contextName和contextEngineID必须唯一,当然管理信息的对象类型和实例可以不唯一。
举个例子,管理对象类型ifDescr是网络接口的描述。为了标识设备device-X的第一个网络接口的描述,必须用到4个信息:snmpEngineID(SNMP实体的标识),contextName(可以定位到device-X),对象类型(即ifDescr),实例编号(‘1’)。
在管理域里面每个context至少有一个唯一的标识(实际上就是contextName)。同样的管理信息可以存在于多个context中。当一条管理信息存在于多个context时,或者一个context有多个标识时,一条管理信息可能有多个唯一标识。
contextEngineID和contextName组合起来就能很明确地标识一个context,请注意,对于一个context可能存在多个这样的唯一组合。(原因很简单,一个context可能有多个标识) 。

理解:
这段文字实际上讲的就是SNMP为什么要用到上下文(context)。原因是按照MIB模块定义的实例标识,不能在管理域中唯一区分实例集合中的实例,所以引入context。
Context实际上是SNMP实体的本地化概念,SNMP实体用context来分类、组织其内部的信息,比如说一台服务器上包含两块网卡,第一块网卡用于Internet上网,第二块网卡用作服务器之间的心跳线,如果把两块网卡的信息分别放在不同的context中,则服务器中的SNMP实体拥有了两个context。这样组织管理信息有个好处,当不需要关心第二块网卡的信息时,我们只从第一个context中读取数据即可。
在context范围内,实例标识可以唯一标识一个实例,但在一个管理域内,实例标识可能不是唯一的,接着上面的例子来说,ifDescr.1在管理域内可能不是唯一的标识,但是contextName.ifDescr.1在管理域内一定是唯一的标识。标识的完整路径应该是:snmpEngineID.contextEngineID.contextName.objectType.instanceId,其中snmpEngineID和contextEngineID一般来说是同一个值的。

理解:
这段文字实际上讲的就是SNMP为什么要用到上下文(context)。原因是按照MIB模块定义的实例标识,不能在管理域中唯一区分实例集合中的实例,所以引入context。
Context实际上是SNMP实体的本地化概念,SNMP实体用context来分类、组织其内部的信息,比如说一台服务器上包含两块网卡,第一块网卡用于Internet上网,第二块网卡用作服务器之间的心跳线,如果把两块网卡的信息分别放在不同的context中,则服务器中的SNMP实体拥有了两个context。这样组织管理信息有个好处,当不需要关心第二块网卡的信息时,我们只从第一个context中读取数据即可。
在context范围内,实例标识可以唯一标识一个实例,但在一个管理域内,实例标识可能不是唯一的,接着上面的例子来说,ifDescr.1在管理域内可能不是唯一的标识,但是contextName.ifDescr.1在管理域内一定是唯一的标识。标识的完整路径应该是:snmpEngineID.contextEngineID.contextName.objectType.instanceId,其中snmpEngineID和contextEngineID一般来说是同一个值的。

这是RFC文档中定义的命令相应器访问context的结构图,从这个图上更容易理解context的概念
在这里插入图片描述
从这个图中可以看出,默认contextName为””。
按照我的经验,普通的SNMP应用只有一个context。
如有错误的地方,请给与指教。

发布了39 篇原创文章 · 获赞 16 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/wanggong_1991/article/details/104244579
今日推荐