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實體的子集。因而,爲了在管理域中標識一條獨立的管理信息,contextNamecontextEngineID必須唯一,當然管理信息的對象類型和實例可以不唯一。

     舉個例子,管理對象類型ifDescr是網絡接口的描述。爲了標識設備device-X的第一個網絡接口的描述,必須用到4個信息:snmpEngineID(SNMP實體的標識)contextName(可以定位到device-X),對象類型(ifDescr),實例編號(‘1’)

     在管理域裏面每個context至少有一個唯一的標識(實際上就是contextName)。同樣的管理信息可以存在於多個context中。當一條管理信息存在於多個context時,或者一個context有多個標識時,一條管理信息可能有多個唯一標識。

     contextEngineIDcontextName組合起來就能很明確地標識一個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,其中snmpEngineIDcontextEngineID一般來說是同一個值的。

         這是RFC文檔中定義的命令相應器訪問context的結構圖,從這個圖上更容易理解context的概念:

 

         Context

         從這個圖中可以看出,默認contextName””

 

         按照我的經驗,普通的SNMP應用只有一個context

         如有錯誤的地方,請給與指教。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章