5 Running the Agent
This chapter describes how the agent is configured and started. The topics include:
- configuration directories and parameters
- modifying the configuration files
- starting the agent
- debugging the agent.
Refer also to the chapter Definition of Configuration Files which contains more detailed information about the configuration files.
5.1 Configuring the Agent
The following two directories must exist in the system:
- the configuration directory stores all configuration files (refer to the chapter Definition of Configuration Files for more information).
- the database directory stores the internal database files.
The agent uses application configuration parameters to find out where these directories are located. These parameters should be defined in an Erlang system configuration file. The following configuration parameters are defined for the SNMP application:
audit_trail_log = false | write_log | read_write_log <optional>
- Specifies if an audit trail log should be used. The
disk_log
module is used to maintain a wrap log. Ifwrite_log
is specified, only set requests are logged. Ifread_write_log
, all requests are logged. Default isfalse
.
audit_trail_log_dir = string() <optional>
- Specifies where the audit trail log should be stored. If
audit_trail_log
specifies that logging should take place, this parameter must be defined.
audit_trail_log_size = {MaxBytes, MaxFiles} <optional>
- Specifies the size of the audit trail log. This parameter is sent to
disk_log
. Ifaudit_trail_log
specifies that logging should take place, this parameter must be defined.
snmp_agent_type = master | sub <optional>
- If
master
, one master agent is started. Otherwise, no agents are started. Default ismaster
.
snmp_config_dir = string() <mandatory>
- Defines where the SNMP configuration files and the compiled master agent MIB files are stored.
snmp_db_dir = string() <mandatory>
- Defines where the SNMP internal db files are stored.
snmp_master_agent_mibs = [string()] <optional>
- Specifies a list of MIB names and defines which MIBs are initially loaded into the SNMP master agent. These MIBs are loaded from
snmp_config_dir
.
snmp_multi_threaded = bool() <optional>
- If
true
, the agent is multi threaded, with one thread for each get request. Default isfalse
.
snmp_priority = atom() <optional>
- Defines the Erlang priority for all SNMP processes. Default is
normal
.
v1 = bool() <optional>
- Defines if the agent shall speak SNMPv1. Default is
true
.
v2 = bool() <optional>
- Defines if the agent shall speak SNMPv2c. Default is
true
.
5.2 Modifying the Configuration Files
To to start the agent, the agent configuration files must be modified and there are two ways of doing this. Either edit the files manually, or run the configuration tool as follows:
1> snmp:config(). Simple SNMP configuration tool (v2.2) ---------------------------------------------- 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 1. System name (sysName standard variable) [mbj's agent] 2. The UDP port the agent listens to. (standard 161) [4000] 3. IP address for the agent (only used as id when sending traps) [dront.ericsson.se] 4. IP address for the manager (only this manager will have access to the agent, traps are sent to this one) [dront.ericssob.se] 5. To what UDP port at the manager should traps be sent (standard 162)? [5000] 6. What SNMP version should be used (1,2,1&2)? [2] 6.b. Should a notification be sent as trap or inform? [trap] 7. Where is the configuration directory (absolute)? [/home/eklas/work] 8. Current configuration files will now be overwritten. Ok [y]/n? ------------------------ Info: 1. Community "public" has read-only access to all mibs. 2. Community "all-rights" has read-write access to all mibs. 3. Standard traps (community "standard trap") is sent to the manager. The following files were written: address.conf, agent.conf, community.conf, standard.conf, target_addr.conf, target_params.conf notify.conf view.conf, sys.config ------------------------ ok5.3 Starting the Agent
Start Erlang with the command:
erl -config /home/eklas/work/sys1> application:start(snmp). ok5.4 Debugging the Agent
The debug flag can be turned on to verify that the configuration is correct and that the instrumentation functions behave as expected. The agent then shows all network communication (incoming/outgoing traffic), and calls to instrumentation functions.
1> snmp:debug(snmp_master_agent, true). ok 2> %% Example of output from the agent when a get-request arrives: ** SNMP Agent debug: got pdu from {{147,12,12,12},5000}, community "public" pdu: {pdu,'get-next-request',31123857,noError,0, [{varbind,[1,1,2],'NULL','NULL',1}]} ** SNMP Agent debug: apply: snmp_generic,variable_func,[get,{sysDescr,permanent}] returned: {value,"Erlang SNMPv1 agent"} ** SNMP Net if debug: reply pdu: {pdu,'get-response',31123857,noError,0, [{varbind,[1,3,6,1,2,1,1,1,0],'OCTET STRING', "Erlang SNMPv1 agent",1}]} 2>Another useful function for debugging is
snmp_local_db:print/0,1,2
. For example, this function can show the counterssnmpInPkts
andsnmpOutPkts
. Enter the following command:1> snmp_local_db:print(). %% A lot of information.