非常教程

Erlang 20参考手册

snmp

5.运行应用程序 | 5. Running the application

运行应用程序 ”一章描述了应用程序的配置和启动方式。主题包括:

  • 配置目录和参数
  • 修改配置文件
  • 启动应用程序(代理和/或经理)
  • 调试应用程序(代理和/或管理器)

另请参阅章节Definition of Agent Configuration FilesDefinition of Manager Configuration Files其中包含有关代理和管理器配置文件的更多详细信息。

5.1 配置应用程序

系统中必须存在以下两个目录才能运行代理程序:

  • 配置目录存储由代理使用的所有配置文件(请参见章节Definition of Agent Configuration Files获得更多信息)。
  • 数据库目录中存储的内部数据库文件。

系统中必须存在以下目录才能运行管理器:

  • 配置目录存储由管理员使用的所有配置文件(请参阅章节Definition of Manager Configuration Files以获取更多信息)。
  • 数据库目录中存储的内部数据库文件。

代理和管理器使用(应用程序)配置参数来找出这些目录的位置。这些参数应该在Erlang系统配置文件中定义。为SNMP应用程序定义了以下配置参数:

agent_options() = [agent_option()]
agent_option() = {restart_type,     restart_type()}     | 
                 {agent_type,       agent_type()}       |  
                 {agent_verbosity,  verbosity()}        |  
                 {versions,         versions()}         |  
                 {discovery,        agent_discovery()}  |  
                 {gb_max_vbs,       gb_max_vbs()}       |  
                 {priority,         priority()}         |  
                 {multi_threaded,   multi_threaded()}   |  
                 {db_dir,           db_dir()}           |  
                 {db_init_error,    db_init_error()}    |  
                 {local_db,         local_db()}         |  
                 {net_if,           agent_net_if()}     |  
                 {mibs,             mibs()}             |  
                 {mib_storage,      mib_storage()}      |  
                 {mib_server,       mib_server()}       |  
                 {audit_trail_log,  audit_trail_log()}  |  
                 {error_report_mod, error_report_mod()} |  
                 {note_store,       note_store()}       |  
                 {symbolic_store,   symbolic_store()}   |  
                 {target_cache,     target_cache()}     |  
                 {config,           agent_config()}
manager_options() = [manager_option()]
manager_option() = {restart_type,             restart_type()}    | 
                   {net_if,                   manager_net_if()}  |  
                   {server,                   server()}          | 
                   {note_store,               note_store()}      | 
                   {config,                   manager_config()}  |  
                   {inform_request_behaviour, manager_irb()}     | 
                   {mibs,                     manager_mibs()}    | 
                   {priority,                 priority()}        |  
                   {audit_trail_log,          audit_trail_log()} | 
                   {versions,                 versions()}        | 
                   {def_user_mod,             def_user_module()  | 
                   {def_user_data,            def_user_data()}

代理特定的配置选项和类型:

agent_type() = master | sub <optional>

如果master启动了一个主代理程序。否则,不会启动代理。

默认是master

agent_discovery() = [agent_discovery_opt()] <optional>

agent_discovery_opt() = {terminating, agent_terminating_discovery_opts()} | {originating, agent_originating_discovery_opts()}

这些terminating选项会影响经理发起的发现。

这个originating选项影响这个代理发起的发现。

有关默认值,请参阅中的选项agent_discovery_opt()

agent_terminating_discovery_opts() = [agent_terminating_discovery_opt()] <optional>

agent_terminating_discovery_opt() = {enable, boolean()} | {stage2, discovery | plain} | {trigger_username, string()}

这些是影响terminating该代理发现的选项(即由经理发起)。

terminating发现选项的默认值为:

  • 启用: true
  • 阶段2: discovery
  • trigger_username: ""

agent_originating_discovery_opts() = [agent_originating_discovery_opt()] <optional>

agent_originating_discovery_opt() = {enable, boolean()}

这些是影响originating代理发现的选项。

originating发现选项的默认值为:

  • 启用: true

multi_threaded() = bool() <optional>

如果为true,则代理是多线程的,每个获取请求都有一个线程。

默认是false

db_dir() = string() <mandatory>

定义SNMP代理内部数据库文件的存储位置。

gb_max_vbs() = pos_integer() | infinity <optional>

定义Get-BULK响应中允许的最大varbind数量。

默认是1000

local_db() = [local_db_opt()] <optional>

local_db_opt() = {repair, agent_repair()} | {auto_save, agent_auto_save()} | {verbosity, verbosity()}

定义特定于SNMP代理本地数据库的选项。

有关默认值,请参阅中的选项local_db_opt()

agent_repair() = false | true | force <optional>

启动snmpa_local_db时,它总是尝试打开现有的数据库。 如果为false,并且发生一些错误,则会创建一个新的数据库。 如果为true,则现有文件将被修复。 如果强制,即使正确关闭,桌子也会被修复。

默认是true

agent_auto_save() = integer() | infinity <optional>

自动保存间隔。每当这段时间没有访问时,该表被刷新到磁盘。

默认是5000

agent_net_if() = [agent_net_if_opt()] <optional>

agent_net_if_option() = {module, agent_net_if_module()} | {verbosity, verbosity()} | {options, agent_net_if_options()}

定义特定于SNMP代理网络接口实体的选项。

有关默认值,请参阅agent_net_if_opt()中的选项。

agent_net_if_module() = atom() <optional>

处理SNMP代理的网络接口部分的模块。必须执行该snmpa_network_interface行为。

默认是snmpa_net_if

agent_net_if_options() = [agent_net_if_option()] <optional>

agent_net_if_option() = {bind_to, bind_to()} | {sndbuf, sndbuf()} | {recbuf, recbuf()} | {no_reuse, no_reuse()} | {req_limit, req_limit()} | {filter, agent_net_if_filter_options()}

这些选项实际上是特定于使用的模块。这里显示的那些适用于默认值agent_net_if_module()

有关默认值,请参阅agent_net_if_option()中的选项。

req_limit() = integer() | infinity <optional>

代理处理的最大并发请求数。

默认是infinity

agent_net_if_filter_options() = [agent_net_if_filter_option()] <optional>

agent_net_if_filter_option() = {module, agent_net_if_filter_module()}

这些选项实际上是特定于使用的模块。这里显示的那些适用于默认值agent_net_if_filter_module()

有关默认值,请参阅agent_net_if_filter_option()中的选项。

agent_net_if_filter_module() = atom() <optional>

处理SNMP代理的网络接口过滤器部分的模块。必须执行该snmpa_network_interface_filter行为。

默认是snmpa_net_if_filter

agent_mibs() = [string()] <optional>

指定MIB(包括路径)的列表,该列表定义哪些MIB最初加载到SNMP主代理中。

请注意,总是会加载以下内容:

  • version v1: STANDARD-MIB
  • version v2: SNMPv2
  • version v3: SNMPv2, SNMP-FRAMEWORK-MIB and SNMP-MPD-MIB

默认是[]

mib_storage() = [mib_storage_opt()] <optional>

mib_storage_opt() = {module, mib_storage_module()} | {options, mib_storage_options()}

该选项指定如何存储基本mib数据。该选项由snmp代理的两部分使用:mib-server和symbolic-store。

Default is [{module, snmpa_mib_storage_ets}].

mib_storage_module() = snmpa_mib_data_ets | snmpa_mib_data_dets | snmpa_mib_data_mnesia | module()

定义由snmpa_mib_storage行为定义的SNMP代理的mib存储模块。

snmp代理的几个实体(mib-server通过它的数据模块和symbolic-store)使用它来存储加载mib时数据检索到的其他数据相关数据。

代理提供了几种实现:snmpa_mib_storage_etssnmpa_mib_storage_detssnmpa_mib_storage_mnesia

默认模块是snmpa_mib_storage_ets

mib_storage_options() = list() <optional>

这是依赖于实现的。也就是说,这取决于模块。对于每个模块,一组特定的选项是有效的。对于随应用程序提供的模块,这些选项是受支持的:

  • snmpa_mib_storage_ets: {dir, filename()} | {action, keep | clear}, {checksum, boolean()}
-  `dir` - If present, points to a directory where a file to which all data in the ets table is "synced".  Also, when a table is opened this file is read, if it exists. 
 By default, this will not be used. 
 
-  `action` - Specifies the behaviour when a non-empty file is found: Keep its content or clear it out.  Default is keep. 
 
-  `checksum` - Defines if the file is checksummed or not.  Default is false. 
 
  • snmpa_mib_storage_dets: {dir, filename()} | {action, keep | clear}, {auto_save, default | pos_integer()} | {repair, force | boolean()}
-  `dir` - This **mandatory** option points to a directory where to place the file of a dets table. 
-  `action` - Specifies the behaviour when a non-empty file is found: Keep its content or clear it out.  Default is keep. 
 
-  `auto_save` - Defines the dets auto-save frequency.  Default is default. 
 
-  `repair` - Defines the dets repair behaviour.  Default is false. 
 
  • snmpa_mib_storage_mnesia: {action, keep | clear}, {nodes, [node()]}
-  `action` - Specifies the behaviour when a non-empty, already existing, table: Keep its content or clear it out.  Default is keep. 
 
-  `nodes` - A list of node names (or an atom describing a list of nodes) defining where to open the table. Its up to the user to ensure that mnesia is actually running on the specified nodes.  The following distinct values are recognised: 
 
    -  `[]` - Translated into a list of the own node: `[node()]`
    -  `all` - `erlang:nodes()`
    -  `visible` - `erlang:nodes(visible)`
    -  `connected` - `erlang:nodes(connected)`
    -  `db_nodes` - `mnesia:system_info(db_nodes)`

默认值是调用的结果:erlang:nodes()

mib_server() = [mib_server_opt()] <optional>

mib_server_opt() = {mibentry_override, mibentry_override()} | {trapentry_override, trapentry_override()} | {verbosity, verbosity()} | {cache, mibs_cache()} | {data_module, mib_server_data_module()}

定义特定于SNMP代理mib服务器的选项。

有关默认值,请参阅mib_server_opt()中的选项。

mibentry_override() = bool() <optional>

如果此值为false,则加载mib时,每个mib-entry在安装mib之前都会被检查。检查的目的是为了防止相同的符号mibentry名称用于不同的oid。

默认是false

trapentry_override() = bool() <optional>

如果此值为false,则加载mib时,将在安装mib之前检查每个陷阱。检查的目的是为了防止相同的符号陷阱名称用于不同的陷阱。

默认是false

mib_server_data_module() = snmpa_mib_data_tttn | module() <optional>

定义由snmpa_mib_data行为定义的SNMP代理mib-server的后端数据模块。

目前只有代理提供了默认模块,snmpa_mib_data_tttn

默认模块是snmpa_mib_data_tttn

mibs_cache() = bool() | mibs_cache_opts() <optional>

代理是否使用mib服务器查找缓存。

默认值是true(在这种情况下,mibs_cache_opts()默认值适用)。

mibs_cache_opts() = [mibs_cache_opt()] <optional>

mibs_cache_opt() = {autogc, mibs_cache_autogc()} | {gclimit, mibs_cache_gclimit()} | {age, mibs_cache_age()}

定义特定于SNMP代理mib服务器缓存的选项。

有关默认值,请参阅mibs_cache_opt()中的选项。

mibs_cache_autogc() = bool() <optional>

定义mib服务器是否应自动执行缓存gc或将其留给用户(请参阅参考资料gc_mibs_cache/0,1,2,3)。

默认是true

mibs_cache_age() = integer() > 0 <optional>

定义缓存中的条目在被GC调用之前将被允许变为多大(假定执行GC)。无论何时访问,缓存中的每个条目都会“触及”。

年龄定义为毫秒。

默认是10 timutes

mibs_cache_gclimit() = integer() > 0 | infinity <optional>

执行GC时,这是将从缓存中删除的最大缓​​存条目数。

有这个限制的原因是,如果缓存很大,GC可能需要很长时间,在此期间代理被锁定。

默认是100

error_report_mod() = atom() <optional>

定义一个错误报告模块,实现该snmpa_error_report行为。工具箱提供了两个模块:snmpa_error_loggersnmpa_error_io

默认是snmpa_error_logger

symbolic_store() = [symbolic_store_opt()]

symbolic_store_opt() = {verbosity, verbosity()}

定义特定于SNMP代理符号存储的选项。

有关默认值,请参阅中的选项symbolic_store_opt()

target_cache() = [target_cache_opt()]

target_cache_opt() = {verbosity, verbosity()}

定义特定于SNMP代理目标缓存的选项。

有关默认值,请参阅target_cache_opt()中的选项。

agent_config() = [agent_config_opt()] <mandatory>

agent_config_opt() = {dir, agent_config_dir()} | {force_load, force_load()} | {verbosity, verbosity()}

为SNMP代理定义特定的配置相关选项。

有关默认值,请参阅agent_config_opt()中的选项。

agent_config_dir = dir() <mandatory>

定义SNMP代理配置文件的存储位置。

force_load() = bool() <optional>

如果true在启动过程中重新读取配置文件,并忽略配置数据库的内容。因此,如果true配置数据库的更改在重新启动代理程序时丢失了。

默认是false

管理员特定的配置选项和类型:

server() = [server_opt()] <optional>

server_opt() = {timeout, server_timeout()} | {verbosity, verbosity()}

指定管理器服务器进程的选项。

默认是silence

server_timeout() = integer() <optional>

异步请求清理时间。对于每个请求,都会将一些信息存储在内部,以便能够将回复(到达时)发送到正确的目的地。如果回复到达,此信息将被删除。但是,如果没有回复(及时),则必须在通过最佳时间之后删除信息。此清理将按照时间定义的定期执行server_timeout()。这些信息将有一个最好的前时间,由定义的Expire调用请求的功能时,给定的时间(见async_getasync_get_nextasync_set)。

以毫秒为单位的时间。

默认是30000

manager_config() = [manager_config_opt()] <mandatory>

manager_config_opt() = {dir, manager_config_dir()} | {db_dir, manager_db_dir()} | {db_init_error, db_init_error()} | {repair, manager_repair()} | {auto_save, manager_auto_save()} | {verbosity, verbosity()}

为SNMP管理器定义特定的配置相关选项。

有关默认值,请参阅manager_config_opt()中的选项。

manager_config_dir = dir() <mandatory>

定义SNMP管理器配置文件的存储位置。

manager_db_dir = dir() <mandatory>

定义SNMP管理器存储持久数据的位置。

manager_repair() = false | true | force <optional>

定义永久数据库的修复选项(如果以及如何在打开时修复表)。

默认是true

manager_auto_save() = integer() | infinity <optional>

自动保存间隔。每当这段时间没有访问时,该表被刷新到磁盘。

默认是5000

manager_irb() = auto | user | {user, integer()} <optional>

该选项定义了管理员将如何处理向收到的通知请求发送回复(确认)。

  • auto - 管理员将自动发送响应(确认>通知 - 请求消息。
  • {user, integer()}- 当handle_inform功能完成时,管理器将发送响应(确认)给通知请求消息。整数是以毫秒为单位的时间,管理员将认为存储的通知请求信息有效。
  • user- 与{user, integer()}使用默认时间15000毫秒时相同。

snmpm_network_interfacehandle_informdefinition of the manager net if获得更多信息。

默认是auto

manager_mibs() = [string()] <optional>

指定MIB的列表(包括路径)并定义最初将哪些MIB加载到SNMP管理器中。

默认是[]

manager_net_if() = [manager_net_if_opt()] <optional>

manager_net_if_opt() = {module, manager_net_if_module()} | {verbosity, verbosity()} | {options, manager_net_if_options()}

定义特定于SNMP管理器网络接口实体的选项。

有关默认值,请参阅manager_net_if_opt()中的选项。

manager_net_if_options() = [manager_net_if_option()] <optional>

manager_net_if_option() = {bind_to, bind_to()} | {sndbuf, sndbuf()} | {recbuf, recbuf()} | {no_reuse, no_reuse()} | {filter, manager_net_if_filter_options()}

这些选项实际上是特定于使用的模块。这里显示的那些适用于默认值manager_net_if_module()

有关默认值,请参阅manager_net_if_option()中的选项。

manager_net_if_module() = atom() <optional>

处理SNMP管理器网络接口部分的模块。它必须实施该snmpm_network_interface行为。

默认是snmpm_net_if

manager_net_if_filter_options() = [manager_net_if_filter_option()] <optional>

manager_net_if_filter_option() = {module, manager_net_if_filter_module()}

这些选项实际上是特定于使用的模块。这里显示的那些适用于默认值manager_net_if_filter_module()

有关默认值,请参阅manager_net_if_filter_option()中的选项。

manager_net_if_filter_module() = atom() <optional>

为SNMP管理器处理网络接口过滤器部分的模块。必须执行该snmpm_network_interface_filter行为。

默认是snmpm_net_if_filter

def_user_module() = atom() <optional>

实现默认用户的模块。参阅snmpm_user行为。

默认是snmpm_user_default

def_user_data() = term() <optional>

数据为默认用户。在调用回调函数时传递给用户。

默认是undefined

通用配置类型:

restart_type() = permanent | transient | temporary

查看supervisor文档以获取更多信息。

默认值是permanent代理和transient管理者。

db_init_error() = terminate | create | create_db_and_dir

定义如果代理无法打开现有数据库文件该怎么做。terminate意味着代理/经理将终止,create意味着代理/经理将删除有故障的文件并创建新文件,并且create_db_and_dir意味着代理/经理将创建数据库文件以及数据库文件的任何缺失父目录。

默认是terminate

priority() = atom() <optional>

为所有SNMP进程定义Erlang优先级。

默认是normal

versions() = [version()] <optional>

version() = v1 | v2 | v3

哪些SNMP版本将被接受/使用。

默认是[v1,v2,v3]

verbosity() = silence | info | log | debug | trace <optional>

SNMP过程的详细程度。这指定了现在打印的很多调试信息。

默认是silence

bind_to() = bool() <optional>

如果为true,net_if绑定到IP地址。如果为false,net_if在它运行的主机上侦听任何IP地址。

默认是false

no_reuse() = bool() <optional>

如果为true,net_if没有指定IP和端口地址应该是可重用的。如果为false,地址设置为可重用。

默认是false

recbuf() = integer() <optional>

接收缓冲区大小。

默认值由gen_udp定义。

sndbuf() = integer() <optional>

发送缓冲区大小。

默认值由gen_udp定义。

note_store() = [note_store_opt()] <optional>

note_store_opt() = {timeout, note_store_timeout()} | {verbosity, verbosity()}

指定SNMP注释存储的选项。

有关默认值,请参阅note_store_opt()中的选项。

note_store_timeout() = integer() <optional>

请注意清理时间。在笔记存储中存储笔记时,每个笔记都会被赋予一生。每个timeoutnote_store进程执行一次GC来删除过期的注释。以毫秒为单位的时间。

默认是30000

audit_trail_log() [audit_trail_log_opt()] <optional>

audit_trail_log_opt() = {type, atl_type()} | {dir, atl_dir()} | {size, atl_size()} | {repair, atl_repair()} | {seqno, atl_seqno()}

如果存在,该选项指定审计线索记录的选项。 disk_log模块用于维护一个换行日志。 如果存在,则必须指定目录和大小选项。

如果不存在,则不使用审计跟踪日志记录。

atl_type() = read | write | read_write <optional>

指定应该使用哪种类型的审计跟踪日志。代理和经理的类型的影响实际上是不同的。

对于代理人:

  • 如果write指定,则只记录设置的请求。
  • 如果read指定,则只记录请求。
  • 如果read_write所有请求都被记录。

对于管理者:

  • 如果write指定,则只记录发送的消息。
  • 如果read指定,则只记录收到的消息。
  • 如果read_write记录了传出和传入的消息。

默认是read_write

atl_dir = dir() <mandatory>

指定审计跟踪日志应存储的位置。

如果audit_trail_log指定应该进行日志记录,则必须定义此参数。

atl_size() = {integer(), integer()} <mandatory>

指定审计跟踪日志的大小。该参数被发送到disk_log

如果audit_trail_log指定应该进行日志记录,则必须定义此参数。

atl_repair() = true | false | truncate | snmp_repair <optional>

指定在打开审计跟踪日志时是否以及如何修复。 除非此参数具有值snmp_repair,否则它将发送到disk_log。 另一方面,如果该值为snmp_repair,则snmp会尝试自行处理某些故障。 即使它不能修复文件,它也不会直接截断它,而是将它移到一边以供以后离线分析。

默认是true

atl_seqno() = true | false <optional>

指定审计跟踪日志条目是否将(序列)编号。序列号的范围根据RFC 5424,即1到2147483647。

默认是false

5.2 修改配置文件

要启动应用程序(代理和/或管理器),必须修改配置文件,并且有两种方法可以执行此操作。可以手动编辑文件,也可以按如下方式运行配置工具。

如果使用认证或加密(仅限SNMPv3),请启动crypto应用程序。

1> snmp:config().

Simple SNMP configuration tool (version 4.0)
------------------------------------------------
Note: Non-trivial configurations still has to be
      done manually. IP addresses may be entered 
      as dront.ericsson.se (UNIX only) or
      123.12.13.23
------------------------------------------------

Configure an agent (y/n)? [y] 

Agent system config: 
--------------------
1. Agent process priority (low/normal/high) [normal] 
2. What SNMP version(s) should be used (1,2,3,1&2,1&2&3,2&3)? [3] 1&2&3
3. Configuration directory (absolute path)? [/ldisk/snmp] /ldisk/snmp/agent/conf
4. Config verbosity (silence/info/log/debug/trace)? [silence] 
5. Database directory (absolute path)? [/ldisk/snmp] /ldisk/snmp/agent/db
6. Mib storage type (ets/dets/mnesia)? [ets] 
7. Target cache verbosity (silence/info/log/debug/trace)? [silence] 
8. Symbolic store verbosity (silence/info/log/debug/trace)? [silence] 
9. Local DB verbosity (silence/info/log/debug/trace)? [silence] 
10. Local DB repair (true/false/force)? [true] 
11. Local DB auto save (infinity/milli seconds)? [5000] 
12. Error report module? [snmpa_error_logger] 
13. Agent type (master/sub)? [master] 
14. Master-agent verbosity (silence/info/log/debug/trace)? [silence] log
15. Shall the agent re-read the configuration files during startup 
    (and ignore the configuration database) (true/false)? [true] 
16. Multi threaded agent (true/false)? [false] true
17. Check for duplicate mib entries when installing a mib (true/false)? [false] 
18. Check for duplicate trap names when installing a mib (true/false)? [false] 
19. Mib server verbosity (silence/info/log/debug/trace)? [silence] 
20. Mib server cache (true/false)? [true]
21. Note store verbosity (silence/info/log/debug/trace)? [silence] 
22. Note store GC timeout? [30000] 
23. Shall the agent use an audit trail log (y/n)? [n] y
23b. Audit trail log type (write/read_write)? [read_write] 
23c. Where to store the audit trail log? [/ldisk/snmp] /ldisk/snmp/agent/log
23d. Max number of files? [10] 
23e. Max size (in bytes) of each file? [10240] 
23f. Audit trail log repair (true/false/truncate)? [true] 
24. Which network interface module shall be used? [snmpa_net_if] 
25. Network interface verbosity (silence/info/log/debug/trace)? [silence] log
25a. Bind the agent IP address (true/false)? [false] 
25b. Shall the agents IP address and port be not reusable (true/false)? [false] 
25c. Agent request limit (used for flow control) (infinity/pos integer)? [infinity] 32
25d. Receive buffer size of the agent (in bytes) (default/pos integer)? [default] 
25e. Send buffer size of the agent (in bytes) (default/pos integer)? [default]
25f. Do you wish to specify a network interface filter module (or use default) [default] 

Agent snmp config: 
------------------
1. System name (sysName standard variable) [bmk's agent] 
2. Engine ID (snmpEngineID standard variable) [bmk's engine] 
3. Max message size? [484] 
4. The UDP port the agent listens to. (standard 161) [4000] 
5. IP address for the agent (only used as id 
   when sending traps) [127.0.0.1] 
6. IP address for the manager (only this manager 
   will have access to the agent, traps are sent 
   to this one) [127.0.0.1] 
7. To what UDP port at the manager should traps 
   be sent (standard 162)? [5000] 
8. Do you want a none- minimum- or semi-secure configuration? 
   Note that if you chose v1 or v2, you won't get any security for these
   requests (none, minimum, semi_des, semi_aes) [minimum] 
making sure crypto server is started...
8b. Give a password of at least length 8. It is used to generate 
    private keys for the configuration:  kalle-anka
9. Current configuration files will now be overwritten. Ok (y/n)? [y] 

- - - - - - - - - - - - -
Info: 1. SecurityName "initial" has noAuthNoPriv read access
         and authenticated write access to the "restricted"
         subtree.
      2. SecurityName "all-rights" has noAuthNoPriv read/write
         access to the "internet" subtree.
      3. Standard traps are sent to the manager.
      4. Community "public" is mapped to security name "initial".
      5. Community "all-rights" is mapped to security name "all-rights".
The following agent files were written: agent.conf, community.conf,
standard.conf, target_addr.conf, target_params.conf, 
notify.conf, vacm.conf and usm.conf
- - - - - - - - - - - - -

Configure a manager (y/n)? [y] 

Manager system config: 
----------------------
1. Manager process priority (low/normal/high) [normal] 
2. What SNMP version(s) should be used (1,2,3,1&2,1&2&3,2&3)? [3] 1&2&3
3. Configuration directory (absolute path)? [/ldisk/snmp] /ldisk/snmp/manager/conf
4. Config verbosity (silence/info/log/debug/trace)? [silence] log
5. Database directory (absolute path)? [/ldisk/snmp] /ldisk/snmp/manager/db
6. Database repair (true/false/force)? [true] 
7. Database auto save (infinity/milli seconds)? [5000] 
8. Inform request behaviour (auto/user)? [auto] 
9. Server verbosity (silence/info/log/debug/trace)? [silence] log
10. Server GC timeout? [30000] 
11. Note store verbosity (silence/info/log/debug/trace)? [silence] 
12. Note store GC timeout? [30000] 
13. Which network interface module shall be used? [snmpm_net_if] 
14. Network interface verbosity (silence/info/log/debug/trace)? [silence] log
15. Bind the manager IP address (true/false)? [false] 
16. Shall the manager IP address and port be not reusable (true/false)? [false] 
17. Receive buffer size of the manager (in bytes) (default/pos integer)? [default] 
18. Send buffer size of the manager (in bytes) (default/pos integer)? [default] 
19. Shall the manager use an audit trail log (y/n)? [n] y
19b. Where to store the audit trail log? [/ldisk/snmp] /ldisk/snmp/manager/log
19c. Max number of files? [10] 
19d. Max size (in bytes) of each file? [10240] 
19e. Audit trail log repair (true/false/truncate)? [true] 
20. Do you wish to assign a default user [yes] or use
    the default settings [no] (y/n)? [n] 

Manager snmp config: 
--------------------
1. Engine ID (snmpEngineID standard variable) [bmk's engine] 
2. Max message size? [484] 
3. IP address for the manager (only used as id 
   when sending requests) [127.0.0.1] 
4. Port number (standard 162)? [5000] 
5. Configure a user of this manager (y/n)? [y] 
5b. User id? kalle
5c. User callback module? snmpm_user_default
5d. User (callback) data? [undefined] 
5. Configure a user of this manager (y/n)? [y] n
6. Configure an agent handled by this manager (y/n)? [y] 
6b. User id? kalle
6c. Target name? [bmk's agent] 
6d. Version (1/2/3)? [1] 3
6e. Community string ? [public] 
6f. Engine ID (snmpEngineID standard variable) [bmk's engine] 
6g. IP address for the agent [127.0.0.1] 
6h. The UDP port the agent listens to. (standard 161) [4000] 
6i. Retransmission timeout (infinity/pos integer)? [infinity] 
6j. Max message size? [484] 
6k. Security model (any/v1/v2c/usm)? [any] usm
6l. Security name? ["initial"] 
6m. Security level (noAuthNoPriv/authNoPriv/authPriv)? [noAuthNoPriv] authPriv
6. Configure an agent handled by this manager (y/n)? [y] n
7. Configure an usm user handled by this manager (y/n)? [y] 
7a. Engine ID [bmk's engine] 
7b. User name? hobbes
7c. Security name? [hobbes] 
7d. Authentication protocol (no/sha/md5)? [no] sha
7e  Authentication [sha] key (length 0 or 20)? [""] [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, \
    17,18,19,20]
7d. Priv protocol (no/des/aes)? [no] des
7f  Priv [des] key (length 0 or 16)? [""] 10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25
7. Configure an usm user handled by this manager (y/n)? [y] n
8. Current configuration files will now be overwritten. Ok (y/n)? [y] 

- - - - - - - - - - - - -
The following manager files were written: manager.conf, agents.conf , users.conf and usm.conf
- - - - - - - - - - - - -

--------------------
Configuration directory for system file (absolute path)? [/ldisk/snmp] 
ok

5.3 启动应用程序

使用以下命令启动Erlang:

erl -config /tmp/snmp/sys

如果使用认证或加密(仅限SNMPv3),请启动加密应用程序。 如果忘记此步骤,代理将无法启动,但会报告{config_error,{unsupported_crypto,_}}错误。

1> application:start(crypto).
ok
2> application:start(snmp).
ok

5.4 调试应用程序

可能调试应用程序的每个(非超级用户)进程(代理和管理程序),可能除了应用程序用户可能提供的net_if模块之外)。 这通过调用snmpa:verbosity / 2和snmpm:verbosity / 2函数和/或使用配置参数来完成。 冗长本身有几个层次:沉默| info | 日志| 调试| 跟踪。 对于最低冗长的沉默,没有什么是印刷的。 冗长度越高,打印的越多。 默认值始终为静音。

3> snmpa:verbosity(master_agent, log).
ok
5> snmpa:verbosity(net_if, log).
ok
6> 
%% Example of output from the agent when a get-next-request arrives:
** SNMP NET-IF LOG: 
   got packet from {147,12,12,12}:5000

** SNMP NET-IF MPD LOG: 
   v1, community: all-rights

** SNMP NET-IF LOG: 
   got pdu from {147,12,12,12}:5000 {pdu, 'get-next-request',
                                          62612569,noError,0,
                                          [{varbind,[1,1],'NULL','NULL',1}]}

** SNMP MASTER-AGENT LOG: 
   apply: snmp_generic,variable_func,[get,{sysDescr,persistent}]

** SNMP MASTER-AGENT LOG: 
   returned: {value,"Erlang SNMP agent"}

** SNMP NET-IF LOG: 
   reply pdu: {pdu,'get-response',62612569,noError,0,
                   [{varbind,[1,3,6,1,2,1,1,1,0],
                             'OCTET STRING',
                             "Erlang SNMP agent",1}]}

** SNMP NET-IF INFO: time in agent: 19711 mysec

调试代理的其他有用函数有:

snmpa:info/0,1

info 用于检索其他代理信息的列表。

snmpa:which_aliasnames/0

which_aliasnames 用于检索代理已知的所有别名的列表。

snmpa:which_tables/0

which_tables 用于检索代理程序已知的所有(MIB)表的列表。

snmpa:which_variables/0

which_variables 用于检索代理程序已知的所有(MIB)变量的列表。

snmpa:which_notifications/0

which_notifications 用于检索代理程序已知的所有(MIB)通知/陷阱列表。

snmpa:restart_worker/0,1

restart_worker 用于重新启动多线程代理的工作进程。

snmpa:restart_set_worker/0,1

restart_set_worker 用于重新启动多线程代理的设置工作进程。

snmpa_local_db:print/0,1,2

例如,这个函数可以显示计数器snmpInPktssnmpOutPkts

调试代理的另一个有用方法是漂亮地打印代理直接处理的所有表和/或变量的内容。这可以通过简单地调用:

snmpa:print_mib_info()

print_mib_info/0print_mib_tables/0print_mib_variables/0获取更多信息。

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.6.代理配置文件的定义 | 6. Definition of Agent Configuration Files
6.7. Manager配置文件的定义 | 7. Definition of Manager Configuration Files
7.8.代理实现示例 | 8. Agent Implementation Example
8.9.管理实施例 | 9. Manager Implementation Example
9.10.检测函数 | 10. Instrumentation Functions
10.检测函数的定义 | 11. Definition of Instrumentation Functions
11.Net if的定义 | 12. Definition of Agent Net if
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