Erlang -- ct_snmp

Common Test

Reference Manual

Version 1.18

- User's Guide
- Reference Manual
- Release Notes
- PDF
- Top

- Expand All
- Contract All

### Table of Contents

- common_test
  - Top of manual page
  - Module:Testcase/0
  - Module:Testcase/1
  - Module:all/0
  - Module:end_per_group/2
  - Module:end_per_suite/1
  - Module:end_per_testcase/2
  - Module:group/1
  - Module:groups/0
  - Module:init_per_group/2
  - Module:init_per_suite/1
  - Module:init_per_testcase/2
  - Module:suite/0
- ct_run
- ct
  - Top of manual page
  - abort_current_testcase/1
  - add_config/2
  - break/1
  - break/2
  - capture_get/0
  - capture_get/1
  - capture_start/0
  - capture_stop/0
  - comment/1
  - comment/2
  - continue/0
  - continue/1
  - decrypt_config_file/2
  - decrypt_config_file/3
  - encrypt_config_file/2
  - encrypt_config_file/3
  - fail/1
  - fail/2
  - get_config/1
  - get_config/2
  - get_config/3
  - get_event_mgr_ref/0
  - get_progname/0
  - get_status/0
  - get_target_name/1
  - get_testspec_terms/0
  - get_testspec_terms/1
  - get_timetrap_info/0
  - get_verbosity/1
  - install/1
  - listenv/1
  - log/1
  - log/2
  - log/3
  - log/4
  - log/5
  - make_priv_dir/0
  - notify/2
  - pal/1
  - pal/2
  - pal/3
  - pal/4
  - pal/5
  - parse_table/1
  - print/1
  - print/2
  - print/3
  - print/4
  - print/5
  - reload_config/1
  - remaining_test_procs/0
  - remove_config/2
  - require/1
  - require/2
  - run/1
  - run/2
  - run/3
  - run_test/1
  - run_testspec/1
  - set_verbosity/2
  - sleep/1
  - start_interactive/0
  - step/3
  - step/4
  - stop_interactive/0
  - sync_notify/2
  - testcases/2
  - timetrap/1
  - userdata/2
  - userdata/3
- ct_master
  - Top of manual page
  - abort/0
  - abort/1
  - basic_html/1
  - get_event_mgr_ref/0
  - progress/0
  - run/1
  - run/3
  - run/4
  - run_on_node/2
  - run_on_node/3
  - run_test/2
- ct_cover
  - Top of manual page
  - add_nodes/1
  - cross_cover_analyse/2
  - remove_nodes/1
- ct_ftp
  - Top of manual page
  - cd/2
  - close/1
  - delete/2
  - get/3
  - ls/2
  - open/1
  - put/3
  - recv/2
  - recv/3
  - send/2
  - send/3
  - type/2
- ct_ssh
  - Top of manual page
  - apread/4
  - apread/5
  - apwrite/4
  - apwrite/5
  - aread/3
  - aread/4
  - awrite/3
  - awrite/4
  - close/2
  - close/3
  - connect/1
  - connect/2
  - connect/3
  - del_dir/2
  - del_dir/3
  - delete/2
  - delete/3
  - disconnect/1
  - exec/2
  - exec/3
  - exec/4
  - get_file_info/2
  - get_file_info/3
  - list_dir/2
  - list_dir/3
  - make_dir/2
  - make_dir/3
  - make_symlink/3
  - make_symlink/4
  - open/3
  - open/4
  - opendir/2
  - opendir/3
  - position/3
  - position/4
  - pread/4
  - pread/5
  - pwrite/4
  - pwrite/5
  - read/3
  - read/4
  - read_file/2
  - read_file/3
  - read_file_info/2
  - read_file_info/3
  - read_link/2
  - read_link/3
  - read_link_info/2
  - read_link_info/3
  - receive_response/2
  - receive_response/3
  - receive_response/4
  - rename/3
  - rename/4
  - send/3
  - send/4
  - send/5
  - send_and_receive/3
  - send_and_receive/4
  - send_and_receive/5
  - send_and_receive/6
  - session_close/2
  - session_open/1
  - session_open/2
  - sftp_connect/1
  - shell/2
  - shell/3
  - subsystem/3
  - subsystem/4
  - write/3
  - write/4
  - write_file/3
  - write_file/4
  - write_file_info/3
  - write_file_info/4
- ct_netconfc
  - Top of manual page
  - action/2
  - action/3
  - close_session/1
  - close_session/2
  - connect/1
  - connect/2
  - copy_config/3
  - copy_config/4
  - create_subscription/2
  - create_subscription/3
  - delete_config/2
  - delete_config/3
  - disconnect/1
  - edit_config/3
  - edit_config/4
  - edit_config/5
  - get/2
  - get/3
  - get_capabilities/1
  - get_capabilities/2
  - get_config/3
  - get_config/4
  - get_event_streams/1
  - get_event_streams/2
  - get_event_streams/3
  - get_session_id/1
  - get_session_id/2
  - hello/1
  - hello/2
  - hello/3
  - kill_session/2
  - kill_session/3
  - lock/2
  - lock/3
  - only_open/1
  - only_open/2
  - open/1
  - open/2
  - send/2
  - send/3
  - send_rpc/2
  - send_rpc/3
  - session/1
  - session/2
  - session/3
  - unlock/2
  - unlock/3
- ct_rpc
  - Top of manual page
  - app_node/2
  - app_node/3
  - app_node/4
  - call/4
  - call/5
  - call/6
  - cast/4
  - cast/5
- ct_snmp
  - Top of manual page
  - get_next_values/3
  - get_values/3
  - load_mibs/1
  - register_agents/2
  - register_users/2
  - register_usm_users/2
  - set_info/1
  - set_values/4
  - start/2
  - start/3
  - stop/1
  - unload_mibs/1
  - unregister_agents/1
  - unregister_agents/2
  - unregister_users/1
  - unregister_users/2
  - unregister_usm_users/1
  - unregister_usm_users/2
- ct_telnet
  - Top of manual page
  - close/1
  - cmd/2
  - cmd/3
  - cmdf/3
  - cmdf/4
  - expect/2
  - expect/3
  - get_data/1
  - open/1
  - open/2
  - open/3
  - open/4
  - send/2
  - send/3
  - sendf/3
  - sendf/4
- unix_telnet
  - Top of manual page
  - connect/7
  - get_prompt_regexp/0
- ct_slave
  - Top of manual page
  - start/1
  - start/2
  - start/3
  - stop/1
  - stop/2
- ct_hooks
  - Top of manual page
  - Module:id/1
  - Module:init/2
  - Module:on_tc_fail/4
  - Module:on_tc_skip/4
  - Module:post_all/3
  - Module:post_end_per_group/5
  - Module:post_end_per_suite/4
  - Module:post_end_per_testcase/5
  - Module:post_groups/2
  - Module:post_init_per_group/5
  - Module:post_init_per_suite/4
  - Module:post_init_per_testcase/5
  - Module:pre_end_per_group/4
  - Module:pre_end_per_suite/3
  - Module:pre_end_per_testcase/4
  - Module:pre_init_per_group/4
  - Module:pre_init_per_suite/3
  - Module:pre_init_per_testcase/4
  - Module:terminate/1
- ct_property_test
  - Top of manual page
  - init_per_suite/1
  - quickcheck/2
- ct_testspec
  - Top of manual page
  - get_tests/1

# ct_snmp

### Module

ct_snmp

### Module Summary

Common Test user interface module for the SNMP application.

### Description

Common Test user interface module for the SNMP application.

The purpose of this module is to simplify SNMP configuration for the test case writer. Many test cases can use default values for common operations and then no SNMP configuration files need to be supplied. When it is necessary to change particular configuration parameters, a subset of the relevant SNMP configuration files can be passed to ct_snmp by Common Test configuration files. For more specialized configuration parameters, a simple SNMP configuration file can be placed in the test suite data directory. To simplify the test suite, Common Test keeps track of some of the SNMP manager information. This way the test suite does not have to handle as many input parameters as if it had to interface wthe OTP SNMP manager directly.

Configurable SNMP Manager and Agent Parameters:

Manager configuration:

[{start_manager, boolean()}

  Optional. Default is true.

{users, [{user_name(), [call_back_module(), user_data()]}]}

  Optional.

{usm_users, [{usm_user_name(), [usm_config()]}]}

  Optional. SNMPv3 only.

{managed_agents,[{agent_name(), [user_name(), agent_ip(), agent_port(), [agent_config()]]}]}

  managed_agents is optional.

{max_msg_size, integer()}

  Optional. Default is 484.

{mgr_port, integer()}

  Optional. Default is 5000.

{engine _id, string()}

  Optional. Default is "mgrEngine".

Agent configuration:

{start_agent, boolean()}

  Optional. Default is false.

{agent_sysname, string()}

  Optional. Default is "ct_test".

{agent_manager_ip, manager_ip()}

  Optional. Default is localhost.

{agent_vsns, list()}

  Optional. Default is [v2].

{agent_trap_udp, integer()}

  Optional. Default is 5000.

{agent_udp, integer()}

  Optional. Default is 4000.

{agent_notify_type, atom()}

  Optional. Default is trap.

{agent_sec_type, sec_type()}

  Optional. Default is none.

{agent_passwd, string()}

  Optional. Default is "".

{agent_engine_id, string()}

  Optional. Default is "agentEngine".

{agent_max_msg_size, string()}

  Optional. Default is 484.

The following parameters represents the SNMP configuration files context.conf, standard.conf, community.conf, vacm.conf, usm.conf, notify.conf, target_addr.conf, and target_params.conf. Notice that all values in agent.conf can be modified by the parameters listed above. All these configuration files have default values set by the SNMP application. These values can be overridden by suppling a list of valid configuration values or a file located in the test suites data directory, which can produce a list of valid configuration values if you apply function file:consult/1 to the file.

{agent_contexts, [term()] | {data_dir_file, rel_path()}}

  Optional.

{agent_community, [term()] | {data_dir_file, rel_path()}}

  Optional.

{agent_sysinfo, [term()] | {data_dir_file, rel_path()}}

  Optional.

{agent_vacm, [term()] | {data_dir_file, rel_path()}}

  Optional.

{agent_usm, [term()] | {data_dir_file, rel_path()}}

  Optional.

{agent_notify_def, [term()] | {data_dir_file, rel_path()}}

  Optional.

{agent_target_address_def, [term()] | {data_dir_file, rel_path()}}

  Optional.

{agent_target_param_def, [term()] | {data_dir_file, rel_path()}}

  Optional.

Parameter MgrAgentConfName in the functions is to be a name you allocate in your test suite using a require statement. Example (where MgrAgentConfName = snmp_mgr_agent):

     suite() -> [{require, snmp_mgr_agent, snmp}].

or

     ct:require(snmp_mgr_agent, snmp).

Notice that USM users are needed for SNMPv3 configuration and are not to be confused with users.

SNMP traps, inform, and report messages are handled by the user callback module. For details, see the SNMP application.

It is recommended to use the .hrl files created by the Erlang/OTP MIB compiler to define the Object Identifiers (OIDs). For example, to get the Erlang node name from erlNodeTable in the OTP-MIB:

     Oid = ?erlNodeEntry ++ [?erlNodeName, 1]

Furthermore, values can be set for SNMP application configuration parameters, config, server, net_if, and so on (for a list of valid parameters and types, see the User's Guide for the SNMP application). This is done by defining a configuration data variable on the following form:

     {snmp_app, [{manager, [snmp_app_manager_params()]},
                 {agent, [snmp_app_agent_params()]}]}.

A name for the data must be allocated in the suite using require (see the example above). Pass this name as argument SnmpAppConfName to ct_snmp:start/3. ct_snmp specifies default values for some SNMP application configuration parameters (such as {verbosity,trace} for parameter config). This set of defaults is merged with the parameters specified by the user. The user values override ct_snmp defaults.

### Data Types

agent_config() = {Item, Value}
agent_ip() = ip()
agent_name() = atom()
agent_port() = integer()
call_back_module() = atom()
error_index() = integer()
error_status() = noError | atom()
ip() = string() | {integer(), integer(), integer(), integer()}
manager_ip() = ip()
oid() = [byte()]
oids() = [oid()]
rel_path() = string()
sec_type() = none | minimum | semi
snmp_app_agent_params() = term()
snmp_app_manager_params() = term()
snmpreply() = {error_status(), error_index(), varbinds()}
user_data() = term()
user_name() = atom()
usm_config() = {Item, Value}
usm_user_name() = string()
value_type() = o('OBJECT IDENTIFIER') | i('INTEGER') | u('Unsigned32') | g('Unsigned32') | s('OCTET STRING')
var_and_val() = {oid(), value_type(), value()}
varbind() = term()
varbinds() = [varbind()]
varsandvals() = [var_and_val()]

These data types are described in the documentation for the SNMP application.

### Exports

get_next_values(Agent, Oids, MgrAgentConfName) -> SnmpReply |

### Types

Agent = agent_name()
Oids = oids()
MgrAgentConfName = atom()
SnmpReply = snmpreply()

Issues a synchronous SNMP get next request.

get_values(Agent, Oids, MgrAgentConfName) -> SnmpReply |

### Types

Agent = agent_name()
Oids = oids()
MgrAgentConfName = atom()
SnmpReply = snmpreply()

Issues a synchronous SNMP get request.

load_mibs(Mibs) -> ok | {error, Reason} |

### Types

Mibs = [MibName]
MibName = string()
Reason = term()

Loads the MIBs into agent snmp_master_agent.

register_agents(MgrAgentConfName, ManagedAgents) -> ok | {error, Reason} |

### Types

MgrAgentConfName = atom()
ManagedAgents = [agent()]
Reason = term()

Explicitly instructs the manager to handle this agent. Corresponds to making an entry in agents.conf.

This function tries to register the specified managed agents, without checking if any of them exist. To change a registered managed agent, the agent must first be unregistered.

register_users(MgrAgentConfName, Users) -> ok | {error, Reason} |

### Types

MgrAgentConfName = atom()
Users = [user()]
Reason = term()

Registers the manager entity (=user) responsible for specific agent(s). Corresponds to making an entry in users.conf.

This function tries to register the specified users, without checking if any of them exist. To change a registered user, the user must first be unregistered.

register_usm_users(MgrAgentConfName, UsmUsers) -> ok | {error, Reason} |

### Types

MgrAgentConfName = atom()
UsmUsers = [usm_user()]
Reason = term()

Explicitly instructs the manager to handle this USM user. Corresponds to making an entry in usm.conf.

This function tries to register the specified users, without checking if any of them exist. To change a registered user, the user must first be unregistered.

set_info(Config) -> [{Agent, OldVarsAndVals, NewVarsAndVals}] |

### Types

Config = [{Key, Value}]
Agent = agent_name()
OldVarsAndVals = varsandvals()
NewVarsAndVals = varsandvals()

Returns a list of all successful set requests performed in the test case in reverse order. The list contains the involved user and agent, the value before set, and the new value. This is intended to simplify the cleanup in function end_per_testcase, that is, the undoing of the set requests and their possible side-effects.

set_values(Agent, VarsAndVals, MgrAgentConfName, Config) -> SnmpReply |

### Types

Agent = agent_name()
Oids = oids()
MgrAgentConfName = atom()
Config = [{Key, Value}]
SnmpReply = snmpreply()

Issues a synchronous SNMP set request.

start(Config, MgrAgentConfName) -> ok |

Equivalent to ct_snmp:start(Config, MgrAgentConfName, undefined).

start(Config, MgrAgentConfName, SnmpAppConfName) -> ok |

### Types

Config = [{Key, Value}]
Key = atom()
Value = term()
MgrAgentConfName = atom()
SnmpConfName = atom()

Starts an SNMP manager and/or agent. In the manager case, registrations of users and agents, as specified by the configuration MgrAgentConfName, are performed. When using SNMPv3, called USM users are also registered. Users, usm_users, and managed agents can also be registered later using ct_snmp:register_users/2, ct_snmp:register_agents/2, and ct_snmp:register_usm_users/2.

The agent started is called snmp_master_agent. Use ct_snmp:load_mibs/1 to load MIBs into the agent.

With SnmpAppConfName SNMP applications can be configured with parameters config, mibs, net_if, and so on. The values are merged with (and possibly override) default values set by ct_snmp.

stop(Config) -> ok |

### Types

Config = [{Key, Value}]
Key = atom()
Value = term()

Stops the SNMP manager and/or agent, and removes all files created.

unload_mibs(Mibs) -> ok | {error, Reason} | OTP R16B

### Types

Mibs = [MibName]
MibName = string()
Reason = term()

Unloads the MIBs from agent snmp_master_agent.

unregister_agents(MgrAgentConfName) -> ok |

### Types

MgrAgentConfName = atom()
Reason = term()

Unregisters all managed agents.

unregister_agents(MgrAgentConfName, ManagedAgents) -> ok | OTP R16B

### Types

MgrAgentConfName = atom()
ManagedAgents = [agent_name()]
Reason = term()

Unregisters the specified managed agents.

unregister_users(MgrAgentConfName) -> ok |

### Types

MgrAgentConfName = atom()
Reason = term()

Unregisters all users.

unregister_users(MgrAgentConfName, Users) -> ok | OTP R16B

### Types

MgrAgentConfName = atom()
Users = [user_name()]
Reason = term()

Unregisters the specified users.

unregister_usm_users(MgrAgentConfName) -> ok | OTP R16B

### Types

MgrAgentConfName = atom()
Reason = term()

Unregisters all USM users.

unregister_usm_users(MgrAgentConfName, UsmUsers) -> ok | OTP R16B

### Types

MgrAgentConfName = atom()
UsmUsers = [usm_user_name()]
Reason = term()

Unregisters the specified USM users.