对SNMP的MIB总算有所了解

  MRTG用了多年,也搞过一段RRDTool和Cacti做监控画图,但是一直都对SNMP的MIB库定义感到模棱两可,尤其那堆类似 .1.3.6.1.2.1.6.9.0 的数字感到迷惑,这回收集了一些资料,好好整理了一下,自己感觉清晰了不少,把收集整理的资料做个笔记,也分享给朋友。

SNMP协议介绍
  简单网络管理协议(SNMP:Simple Network Management Protocol)是由互联网工程任务组(IETF:Internet Engineering Task Force )定义的一套网络管理协议。该协议基于简单网关监视协议(SGMP:Simple Gateway Monitor Protocol)。利用SNMP,一个管理工作站可以远程管理所有支持这种协议的网络设备,包括监视网络状态、修改网络设备配置、接收网络事件警告等。虽然SNMP开始是面向基于IP的网络管理,但作为一个工业标准也被成功用于电话网络管理。

1. SNMP基本原理
  SNMP采用了Client/Server模型的特殊形式:代理/管理站模型。对网络的管理与维护是通过管理工作站与SNMP代理间的交互工作完成的。每个SNMP从代理负责回答SNMP管理工作站(主代理)关于MIB定义信息的各种查询。下图10是NMS公司网络产品中SNMP协议的实现模型。

mib0

  SNMP代理和管理站通过SNMP协议中的标准消息进行通信,每个消息都是一个单独的数据报。SNMP使用UDP(用户数据报协议)作为第四层协议(传输协议),进行无连接操作。SNMP消息报文包含两个部分:SNMP报头和协议数据单元PDU。数据报结构如下图

mib1

  版本识别符(version identifier):确保SNMP代理使用相同的协议,每个SNMP代理都直接抛弃与自己协议版本不同的数据报。

  团体名(Community Name):用于SNMP从代理对SNMP管理站进行认证;如果网络配置成要求验证时,SNMP从代理将对团体名和管理站的IP地址进行认证,如果失败,SNMP从代理将向管理站发送一个认证失败的Trap消息

  协议数据单元(PDU):其中PDU指明了SNMP的消息类型及其相关参数。

2. 管理信息库MIB
IETF规定的管理信息库MIB(由中定义了可访问的网络设备及其属性,由对象识别符(OID:Object Identifier)唯一指定。MIB是一个树形结构,SNMP协议消息通过遍历MIB树形目录中的节点来访问网络中的设备。  
下图给出了NMS系统中SNMP可访问网络设备的对象识别树(OID:Object Identifier)结构。

mib2

  下图给出了对一个DS1线路状态进行查询的OID设置例子。

mib3

3. SNMP的五种消息类型

  SNMP中定义了五种消息类型:Get-Request、Get-Response、Get-Next-Request、Set-Request、Trap

  • Get-Request 、Get-Next-Request与Get-Response   
    SNMP管理站用Get-Request消息从拥有SNMP代理的网络设备中检索信息,而SNMP代理则用Get-Response消息响应。Get-Next-Request用于和Get-Request组合起来查询特定的表对象中的列元素。如:首先通过下面的原语获得所要查询的设备的接口数:
    {iso org(3) dod(6) internet(1) mgmt(2) mib(1) interfaces(2) ifNumber(2)}
    后再通过下面的原语,进行查询(其中第一次用Get-Request,其后用Get-Next-Request):
    {iso org(3) dod(6) internet(1) mgmt(2) mib(1) interfaces(2) ifTable(2)}
  • Set-Request
    SNMP管理站用Set-Request 可以对网络设备进行远程配置(包括设备名、设备属性、删除设备或使某一个设备属性有效/无效等)。
  • Trap
    SNMP代理使用Trap向SNMP管理站发送非请求消息,一般用于描述某一事件的发生。

SNMP管理信息库MIB

  管理信息库MIB指明了网络元素所维持的变量(即能够被管理进程查询和设置的信息)。MIB给出了一个网络中所有可能的被管理对象的集合的数据结构。SNMP的管理信息库采用和域名系统DNS相似的树型结构,它的根在最上面,根没有名字。下图画的是管理信息库的一部分,它又称为对象命名(objectnamingtree)。

mib4

  管理信息库的对象命名举例

  对象命名树的顶级对象有三个,即ISO、ITU-T和这两个组织的联合体。在ISO的下面有4个结点,其中的饿一个(标号3)是被标识的组织。在其下面有一个美国国防部(Department of Defense)的子树(标号是6),再下面就是Internet(标号是1)。在只讨论Internet中的对象时,可只画出Internet以下的子树(图中带阴影的虚线方框),并在Internet结点旁边标注上{1.3.6.1}即可。 在Internet结点下面的第二个结点是mgmt(管理),标号是2。再下面是管理信息库,原先的结点名是mib。1991年定义了新的版本MIB-II,故结点名现改为mib-2,其标识为{1.3.6.1.2.1},或{Internet(1) .2.1}。这种标识为对象标识符。
  最初的结点mib将其所管理的信息分为8个类别,见表1。现在de mib-2所包含的信息类别已超过40个。

  表1 最初的结点mib管理的信息类别

mib5

  应当指出,MIB的定义与具体的网络管理协议无关,这对于厂商和用户都有利。厂商可以在产品(如路由器)中包含SNMP代理软件,并保证在定义新的MIB项目后该软件仍遵守标准。用户可以使用同一网络管理客户软件来管理具有不同版本的MIB的多个路由器。当然,一个没有新的MIB项目的路由器不能提供这些项目的信息。

  这里要提一下MIB中的对象{1.3.6.1.4.1},即enterprises(企业),其所属结点数已超过3000。例如IBM为11.3.6.1.4.1.2},Cisco为{1.3.6.1.4.1.9},Novell为{1.3.6.1.4.1.23}等。世界上任何一个公司、学校只要用电子邮件发往iana-mib@isi.edu进行申请即可获得一个结点名。这样各厂家就可以定义自己的产品的被管理对象名,使它能用SNMP进行管理。

Category: 其他技术
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
No Responses
  1. minecraft says:

    Admiring the hard work you put into your site and in depth information you offer.
    It’s awesome to come across a blog every once in a while that isn’t the same outdated
    rehashed information. Excellent read! I’ve bookmarked your
    site and I’m including your RSS feeds to my Google account.

  2. minecraft says:

    It’s actually very complicated in this busy life to listen news on Television, thus I only use web for that purpose, and obtain the most recent information.

  3. minecraft says:

    Hey would you mind stating which blog platform you’re working with?
    I’m going to start my own blog in the near future but
    I’m having a tough time making a decision between BlogEngine/Wordpress/B2evolution and
    Drupal. The reason I ask is because your design and style seems different
    then most blogs and I’m looking for something unique.
    P.S My apologies for being off-topic but I had to ask!

  4. minecraft says:

    I believe that is one of the so much vital information for me.
    And i am satisfied reading your article. But should remark on few basic things,
    The website style is perfect, the articles is in reality great :
    D. Excellent activity, cheers

  5. For the reason that the admin of this web site is working, no
    doubt very quickly it will be famous, due to its quality contents.

  6. Aw, this was an exceptionally good post. Finding the time and actual effort to create a top notch article… but what
    can I say… I procrastinate a whole lot and don’t seem to get nearly anything done.

  7. Coconut Oil says:

    Valuable information. Lucky me I discovered your web site by accident, and I am stunned
    why this twist of fate did not happened in advance!
    I bookmarked it.

  8. Coconut Oil says:

    Just desire to say your article is as astonishing. The clarity in your
    post is just cool and i can assume you are an expert on this subject.
    Fine with your permission allow me to grab your feed to keep up to date with forthcoming post.

    Thanks a million and please continue the rewarding work.

  9. What a information of un-ambiguity and preserveness of precious know-how about
    unpredicted emotions.

  10. Coconut Oil says:

    I feel that is one of the so much significant information for me.
    And i’m satisfied reading your article. But wanna commentary on few general
    issues, The site taste is ideal, the articles is in point of fact nice
    : D. Excellent job, cheers

  11. Magnificent goods from you, man. I’ve understand your stuff previous
    to and you’re just extremely wonderful. I actually like what you’ve acquired
    here, really like what you’re stating and the way in which you say it.
    You make it enjoyable and you still take care of to keep it wise.
    I can’t wait to read far more from you.
    This is actually a tremendous website.

  12. Quest bars cheap fitnesstipsnew1 quest bars cheap 516999410492780544 quest bars cheap
    Hi everyone, it’s my first visit at this site, and piece of
    writing is in fact fruitful in favor of me, keep up posting these types
    of articles. Quest bars cheap fitnesstipsnew1 quest bars cheap 516999410492780544 quest bars cheap

  13. What’s up, its good paragraph about media print, we all be
    familiar with media is a enormous source of information.

  14. Sling TV says:

    Hi there! Do you use Twitter? I’d like to follow you if that would be ok.

    I’m absolutely enjoying your blog and look forward to new
    updates.

  15. Thanks very interesting blog!

  16. Sling TV says:

    I love it when folks come together and share opinions.
    Great website, stick with it!

  17. Sling TV says:

    Every weekend i used to visit this site, as i want enjoyment, for the
    reason that this this site conations in fact fastidious funny data too.

  18. Hola! I’ve been following your weblog for a while now and finally got the courage to
    go ahead and give you a shout out from Austin Texas!
    Just wanted to mention keep up the good work!

  19. Hi there, just wanted to say, I enjoyed this article.

    It was helpful. Keep on posting!

  20. Everything is very open with a really clear explanation of the challenges.
    It was definitely informative. Your site is very
    useful. Many thanks for sharing!

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image