非常教程

Erlang 20参考手册

snmp

Net if的定义 | 12. Definition of Agent Net if

图12.1: 代理Net的目的IF

网络接口(Net if)进程将SNMP PDU传递给主代理,并从主代理接收SNMP PDU。Net if进程最常见的行为是从网络接收字节,将它们解码为SNMP PDU,并将其发送给主代理。当主代理处理PDU时,它向Net if过程发送响应PDU,该过程将PDU编码为字节并将字节传输到网络上。

但是,这种简单的行为可以通过多种方式进行修改。例如,网络if进程可以对字节应用某种加密/解密方案,或充当代理过滤器,该代理过滤器将一些数据包发送给代理代理,并将一些数据包发送给主代理。

也可以编写自己的Net if过程。默认的Net if进程在模块中实现snmpa_net_if,它使用UDP作为传输协议,即传输域transportDomainUdpIpv4和/或transportDomainUdpIpv6

本节介绍如何编写Net if进程。

12.1强制功能

Net if进程必须实现SNMP代理network interface behaviour

12.2消息

消息 ”部分描述了强制性消息,如果必须发送并且能够接收,该消息必须是Net。

在本节中,Address字段是一个{Domain,Addr}元组,其中Domain是transportDomainUdpIpv4或transportDomainUdpIpv4,Addr是{IpAddr,IpPort}元组。

传出消息

Net如果从网络接收到针对MasterAgent的SNMP PDU时必须发送以下消息:

MasterAgent ! {snmp_pdu, Vsn, Pdu, PduMS, ACMData, From, Extra}
  • Vsn可以是'版本-1','版本-2'或'版本-3'。
  • Pdu是snmp_types.hrl中定义的SNMP PDU记录和SNMP请求。
  • PduMS是允许的最大响应Pdu的大小。 通常这是从snmpa_mpd:process_packet返回的(请参阅参考手册)。
  • ACMData是正在使用的访问控制模块使用的数据。 通常这是从snmpa_mpd:process_packet返回的(请参阅参考手册)。
  • 源是来源地址。
  • 额外是如果流程希望发送给代理的任何术语。 仪表功能可以通过调用snmp:current_net_if_data()来检索该术语。 当代理生成对请求的响应时,这些数据也会发送回网络。

以下消息用于报告已收到对请求的响应。代理可以发送的唯一请求是一个Inform-Request。

Pid ! {snmp_response_received, Vsn, Pdu, From}
  • Pid是等待请求响应的进程。send_pdu_req消息中指定了Pid (see below)
  • Vsn或者是'version-1''version-2',或'version-3'
  • Pdu 是收到的SNMP Pdu
  • From是来源Address

传入消息

本节介绍Net if进程必须能够接收的传入消息。

  • {snmp_response, Vsn, Pdu, Type, ACMData, To, Extra} 该消息作为对先前接收到的请求的响应而被发送到来自主代理的网络if处理。
-  `Vsn` is either `'version-1'`, `'version-2'`, or `'version-3'`. 
-  `Pdu` is an SNMP PDU record (as defined in snmp\_types.hrl) with the SNMP response. 
-  `Type` is the `#pdu.type` of the original request. 
-  `ACMData` is data used by the Access Control Module in use. Normally this is just sent to `snmpa_mpd:generate_response_message` (see Reference Manual). 
-  `To` is the destination `Address` that comes from the `From` field in the corresponding `snmp_pdu` message previously sent to the MasterAgent.
-  `Extra` is the term that the Net if process sent to the agent when the request was sent to the agent. 
  • {discarded_pdu, Vsn, ReqId, ACMData, Variable, Extra} 如果由于某种原因决定放弃pdu,该消息将从主代理发送。
-  `Vsn` is either `'version-1'`, `'version-2'`, or `'version-3'`. 
-  `ReqId` is the request id of the original request. 
-  `ACMData` is data used by the Access Control Module in use. Normally this is just sent to `snmpa_mpd:generate_response_message` (see Reference Manual). 
-  `Variable` is the name of an snmp counter that represents the error, e.g. `snmpInBadCommunityUses`. 
-  `Extra` is the term that the Net if process sent to the agent when the request was sent to the agent. 
  • {send_pdu, Vsn, Pdu, MsgData, To, Extra} 当要发送陷阱时,该消息从主代理发送。
-  `Vsn` is either `'version-1'`, `'version-2'`, or `'version-3'`.
-  `Pdu` is an SNMP PDU record (as defined in snmp\_types.hrl) with the SNMP response. 
-  `MsgData` is the message specific data used in the SNMP message. This value is normally sent to `snmpa_mpd:generate_message/4`. In SNMPv1 and SNMPv2c, this message data is the community string. In SNMPv3, it is the context information. 
-  `To` is a list of `{Address, SecData}` tuples i.e the destination addresses and their corresponding security parameters. This value is normally sent to `snmpa_mpd:generate_message/4`. 
-  `Extra` is any term that the notification sender wishes to pass to the Net if process when sending a notification (see [`send notification`](snmpa#send_notification2) for more info). 
  • {send_pdu_req, Vsn, Pdu, MsgData, To, Pid, Extra} 当请求被发送时,该消息从主代理发送。代理可以发送的唯一请求是Inform-Request。net if进程需要记住请求ID和Pid,并且收到请求ID的响应时,使用snmp_response_received消息将其发送到Pid 。
-  `Vsn` is either `'version-1'`, `'version-2'`, or `'version-3'`.
-  `Pdu` is an SNMP PDU record (as defined in snmp\_types.hrl) with the SNMP response. 
-  `MsgData` is the message specific data used in the SNMP message. This value is normally sent to `snmpa_mpd:generate_message/4`. In SNMPv1 and SNMPv2c, this message data is the community string. In SNMPv3, it is the context information. 
-  `To` is a list of `{Address, SecData}` tuples i.e the destination addresses and their corresponding security parameters. This value is normally sent to `snmpa_mpd:generate_message/4`. 
-  `Pid` is a process identifier. 
-  `Extra` is any term that the notification sender wishes to pass to the Net if process when sending a notification (see [`send notification`](snmpa#send_notification2) for more info). 

注意

由于Net if进程负责编码和解码SNMP消息,因此它还必须更新MIB-II中的SNMP组中的相关计数器。 为此,可以使用模块snmpa_mpd中的函数(有关更多详细信息,请参见参考手册,部分snmp,模块snmpa_mpd)。

在模块snmp_pdus中还有一些用于编码和解码SNMP消息的有用功能

snmp相关

1.1. SNMP简介 | 1. SNMP Introduction
2.2.代理功能描述 | 2. Agent Functional Description
3.3.管理功能描述 | 3. Manager Functional Description
4.4. MIB编译器 | 4. The MIB Compiler
5.5.运行应用程序 | 5. Running the application
6.6.代理配置文件的定义 | 6. Definition of Agent Configuration Files
7.7. Manager配置文件的定义 | 7. Definition of Manager Configuration Files
8.8.代理实现示例 | 8. Agent Implementation Example
9.9.管理实施例 | 9. Manager Implementation Example
10.10.检测函数 | 10. Instrumentation Functions
11.检测函数的定义 | 11. Definition of Instrumentation Functions
12.管理Netif 的定义 | 13. Definition of Manager Net if
13.14.审计跟踪日志 | 14. Audit Trail Log
14.15.高级代理主题 | 15. Advanced Agent Topics
15.16. SNMP Appendix A
16.17. SNMP Appendix B
17.snmp
18.snmpa
19.snmpa_conf
20.snmpa_discovery_handler
21.snmpa_error
22.snmpa_error_io
23.snmpa_error_logger
24.snmpa_error_report
25.snmpa_local_db
26.snmpa_mib_data
27.snmpa_mib_storage
28.snmpa_mpd
29.snmpa_network_interface
30.snmpa_network_interface_filter
31.snmpa_notification_delivery_info_receiver
32.snmpa_notification_filter
33.snmpa_supervisor
34.snmpc
35.snmpm
36.snmpm_conf
37.snmpm_mpd
38.snmpm_network_interface
39.snmpm_network_interface_filter
40.snmpm_user
41.snmp_community_mib
42.snmp_framework_mib
43.snmp_generic
44.snmp_index
45.snmp_notification_mib
46.snmp_pdus
47.snmp_standard_mib
48.snmp_target_mib
49.snmp_user_based_sm_mib
50.snmp_view_based_acm_mib
Erlang 20

Erlang 是一种通用的面向并发的编程语言,可应付大规模开发活动的程序设计语言和运行环境。

主页 https://www.erlang.org/
源码 https://github.com/erlang/otp
版本 20
发布版本 20.1