Structure and Identification of Management Information for TCP/IP-based Internets SNMP Traps

 https://www.rfc-editor.org/rfc/rfc1157#section-3

3.  The SNMP Architecture

   Implicit in the SNMP architectural model is a collection of network
   management stations and network elements.  Network management
   stations execute management applications which monitor and control
   network elements.  Network elements are devices such as hosts,
   gateways, terminal servers, and the like, which have management
   agents responsible for performing the network management functions
   requested by the network management stations.  The Simple Network
   Management Protocol (SNMP) is used to communicate management
   information between the network management stations and the agents in
   the network elements.
3.2.6.3.  Identification of Object Instances
  The type-specific naming of object instances is defined below for a
   number of classes of object types.  Instances of an object type to
   which none of the following naming conventions are applicable are
   named by OBJECT IDENTIFIERs of the form x.0, where x is the name of
   said object type in the MIB definition.

   For example, suppose one wanted to identify an instance of the
   variable sysDescr The object class for sysDescr is:

             iso org dod internet mgmt mib system sysDescr
              1   3   6     1      2    1    1       1

   Hence, the object type, x, would be 1.3.6.1.2.1.1.1 to which is
   appended an instance sub-identifier of 0.  That is, 1.3.6.1.2.1.1.1.0
   identifies the one and only instance of sysDescr.

 

https://www.rfc-editor.org/rfc/rfc1155

   Structure and Identification of Management Information for TCP/IP-based Internets

https://www.rfc-editor.org/rfc/rfc1156

  Management Information Base for Network Management of TCP/IP-based internets

https://www.rfc-editor.org/rfc/rfc1157

 A Simple Network Management Protocol (SNMP)

https://www.rfc-editor.org/rfc/rfc1158

     Management Information Base for Network Management
                       of TCP/IP-based internets:
                                 MIB-II

 

https://www.rfc-editor.org/rfc/rfc1155

Structure and Identification of Management Information for TCP/IP-based Internets

 

   This memo specifies a Standard Protocol for the Internet community.
   Its status is "Recommended".  TCP/IP implementations in the Internet
   which are network manageable are expected to adopt and implement this
   specification.

   The Internet Activities Board recommends that all IP and TCP
   implementations be network manageable.  This implies implementation
   of the Internet MIB (RFC-1156) and at least one of the two
   recommended management protocols SNMP (RFC-1157) or CMOT (RFC-1095).
   It should be noted that, at this time, SNMP is a full Internet
   standard and CMOT is a draft standard.  See also the Host and Gateway
   Requirements RFCs for more specific information on the applicability
   of this standard.

 

 

 


-v 1 TRAP-PARAMETERS:
enterprise-oid agent trap-type specific-type uptime [OID TYPE VALUE]...
or
-v 2 TRAP-PARAMETERS:
uptime trapoid [OID TYPE VALUE] ...

 

 

什么是SNMP?为什么需要SNMP? - 华为 https://info.support.huawei.com/info-finder/encyclopedia/zh/SNMP.html

SNMP版本

SNMP有三种版本:SNMPv1,SNMPv2c和SNMPv3。

  • SNMPv1:SNMP的第一个版本,它提供了一种监控和管理计算机网络的系统方法,它基于团体名认证,安全性较差,且返回报文的错误码也较少。它在RFC 1155和RFC 1157中定义。
  • SNMPv2c:第二个版本SNMPv2c引入了GetBulk和Inform操作,支持更多的标准错误码信息,支持更多的数据类型。它在RFC 1901,RFC 1905和RFC 1906中定义。
  • SNMPv3:鉴于SNMPv2c在安全性方面没有得到改善,IETF颁布了SNMPv3版本,提供了基于USM(User Security Module)的认证加密和基于VACM(View-based Access Control Model)的访问控制,是迄今为止最安全的版本。SNMPv3在RFC 1905,RFC 1906,RFC 2571,RFC 2572,RFC 2574和RFC 2575中定义。

SNMP端口

SNMP端口是SNMP通信端点,SNMP消息传输通过UDP进行,通常使用UDP端口号161/162。有时也使用传输层安全性(TLS)或数据报传输层安全性(DTLS)协议,端口使用情况如下表所示。

表1-1 SNMP端口使用介绍

过程

协议

端口号

代理进程接收请求信息

UDP协议

161

NMS与代理进程之间的通信

UDP协议

161

NMS接收通知信息

UDP协议

162

代理进程生成通知信息

-

任何可用的端口

接收请求信息

TLS/DTLS

10161

接收通知信息

TLS/DTLS

10162

 

SNMP如何工作?

一旦网络中启动SNMP协议,NMS作为整个网络的网管中心,会对设备进行管理。每个被管理设备都包含驻留在设备上的Agent、多个被管对象和MIB,NMS通过与运行在被管理设备上的Agent交互,由Agent通过对设备端的MIB的操作,完成NMS的指令。SNMP的工作原理是将协议数据单元(也称为SNMP GET请求)发送到响应SNMP的网络设备。用户通过网络监控工具可以跟踪所有通信过程,并从SNMP获取数据。

SNMP规定了几个操作类型来完成各组件之间的信息交换,如下表所示:

表1-2 SNMP操作类型

操作类型

描述

备注

Get

Get操作可以从Agent中提取一个或多个参数值。

-

GetNext

GetNext操作可以从Agent中按照字典序提取下一个参数值。

-

Set

Set操作可以设置Agent的一个或多个参数值。

-

Response

Response操作可以返回一个或多个参数值。这个操作是由Agent发出的,它是GetRequest、GetNextRequest、SetRequest和GetBulkRequest四种操作的响应操作。Agent接收到来自NMS的Get/Set指令后,通过MIB完成相应的查询/修改操作,然后利用Response操作将信息回应给NMS。

-

Trap

Trap信息是Agent主动向NMS发出的信息,告知管理进程设备端出现的情况。

-

GetBulk

GetBulk操作实现了NMS对被管理设备的信息群查询。

SNMPv1版本不支持GetBulk操作

Inform

InformRequest也是被管理设备向NMS主动发送告警。与Trap告警不同的是,被管理设备发送Inform告警后,需要NMS回复InformResponse来进行确认。

SNMPv1版本不支持Inform操作

SNMP Traps

SNMP Traps是指SNMP Agent主动将设备产生的告警或事件上报给NMS,以便网络管理员及时了解设备当前运行的状态。

SNMP Agent上报SNMP Traps有两种方式:Trap和Inform。Trap和Inform的区别在于,SNMP Agent通过Inform向NMS发送告警或事件后,NMS需要回复InformResponse进行确认。

Trap操作工作原理

Trap不属于NMS对被管理设备的基本操作,它是被管理设备的自发行为。当被管理设备达到告警的触发条件时,会通过SNMP Agent向NMS发送Trap消息,告知设备侧出现的异常情况,便于网络管理人员及时处理。例如被管理设备热启动后,SNMP Agent会向NMS发送warmStart的Trap。

这种Trap信息是受限制的。只有在设备端的模块达到模块预定义的告警触发条件时,SNMP Agent才会向管理进程报告。这种方法的好处是仅在严重事件发生时才发送Trap信息,减少报文交互产生的流量。

Inform操作工作原理

Inform操作也是被管理设备向NMS主动发送告警。与Trap告警不同的是,被管理设备发送Inform告警后,需要NMS进行接收确认。如果被管理设备没有收到确认信息则:

  1. 将告警或事件暂时保存在Inform缓存中。
  2. 重复发送该告警或事件,直到NMS确认收到该告警或者发送次数达到最大重传次数。
  3. 被管设备上会生成相应的告警或事件日志。

 

 NetEngine AR 产品文档 https://support.huawei.com/hedex/hdx.do?docid=EDOC1100087046&id=ZH-CN_TASK_0177878325&lang=zh

版本演进

1990年5月,RFC 1157定义了SNMP的第一个版本SNMPv1。RFC 1157提供了一种监控和管理计算机网络的系统方法。SNMPv1基于团体名认证,安全性较差,且返回报文的错误码也较少。

1996年,IETF颁布了RFC 1901,定义了SNMP的第二个版本SNMPv2c。SNMPv2c中引入了GetBulk和Inform操作,支持更多的标准错误码信息,支持更多的数据类型(Counter64、Counter32)。

鉴于SNMPv2c在安全性方面没有得到改善,IETF又颁布了SNMPv3的版本,提供了基于USM(User Security Module)的认证加密和基于VACM(View-based Access Control Model)的访问控制。

 

 

发送trap

    1. 用于发送trap的命令:
      snmptrap -v 1 -c public 127.0.0.1 '.1.3.6.1.6.3.1.1.5.3' '0.0.0.0' 6 33 '55' .1.3.6.1.6.3.1.1.5.3 s "teststring000"
    2. 接收到的trap:
      15:48:18 2011/07/26 .1.3.6.1.6.3.1.1.5.3.0.33 Normal "General event" localhost - ZBXTRAP 127.0.0.1 127.0.0.1
    3. 测试监控项的值:
      15:48:18 2011/07/26 .1.3.6.1.6.3.1.1.5.3.0.33 Normal "General event" localhost - 127.0.0.1

 

Trap Handlers

The snmptrapd utility also has the ability to execute other programs on the reception of a trap. This is controlled by the traphandle directive, with the syntax

 traphandle OID command

Notice, that this only takes an OID to determine which trap (or notification) is received. This means that SNMPv1 traps, which have a trap type and specific type, need to be represented in SNMPv2 format, which is described in RFC 2089.

Matching SNMPv1 OIDs

SNMPv1 traps fall into two broad categories: generic and enterprise specific. Generic traps use trap types 0 through 5, and do not use the specific type. To match a generic trap, the traphandle OID should be the SNMPv2-MIB::snmpTraps OID, with an additional final OID of the trap type + 1. For example, to match linkDown traps (trap type 2), the correct OID would be "1.3.6.1.6.3.1.1.5.3" (or SNMPv2-MIB::snmpTraps.3, which is also IF-MIB::linkDown).

 SNMPv2-MIB::snmpTraps   1.3.6.1.6.3.1.1.5
  SNMPv2-MIB::coldStart             1.3.6.1.6.3.1.1.5.1
  SNMPv2-MIB::warmStart             1.3.6.1.6.3.1.1.5.2
  IF-MIB::linkDown                  1.3.6.1.6.3.1.1.5.3
  IF-MIB::linkUp                    1.3.6.1.6.3.1.1.5.4
  SNMPv2-MIB::authenticationFailure 1.3.6.1.6.3.1.1.5.5

When the trap type is 6, the trap is an enterprise specific trap. When matching these traps, the traphandle OID is constructed using the enterprise OID and specific type specified in the trap. Earlier in the tutorial, we sent a SNMPv1 enterprise specific trap with an enterprise OID of UCD-TRAP-TEST-MIB::demotraps, a trap type of 6 and a specific type of 17. To match this trap type, the traphandle OID should be the enterprise OID, plus 0, plus the specific type. So the correct OID would be ".1.3.6.1.4.1.2021.13.990.0.17" (or UCD-TRAP-TEST-MIB::demoTrap).

Matching SNMPv2 OIDs

SNMPv2 traps and informs are much easier, because they include the correct OID in the SNMPv2-MIB::snmpTrapOID.0 variable in the trap.

Example handler script

The command specifies a command to be executed by snmptrapd upon reception by the command. This command is executed with the data of the trap as its standard input. The first line is the host name, the second the IP address of the trap sender, and the following lines consists of an OID VALUE pair with the data from the received trap.

A simple shell script to be called from snmptrapd is the following:

 #!/bin/sh
 
 read host
 read ip
 vars=
 
 while read oid val
 do
   if [ "$vars" = "" ]
   then
     vars="$oid = $val"
   else
     vars="$vars, $oid = $val"
   fi
 done
 
 echo trap: $1 $host $ip $vars

Now, given the following sample snmptrapd.conf file,

 # the generic traps
 traphandle SNMPv2-MIB::coldStart    /home/nba/bin/traps cold
 traphandle SNMPv2-MIB::warmStart    /home/nba/bin/traps warm
 traphandle IF-MIB::linkDown         /home/nba/bin/traps down
 traphandle IF-MIB::linkUp           /home/nba/bin/traps up
 traphandle SNMPv2-MIB::authenticationFailure /home/nba/bin/traps auth
 # this one is deprecated
 traphandle .1.3.6.1.6.3.1.1.5.6     /home/nba/bin/traps egp-neighbor-loss
 
 # enterprise specific traps
 traphandle UCD-TRAP-TEST-MIB::demoTrap /home/nba/bin/traps demo-trap
 traphandle UCD-NOTIFICATION-TEST-MIB::demoNotif /home/nba/bin/traps demo-notif

The following snmptrap invocation, to issue a generic Link down trap (OID 1.3.6.1.6.3.1.1.5.3),

 % snmptrap -v 1 -c public localhost TRAP-TEST-MIB::demotraps localhost 2 0 "" \
       IF-MIB::ifIndex i 1

results in the following output from snmptrapd:

 1999-11-13 12:46:49 localhost [127.0.0.1]  TRAP-TEST-MIB::traps:
       Link Down Trap (0) Uptime: 1 day, 18:54:46.27
       IF-MIB::ifIndex.0 = 1

and the following output from the handler:

 trap: down localhost 127.0.0.1 SNMPv2-MIB::sysUpTime = 1:18:54:46.27, SNMPv2-MIB::snmpTrapOID = IF-MIB::linkDown, IF-MIB::ifIndex.0 = 1, SNMPv2-MIB::snmpTrapEnterprise = TRAP-TEST-MIB::traps

and issuing our enterprise specific trap (.1.3.6.1.4.1.2021.13.990.0.17) gives this output from our handler:

 trap: demoTrap localhost 127.0.0.1 SNMPv2-MIB::sysUpTime = 1:19:00:48.01, SNMPv2-MIB::snmpTrapOID = UCD-TRAP-TEST-MIB::demoTrap, SNMPv2-MIB::sysLocation.0 = "just here", SNMPv2-MIB::snmpTrapEnterprise = UCD-TRAP-TEST-MIB::traps

and finally our enterprise specific notification:

 trap: demoNotif localhost 127.0.0.1 SNMPv2-MIB::sysUpTime.0 = 1:19:02:06.33, SNMPv2-MIB::snmpTrapOID.0 = UCD-NOTIFICATION-TEST-MIB::demoNotif, SNMPv2-MIB::sysLocation.0 = "just here"

 

 

rfc1157 https://datatracker.ietf.org/doc/html/rfc1157/#section-4.1.6

4.1.6.  The Trap-PDU

   The form of the Trap-PDU is:

     Trap-PDU ::=
         [4]

              IMPLICIT SEQUENCE {
                 enterprise          -- type of object generating
                                     -- trap, see sysObjectID in [5]
                     OBJECT IDENTIFIER,

                 agent-addr          -- address of object generating
                     NetworkAddress, -- trap

                 generic-trap        -- generic trap type
                     INTEGER {
                         coldStart(0),
                         warmStart(1),
                         linkDown(2),
                         linkUp(3),
                         authenticationFailure(4),
                         egpNeighborLoss(5),
                         enterpriseSpecific(6)
                     },

                 specific-trap     -- specific code, present even
                     INTEGER,      -- if generic-trap is not
                                   -- enterpriseSpecific

                 time-stamp        -- time elapsed between the last
                   TimeTicks,      -- (re)initialization of the network
                                   -- entity and the generation of the
                                      trap

                 variable-bindings   -- "interesting" information
                      VarBindList
             }


   The Trap-PDU is generated by a protocol entity only at the request of
   the SNMP application entity.  The means by which an SNMP application
   entity selects the destination addresses of the SNMP application
   entities is implementation-specific.

   Upon receipt of the Trap-PDU, the receiving protocol entity presents
   its contents to its SNMP application entity.




Case, Fedor, Schoffstall, & Davin                              [Page 27]


RFC 1157                          SNMP                          May 1990


   The significance of the variable-bindings component of the Trap-PDU
   is implementation-specific.

   Interpretations of the value of the generic-trap field are:

4.1.6.1.  The coldStart Trap

   A coldStart(0) trap signifies that the sending protocol entity is
   reinitializing itself such that the agent's configuration or the
   protocol entity implementation may be altered.

4.1.6.2.  The warmStart Trap

   A warmStart(1) trap signifies that the sending protocol entity is
   reinitializing itself such that neither the agent configuration nor
   the protocol entity implementation is altered.

4.1.6.3.  The linkDown Trap

   A linkDown(2) trap signifies that the sending protocol entity
   recognizes a failure in one of the communication links represented in
   the agent's configuration.

   The Trap-PDU of type linkDown contains as the first element of its
   variable-bindings, the name and value of the ifIndex instance for the
   affected interface.

4.1.6.4.  The linkUp Trap

   A linkUp(3) trap signifies that the sending protocol entity
   recognizes that one of the communication links represented in the
   agent's configuration has come up.

   The Trap-PDU of type linkUp contains as the first element of its
   variable-bindings, the name and value of the ifIndex instance for the
   affected interface.

4.1.6.5.  The authenticationFailure Trap

   An authenticationFailure(4) trap signifies that the sending protocol
   entity is the addressee of a protocol message that is not properly
   authenticated.  While implementations of the SNMP must be capable of
   generating this trap, they must also be capable of suppressing the
   emission of such traps via an implementation-specific mechanism.

4.1.6.6.  The egpNeighborLoss Trap

   An egpNeighborLoss(5) trap signifies that an EGP neighbor for whom



Case, Fedor, Schoffstall, & Davin                              [Page 28]


RFC 1157                          SNMP                          May 1990


   the sending protocol entity was an EGP peer has been marked down and
   the peer relationship no longer obtains.

   The Trap-PDU of type egpNeighborLoss contains as the first element of
   its variable-bindings, the name and value of the egpNeighAddr
   instance for the affected neighbor.

4.1.6.7.  The enterpriseSpecific Trap

   A enterpriseSpecific(6) trap signifies that the sending protocol
   entity recognizes that some enterprise-specific event has occurred.
   The specific-trap field identifies the particular trap which
   occurred.

 rfc1907 https://datatracker.ietf.org/doc/html/rfc1907

 

 

Understanding Simple Network Management Protocol (SNMP) Traps - Cisco https://www.cisco.com/c/en/us/support/docs/ip/simple-network-management-protocol-snmp/7244-snmp-trap.html

Introduction

This document provides an introduction to SNMP traps. It shows how SNMP traps are used and the role they play in the management of a data network.

SNMP traps enable an agent to notify the management station of significant events by way of an unsolicited SNMP message.

In this diagram, the setup on the left shows a network management system that polls information and gets a response. The setup on the right shows an agent that sends an unsolicited or asynchronous trap to the network management system (NMS).

 

 

Use SNMP Traps

SNMPv1 (Simple Network Management Protocol) and SNMPv2c, along with the associated Management Information Base (MIB), encourage trap-directed notification.

The idea behind trap-directed notification is that if a manager is responsible for a large number of devices, and each device has a large number of objects, it is impractical for the manager to poll or request information from every object on every device. The solution is for each agent on the managed device to notify the manager without solicitation. It does this by sending a message known as a trap of the event.

After the manager receives the event, the manager displays it and can choose to take an action based on the event. For instance, the manager can poll the agent directly, or poll other associated device agents to get a better understanding of the event.

Trap-directed notification can result in substantial savings of network and agent resources by eliminating the need for frivolous SNMP requests. However, it is not possible to totally eliminate SNMP polling. SNMP requests are required for discovery and topology changes. In addition, a managed device agent can not send a trap, if the device has had a catastrophic outage.

SNMPv1 traps are defined in RFC 1157, with these fields:

  • Enterprise—Identifies the type of managed object that generates the trap.

  • Agent address—Provides the address of the managed object that generates the trap.

  • Generic trap type—Indicates one of a number of generic trap types.

  • Specific trap code—Indicates one of a number of specific trap codes.

  • Time stamp—Provides the amount of time that has elapsed between the last network reinitialization and generation of the trap.

  • Variable bindings—The data field of the trap that contains PDU. Each variable binding associates a particular MIB object instance with its current value.

Standard generic traps are: coldStart, warmStart, linkDown, linkUp, authenticationFailure, egpNeighborLoss. For generic SNMPv1 traps, Enterprise field contains value of sysObjectID  of the device that sends trap. For vendor specific traps, Generic trap type field is set to enterpriseSpecific(6). Cisco implemented its own specific traps in a non-conventional way. Instead of having the trap Enterprise field still the sysObjectID  and having the Specific trap code to identify all specific traps supported by all Cisco devices, Cisco implemented trap identification using various trap Enterprise and Specific trap code fields. You can see the actual values from the SNMP Object Navigator . Also, Cisco redefined some generic traps in CISCO-GENERAL-TRAPS MIB  with the addition of more bound variables. For these traps, Generic trap type is kept the same and not set to enterpriseSpecific(6).

In SNMPv2c trap is defined as NOTIFICATION and formatted differently compared to SNMPv1. It has these parameters:

  • sysUpTime—This is the same as Time stamp in SNMPv1 trap.

  • snmpTrapOID  —Trap identification field. For generic traps, values are defined in RFC 1907, for vendor specific traps snmpTrapOID is essentially a concatenation of the SNMPv1 Enterprise parameter and two additional sub-identifiers, '0', and the SNMPv1 Specific trap code parameter.

  • VarBindList—This is a list of variable-bindings.

In order for a management system to understand a trap sent to it by an agent, the management system must know what the object identifier (OID) defines. Therefore, it must have the MIB for that trap loaded. This provides the correct OID information so that the network management system can understand the traps sent to it.

For traps that are supported by Cisco devices in specific MIBs, refer to the Cisco SNMP Object Navigator . This lists the traps available for a specific MIB. In order to receive one of these traps, your Cisco IOS® Software Release must support the MIB listed. In order to find out which MIBs are supported on your Cisco device, visit www.cisco.com/go/mibs . The MIB must be loaded into your network management system. This is commonly referred to as compiling. See your Network Management System (for instance, HP OpenView or NetView) user guide about MIB compiling on your NMS platform. Also refer to SNMP: Frequently Asked Questions About MIBs and MIB Compilers and Loading MIBs.

Additionally, a device does not send a trap to a network management system unless it is configured to do so. A device must know that it should send a trap. The trap destination is usually defined by an IP address, but can be a host name, if the device is set up to query a Domain Name System (DNS) server. In later versions of Cisco IOS software, device administrators can choose which traps they would like send. For information on how to configure a Cisco device for SNMP, and how to send traps, refer to correspondent device configuration guides and Basic Dial NMS Implementation GuideCisco IOS SNMP Traps Supported and How to Configure Them and How-To Support and Configure Cisco CatalystOS SNMP Traps.

Note: The manager typically receives SNMP notifications (TRAPs and INFORMs) on UDP port number 162.

Examples of Traps Sent by Cisco IOS

This section contains some examples of traps sent by Cisco IOS, taken with debug snmp packet.

SNMPv1 generic trap, redefined by Cisco:

Nov 21 07:44:17: %LINK-3-UPDOWN: Interface Loopback1, changed state to up 
4d23h: SNMP: Queuing packet to 172.17.246.162 
4d23h: SNMP: V1 Trap, ent products.45, addr 172.17.246.9, gentrap 3, spectrap 0 
 ifEntry.1.23 = 23 
 ifEntry.2.23 = Loopback1
 ifEntry.3.23 = 24 
 lifEntry.20.23 = up 

This output shows the Cisco redefined linkUp trap from CISCO-GENERAL-TRAPS MIB with four bound variables. It has these fields:

  • Enterprise = products.45 (sysObjectID  of the device sending trap, in this example, it is c7507 router)

  • Generic trap type = 3 (linkUp)

  • Specific trap code = 0

SNMPv1 Cisco specific trap:

4d23h: SNMP: Queuing packet to 172.17.246.162 
4d23h: SNMP: V1 Trap, ent ciscoSyslogMIB.2, addr 172.17.246.9, gentrap 6, spectrap 1 
 clogHistoryEntry.2.954 = LINK 
 clogHistoryEntry.3.954 = 4 
 clogHistoryEntry.4.954 = UPDOWN 
 clogHistoryEntry.5.954 = Interface Loopback1, changed state to up 
 clogHistoryEntry.6.954 = 43021184 

This output shows the Cisco specific clogMessageGenerated trap from CISCO-SYSLOG-MIB  with five bound variables. It has these fields:

  • Enterprise = Enterprise value of clogMessageGenerated trap

  • Generic trap type = 6 (enterpriseSpecific)

  • Specific trap code = 1 (specific trap code of clogMessageGenerated)

SNMPv2c Cisco specific trap:

4d23h: SNMP: Queuing packet to 172.17.246.162 
4d23h: SNMP: V2 Trap, reqid 2, errstat 0, erridx 0 
 sysUpTime.0 = 43053404 
 snmpTrapOID.0 =  
 clogHistoryEntry.2.958 = SYS 
 clogHistoryEntry.3.958 = 6 
 clogHistoryEntry.4.958 = CONFIG_I 
 clogHistoryEntry.5.958 = Configured from console by vty0 (10.10.10.10) 
 clogHistoryEntry.6.958 = 43053403 

This output shows the Cisco specific ciscoConfigManEvent  SNMPv2c notification from CISCO-CONFIG-MAN-MIB  with three bound variables:

This trap can be used if there has been any changes done to the device's configuration. The values of last two components determine if a show command was issued or if the configuration was touched.

6506E#term mon
6506E#debug snmp packet
SNMP packet debugging is on

6506E#sh run
Building configuration...
...
6506E#
19:24:18: SNMP: Queuing packet to 10.198.28.80
19:24:18: SNMP: V2 Trap, reqid 2, errstat 0, erridx 0
sysUpTime.0 = 6981747
snmpTrapOID.0 = ciscoConfigManMIB.2.0.1
ccmHistoryEventEntry.3.100 = 1 

!--- 1 -> commandLine. Executed via CLI.

ccmHistoryEventEntry.4.100 = 3 

!--- 3 -> running

ccmHistoryEventEntry.5.100 = 2 

!--- 2 -> commandSource. Show command was executed.

6506E#term mon
6506E#debug snmp packet
SNMP packet debugging is on

6506E#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
6506E(config)#exit

22:57:37: SNMP: Queuing packet to 10.198.28.80
22:57:37: SNMP: V2 Trap, reqid 2, errstat 0, erridx 0
 sysUpTime.0 = 8261709
 snmpTrapOID.0 = ciscoConfigManMIB.2.0.1
 ccmHistoryEventEntry.3.108 = 1 

!--- 1 -> commandLine. Executed via CLI.

 ccmHistoryEventEntry.4.108 = 2 

!--- 2 -> commandSource

 ccmHistoryEventEntry.5.108 = 3 

!--- 3 -> running. Change was destined to the running configuration.

 

IP数据报

UDP数据报

SNMP报文

公共SNMP首部get/set首部get/set变量部分

IP首部UDP首部"版本

(0)"共同体"PDU类型

(0-3)"请求标识"差错状态

(0-5)"差错索引名称值名称值...

 

 

"PDU类型

(4)"企业代理地址"trap类型

(0-6)"特定代码时间戳名称值...

trap首部有意义的变量

SNMP报文的格式

 

 

PDU类型名称差错状态名称描述

0get-request0noError没有进程

1get-nextrequest1tooBig代理进程无法把响应放在一个SNMP消息中发送

2get-response2noSuchName操作一个不存在的变量

3set-request3badValueset操作的值或语义有错误

4trap4readOnly管理进程试图修改一个只读变量

SNMP报文中的PDU类型5genErr其他错误

SNMP差错状态的值

 

 

trap类型名称描述

0clodStart代理进程对自己初始化

1warmStart代理进程对自己重新初始化

2linkDown"一个接口从影工作状态变为故障状态,

报文中的第一个变量标识次接口"

3linkUp"一个接口从影故障状态变为工作状态,

报文中的第一个变量标识次接口"

4authenticationFailure从SNMP管理进程收到无效共同体的报文

5egpNeighborLoss一个FGP邻站已变为故障状态。报文中的第一个变量包含此邻站的IP地址

6enterpriseSpecific在这个特定的代码段中查找trap信息

trap的类型

 

 

 

 

 

 

 

 

 

 

 

 

 第25章 SNMP:简单网络管理协议_《TCP/IP详解 卷1:协议》_即时通讯网(52im.net) _即时通讯开发者社区! http://docs.52im.net/extend/docs/book/tcpip/vol1/25/

 

What is SNMP? | SNMP Tutorial – Protocol – Monitoring – Agent https://www.manageengine.com/network-monitoring/what-is-snmp.html

SNMP tutorial

This tutorial is an effort to explain in brief about

What is SNMP?

Simple Network Management Protocol (SNMP) is an application–layer protocol defined by the Internet Architecture Board (IAB) in RFC1157 for exchanging management information between network devices. It is a part of Transmission Control Protocol⁄Internet Protocol (TCP⁄IP) protocol suite.

SNMP is one of the widely accepted network protocols to manage and monitor network elements. Most of the professional–grade network elements come with bundled SNMP agent. These agents have to be enabled and configured to communicate with the network monitoring tools or network management system (NMS).

SNMP basic components and their functionalities

SNMP consists of

SNMP Manager:

A manager or management system is a separate entity that is responsible to communicate with the SNMP agent implemented network devices. This is typically a computer that is used to run one or more network management systems.

SNMP Manager’s key functions
  • Queries agents
  • Gets responses from agents
  • Sets variables in agents
  • Acknowledges asynchronous events from agents

Managed Devices:

A managed device or the network element is a part of the network that requires some form of monitoring and management e.g. routers, switches, servers, workstations, printers, UPSs, etc...

SNMP Agent:

The agent is a program that is packaged within the network element. Enabling the agent allows it to collect the management information database from the device locally and makes it available to the SNMP manager, when it is queried for. These agents could be standard (e.g. Net-SNMP) or specific to a vendor (e.g. HP insight agent)

SNMP agent’s key functions
  • Collects management information about its local environment
  • Stores and retrieves management information as defined in the MIB.
  • Signals an event to the manager.
  • Acts as a proxy for some non–SNMP manageable network node.

 

Basic SNMP Communication Diagram
What are the basic components of SNMP? - ManageEngine OpManager SNMP

Management Information database or Management Information Base (MIB)

Every SNMP agent maintains an information database describing the managed device parameters. The SNMP manager uses this database to request the agent for specific information and further translates the information as needed for the Network Management System (NMS). This commonly shared database between the Agent and the Manager is called Management Information Base (MIB).

Typically these MIB contains standard set of statistical and control values defined for hardware nodes on a network. SNMP also allows the extension of these standard values with values specific to a particular agent through the use of private MIBs.

In short, MIB files are the set of questions that a SNMP Manager can ask the agent. Agent collects these data locally and stores it, as defined in the MIB. So, the SNMP Manager should be aware of these standard and private questions for every type of agent.

 

SNMP MIB Browser and SNMP Walk Tool

ManageEngine's Suite of Free Tools includes a SNMP MIB Browser which helps to Load/unload MIBs and fetch MIB data of SNMP(v1, v2c, v3) agents. SNMP MIB Browser is a complete tool for monitoring SNMP enabled devices and servers. You can load, view multiple MIB modules and perform GET, GETNEXT and SET SNMP operations. This tool is easy to use and allows you to view, configure and parse SNMP traps. You can also perform SNMP operations from Windows and Linux devices.

 

MIB structure and Object Identifier (Object ID or OID)

Management Information Base (MIB) is a collection of Information for managing network element. The MIBs comprises of managed objects identified by the name Object Identifier (Object ID or OID).

Each Identifier is unique and denotes specific characteristics of a managed device. When queried for, the return value of each identifier could be different e.g. Text, Number, Counter, etc...

There are two types of Managed Object or Object ID: Scalar and Tabular. They could be better understandable with an example

Scalar: Device’s vendor name, the result can be only one. (As definition says: "Scalar Object define a single object instance")

Tabular: CPU utilization of a Quad Processor, this would give me a result for each CPU separately, means there will be 4 results for that particular Object ID. (As definition says: "Tabular object defines multiple related object instance that are grouped together in MIB tables")

Every Object ID is organized hierarchically in MIB. The MIB hierarchy can be represented in a tree structure with individual variable identifier.

A typical object ID will be a dotted list of integers. For example, the OID in RFC1213 for "sysDescr" is .1.3.6.1.2.1.1.1

 

MIB Tree Diagram
SNMP MIB Tutorial - ManageEngine OpManager SNMP
 

Basic commands of SNMP

The simplicity in information exchange has made the SNMP as widely accepted protocol. The main reason being concise set of commands, here are they listed below:

  • GET: The GET operation is a request sent by the manager to the managed device. It is performed to retrieve one or more values from the managed device.
  • GET NEXT: This operation is similar to the GET. The significant difference is that the GET NEXT operation retrieves the value of the next OID in the MIB tree.
  • GET BULK: The GETBULK operation is used to retrieve voluminous data from large MIB table.
  • SET: This operation is used by the managers to modify or assign the value of the Managed device.
  • TRAPS: Unlike the above commands which are initiated from the SNMP Manager, TRAPS are initiated by the Agents. It is a signal to the SNMP Manager by the Agent on the occurrence of an event.
  • INFORM: This command is similar to the TRAP initiated by the Agent, additionally INFORM includes confirmation from the SNMP manager on receiving the message.
  • RESPONSE: It is the command used to carry back the value(s) or signal of actions directed by the SNMP Manager.
 

SNMP Traps:

SNMP traps enable an agent to notify the SNMP manager of significant events by an unsolicited SNMP message. SNMP Trap protocols include current sysUpTime value, an OID identifying the type of trap and optional variable bindings. Destination addressing for SNMP traps is determined in an application-specific manner typically through trap configuration variables in the MIB. The format of the trap message was changed in SNMPv2 and the protocol data units was renamed SNMPv2-Trap. 

Typical SNMP communication

Being the part of TCP⁄ IP protocol suite, the SNMP messages are wrapped as User Datagram Protocol (UDP) and intern wrapped and transmitted in the Internet Protocol. The following diagram will illustrate the four–layer model developed by Department of Defense (DoD).

What is SNMP Manager & Agent? - ManageEngine OpManager SNMP

GET⁄ GET NEXT⁄ GET BULK⁄ SET

How SNMP Monitoring works in Networking? - ManageEngine OpManager SNMP

 

TRAP

SNMP Traps Tutorial - ManageEngine OpManager SNMP

 

INFORM

SNMP Tutorial for beginners - ManageEngine OpManager SNMP

 

By default the SNMP port is 161 and TRAP⁄ INFORM uses SNMP port 162 for communication.
 

SNMP versions

Since the inception SNMP, has gone through significant upgrades. However SNMP Protocol v1 and v2c are the most implemented versions of SNMP. Support to SNMP Protocol v3 has recently started catching up as it is more secured when compare to its older versions, but still it has not reached considerable market share.

SNMPv1:

This is the first version of SNMP protocol, which is defined in RFCs 1155 and 1157

SNMPv2c:

This is the revised protocol, which includes enhancements of SNMPv1 in the areas of protocol packet types, transport mappings, MIB structure elements but using the existing SNMPv1 administration structure ("community based" and hence SNMPv2c). It is defined in RFC 1901, RFC 1905, RFC 1906, RFC 2578.

SNMPv3:

SNMPv3 defines the secure version of the SNMP. SNMPv3 protocol also facilitates remote network monitoring configuration of the SNMP entities. It is defined by RFC 1905, RFC 1906, RFC 3411, RFC 3412, RFC 3414, RFC 3415.

Though each version had matured towards rich functionalities, additional emphasis was given to the security aspect on each upgrade. Here is a small clip on each editions security aspect.

SNMP v1 Community–based security
SNMP v2c Community–based security
SNMP v2u User–based security
SNMP v2 Party–based security
SNMP v3 User–based security

Other useful links

 

 

简单网络管理协议_百度百科 https://baike.baidu.com/item/简单网络管理协议/2986113

简单网络管理协议(SNMP) 是专门设计用于在 IP 网络管理网络节点服务器工作站路由器交换机及HUBS等)的一种标准协议,它是一种应用层协议。
 
 
中文名
简单网络管理协议
外文名
SNMP
作    用
IP网络管理网络节点
网络层次
应用层

简介

 语音
SNMP 是专门设计用于在 IP 网络管理网络节点服务器工作站路由器交换机及HUBS等)的一种标准协议,它是一种应用层协议。 SNMP 使网络管理员能够管理网络效能,发现并解决网络问题以及规划网络增长。通过 SNMP 接收随机消息(及事件报告)网络管理系统获知网络出现问题。
SNMP的前身是简单网关监控协议(SGMP),用来对通信线路进行管理。随后,人们对SGMP进行了很大的修改,特别是加入了符合Internet定义的SMIMIB,改进后的协议就是著名的SNMP。基于TCP/IP的SNMP网络管理框架是工业上的现行标准,由3个主要部分组成,分别是管理信息结构SMI(Structure ofManagement Information)、管理信息库MIB和管理协议SNMP。
  • SMI定义了SNMP框架所用信息的组织和标识,为MIB定义管理对象及使用管理对象提供模板。
  • MIB定义了可以通过SNMP进行访问的管理对象的集合。
  • SNMP协议是应用层协议,定义了网络管理者如何对代理进程的MIB对象进行读写操作。
SNMP中的MIB是一种树状数据库,MIB管理的对象,就是树的端节点,每个节点都有唯一位置和唯一名字.IETF规定管理信息库对象识别符(OID,Object Identifier)唯一指定,其命名规则就是父节点的名字作为子节点名字的前缀。 [1] 

组成部分

 语音
一个SNMP管理的网络由下列三个关键组件组成:
  • 网络管理系统(NMS,Network-management systems)
  • 被管理的设备(managed device)
  • 代理者(agent)
网络管理系统运行应用程序,以该应用程序监视并控制被管理的设备。也称为管理实体(managingentity),网络管理员在这儿与网络设备进行交互。网络管理系统提供网络管理需要的大量运算和记忆资源。一个被管理的网络可能存在一个以上的网络管理系统。
被管理的设备是一个网络节点,它包含一个存在于被管理的网络中的SNMP代理者。被管理的设备通过管理信息库(MIB)收集并存储管理信息,并且让网络管理系统能够通过SNMP代理者取得这项信息。
代理者是一种存在于被管理的设备中的网络管理软件模块。代理者控制本地机器的管理信息,以和SNMP兼容的格式传送这项信息。

技术优点

 语音
SNMP是管理进程(NMS)和代理进程(Agent)之间的通信协议。它规定了在网络环境中对设备进行监视和管理的标准化管理框架、通信的公共语言、相应的安全和访问控制机制。网络管理员使用SNMP功能可以查询设备信息、修改设备的参数值、监控设备状态、自动发现网络故障、生成报告等。
SNMP具有以下技术优点:
  • 基于TCP/IP互联网的标准协议,传输层协议一般采用UDP
  • 自动化网络管理。网络管理员可以利用SNMP平台在网络上的节点检索信息、修改信息、发现故障、完成故障诊断、进行容量规划和生成报告。
  • 屏蔽不同设备的物理差异,实现对不同厂商产品的自动化管理。SNMP只提供最基本的功能集,使得管理任务与被管设备的物理特性和实际网络类型相对独立,从而实现对不同厂商设备的管理。
  • 简单的请求—应答方式和主动通告方式相结合,并有超时和重传机制。
  • 报文种类少,报文格式简单,方便解析,易于实现。
  • SNMPv3版本提供了认证和加密安全机制,以及基于用户和视图的访问控制功能,增强了安全性。

架构方式

 语音

主代理

主代理是一个在可运行SNMP的网络组件上运作的软件,可回应从管理站发出的SNMP要求。它的角色类似客户端/服务器结构(Client/Server)术语中的服务器。主代理依赖子代理提供有关特定功能的管理信息。
如果系统当前拥有多个可管理的子系统,主代理就会传递它从一个或多个子代理处收到的请求。这些子代理在一个子系统以及对那个子系统进行监测和管理操作的接口内为关心的对象建模。主代理和子代理的角色可以合并,在这种情况下我们可以简单的称之为代理(agent)。

子代理

子代理是一个在可运行SNMP的网络组件上运作的软件,运行在特定子系统的特定管理信息库(MIB,Management Information Base)中定义的信息和管理功能。子代理的一些能力有:
搜集主代理的信息
配置主代理的参数
回应管理者的要求
产生警告或陷阱
对协议和管理信息结构的良好分离使得使用SNMP来监测和管理同一网络内上百的不同子系统非常简单。MIB模型运行管理OSI参考模型的所有层,并可以扩展至诸如数据库,电子邮件以及J2EE参考模型之类的应用。

管理站

管理者或者管理站提供第三个组件。它和一个客户端/服务器结构下的客户端一样工作。它根据一个管理员或应用程序的行为发出管理操作的请求,也接收从代理处获得的TRAP。

协议种类

 语音
目前, SNMP 有 3 种: SNMPV1 、 SNMPV2 、 SNMPV3。第 1 版和第 2 版没有太大差距,但 SNMPV2 是增强版本,包含了其它协议操作。与前两种相比, SNMPV3 则包含更多安全和远程配置。为了解决不同 SNMP 版本间的不兼容问题, RFC3584 中定义了三者共存策略。
SNMP 还包括一组由RMON、RMON2、MTB、MTB2、OCDS及OCDS定义的扩展协议。

协议结构

 语音
SNMP 是一种应用程序协议,封装在UDP中。各种版本的 SNMP 信息通用格式如下所示:
Version Community PDU
Version:SNMP 版本号。管理器和代理器必须使用相同版本的 SNMP。需要删除具有不同版本号的信息,并不对它们作进一步的处理。
Community:团体名称,用于在访问代理器之前认证管理器。
PDU(协议数据单元):SNMPv1、v2 和 v3 中的 PDU 类型和格式将在对应文件中作具体介绍。

开发和使用

 语音

第一版

SNMP的第一个RFC系列出现在1988年:
RFC 1065:基于TCP/IP网络的管理信息的结构和认定
RFC 1066:以基于TCP/IP网络的网络管理为基础的管理信息
RFC 1067:一个简单网络管理协议
这些协议被废除经由:
RFC 1155:基于TCP/IP网络的管理信息的结构和认定
RFC 1156:以基于TCP/IP网络的网络管理为基础的管理信息
RFC 1157:一个简单网络管理协议
SNMP协议工作在OSI模型的应用层(第七层)。它(在第一版中)指定了四种核心协议数据单元(PDU):
GET,用来得到一条管理信息
GETNEXT,用来反复得到管理信息的串行
SET,用来给一个被管理的子系统制造一个变化
TRAP,用来报告一个关于被管理子系统的警告或其他异步事件
典型的,SNMP为代理使用UDP端口161,为管理站使用UDP端口162。
第一版因为其脆弱的安全性而备受争议。客户端的认证使用明码传送。在80年代,SNMP第一版被设计出来的时期,互联网标准的认证/安全并不被主要的协议设计团体所重视。

第二版

SNMP第二版(RFC 1441–RFC 1452)修订了第一版并且包含了在性能、安全、机密性和管理者之间通信这些领域的改进。它引入了GETBULK以取代反复的GETNEXT,藉以在单个请求中获取大量的管理数据。然而,SNMP第二版的新安全系统被认为过于复杂,而不被广泛接受。
SNMP v2c(基于社区的SNMP第二版)定义于RFC 1901–RFC 1908,一开始也非正式的被称为SNMP第1.5版。SNMPv2c包含SNMP第二版除了受争议的新SNMP第二版安全模型以外的部份,并以SNMP第一版的简单的基于社区的安全性方案取而代之。
SNMP v2u(基于用户的SNMP第二版)定义于RFC 1909–RFC 1910。这是一个SNMP第一版和SNMP第二版的折衷方案,试图提供比SNMP第一版更好的安全性,又不遭遇SNMP第二版的高复杂度。这产生一个被商业化的变种,称为SNMP v2*,而且它的机制最后被SNMP第三版的两个安全性框架之一采用。

第三版

Internet工程工作小组(IETF)把在RFC3411-RFC3418(STD0062)中定义的SNMP第三版作为2004年的标准版本。IETF将先前的版本定为“Obsolete”或“Historical”。
实际上,SNMP实现通常支持多个版本:典型的SNMPv1、SNMPv2c以及SNMPv3。参见RFC3584“Internet标准网络管理框架第一、二、三版间的共存”。
SNMP第三版提供三项重要的服务:认证、隐私和访问控制

应用

 语音
在大型网络管理中,网络管理员比较头痛的问题就是如何实时了解不在身边的网络设备的运行状况。若要一台一台的去查看网络设备的运行现状,那明显不是很现实。实际网络中,利用SNMP协议自动帮助管理员收集网络运行状况的方法应用最为广泛。通过这种方法,网络管理员只需要坐在自己的位置上,就可以了解全公司的网络设备的运行情况。有了这个简单网络管理协议(SNMP),网络管理员可以很方便的在SNMP Agent和NMS之间交换管理信息。SNMP的主要作用就是帮助企业网络管理人员更方便的了解网络性能、发现并解决网络问题、规划网络的未来发展。 [2]

 

 

 

 

什么是SNMP - 华为 https://support.huawei.com/enterprise/zh/doc/EDOC1100087025

 技术支持  文档中心  交换机  数据中心交换机  CloudEngine 58&68&78&88&98  配置调测  技术指导 

什么是SNMP
 
评分并提供意见反馈 :     
 

 

SNMP配置任务概览 - S12700 V200R013C00 配置指南-网络管理与监控 - 华为 https://support.huawei.com/enterprise/zh/doc/EDOC1100065721/683404d4

 

 

 

 

 

 

 

 

 

 

什么是SNMP
 
评分并提供意见反馈 :     
 

IP数据报UDP数据报SNMP报文公共SNMP首部get/set首部get/set变量部分IP首部UDP首部"版本(0)"共同体"PDU类型(0-3)"请求标识"差错状态(0-5)"差错索引名称值名称值..."PDU类型(4)"企业代理地址"trap类型(0-6)"特定代码时间戳名称值...trap首部有意义的变量SNMP报文的格式PDU类型名称差错状态名称描述0get-request0noError没有进程1get-nextrequest1tooBig代理进程无法把响应放在一个SNMP消息中发送2get-response2noSuchName操作一个不存在的变量3set-request3badValueset操作的值或语义有错误4trap4readOnly管理进程试图修改一个只读变量SNMP报文中的PDU类型5genErr其他错误SNMP差错状态的值trap类型名称描述0clodStart代理进程对自己初始化1warmStart2linkDown"一个接口从影工作状态变为故障状态,报文中的第一个变量标识次接口"3linkUp"一个接口从影故障状态变为工作状态,报文中的第一个变量标识次接口"4authenticationFailure从SNMP管理进程收到无效共同体的报文5egpNeighborLoss一个FGP邻站已变为故障状态。报文中的第一个变量包含此邻站的IP地址6enterpriseSpecific在这个特定的代码段总查找trap信息trap的类型

 

IP数据报UDP数据报SNMP报文公共SNMP首部get/set首部get/set变量部分IP首部UDP首部"版本(0)"共同体"PDU类型(0-3)"请求标识"差错状态(0-5)"差错索引名称值名称值..."PDU类型(4)"企业代理地址"trap类型(0-6)"特定代码时间戳名称值...trap首部有意义的变量SNMP报文的格式PDU类型名称差错状态名称描述0get-request0noError没有进程1get-nextrequest1tooBig代理进程无法把响应放在一个SNMP消息中发送2get-response2noSuchName操作一个不存在的变量3set-request3badValueset操作的值或语义有错误4trap4readOnly管理进程试图修改一个只读变量SNMP报文中的PDU类型5genErr其他错误SNMP差错状态的值trap类型名称描述0clodStart代理进程对自己初始化1warmStart代理进程对自己重新初始化2linkDown"一个接口从影工作状态变为故障状态,报文中的第一个变量标识次接口"3linkUp"一个接口从影故障状态变为工作状态,报文中的第一个变量标识次接口"4authenticationFailure从SNMP管理进程收到无效共同体的报文5egpNeighborLoss一个FGP邻站已变为故障状态。报文中的第一个变量包含此邻站的IP地址6enterpriseSpecific在这个特定的代码段总查找trap信息trap的类型

 

IP数据报UDP数据报SNMP报文公共SNMP首部get/set首部get/set变量部分IP首部UDP首部"版本(0)"共同体"PDU类型(0-3)"请求标识"差错状态(0-5)"差错索引名称值名称值..."PDU类型(4)"企业代理地址"trap类型(0-6)"特定代码时间戳名称值...trap首部有意义的变量SNMP报文的格式PDU类型名称差错状态名称描述0get-request0noError没有进程1get-nextrequest1tooBig代理进程无法把响应放在一个SNMP消息中发送2get-response2noSuchName操作一个不存在的变量3set-request3badValueset操作的值或语义有错误4trap4readOnly管理进程试图修改一个只读变量SNMP报文中的PDU类型5genErr其他错误SNMP差错状态的值trap类型名称描述0clodStart代理进程对自己初始化1warmStart代理进程对自己重新初始化2linkDown"一个接口从影工作状态变为故障状态,报文中的第一个变量标识次接口"3linkUp"一个接口从影故障状态变为工作状态,报文中的第一个变量标识次接口"4authenticationFailure从SNMP管理进程收到无效共同体的报文5egpNeighborLoss一个FGP邻站已变为故障状态。报文中的第一个变量包含此邻站的IP地址6enterpriseSpecific在这个特定的代码段中查找trap信息trap的类型

 

posted @ 2021-08-05 10:02  papering  阅读(613)  评论(0编辑  收藏  举报