Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Tracing SNMP Activity on a Device Running Junos OS

SNMP tracing operations track activity for SNMP agents and record the information in log files. The logged error descriptions provide detailed information to help you solve problems faster.

By default, Junos OS does not trace any SNMP activity. If you include the traceoptions statement at the [edit snmp] hierarchy level, the default tracing behavior is:

  • Important activities are logged in files located in the /var/log directory. Each log is named after the SNMP agent that generates it. Currently, the following log files are created in the /var/log directory when the traceoptions statement is used:

    • chassisd

    • craftd

    • ilmid

    • mib2d

    • rmopd

    • serviced

    • snmpd

  • When a trace file named filename reaches its maximum size, it is renamed filename.0, then filename.1, and so on, until the maximum number of trace files is reached. Then the oldest trace file is overwritten. (For more information about how log files are created, see the System Log Explorer.)

  • Log files can be accessed only by the user who configured the tracing operation.

You cannot change the directory (/var/log) in which trace files are located. However, you can customize the other trace file settings by including the following statements at the [edit snmp] hierarchy level:

These statements are described in the following sections:

Configuring the Number and Size of SNMP Log Files

By default, when the trace file reaches 128 kilobytes (KB) in size, it is renamed filename.0, then filename.1, and so on, until there are three trace files. Then the oldest trace file (filename.2) is overwritten.

You can configure the limits on the number and size of trace files by including the following statements at the [edit snmp traceoptions] hierarchy level:

For example, set the maximum file size to 2 MB, and the maximum number of files to 20. When the file that receives the output of the tracing operation (filename) reaches 2 MB, filename is renamed filename.0, and a new file called filename is created. When the new filename reaches 2 MB, filename.0 is renamed filename.1 and filename is renamed filename.0. This process repeats until there are 20 trace files. Then the oldest file (filename.19) is overwritten by the newest file (filename.0).

The number of files can be from 2 through 1000 files. The file size of each file can be from 10 KB through 1 gigabyte (GB).

Configuring Access to the Log File

By default, log files can be accessed only by the user who configured the tracing operation.

To specify that any user can read all log files, include the file world-readable statement at the [edit snmp traceoptions] hierarchy level:

To explicitly set the default behavior, include the file no-world-readable statement at the [edit snmp traceoptions] hierarchy level:

Configuring a Regular Expression for Lines to Be Logged

By default, the trace operation output includes all lines relevant to the logged activities.

You can refine the output by including the match statement at the [edit snmp traceoptions file filename] hierarchy level and specifying a regular expression (regex) to be matched:

Configuring the Trace Operations

By default, only important activities are logged. You can specify which trace operations are to be logged by including the following flag statement (with one or more tracing flags) at the [edit snmp traceoptions] hierarchy level:

Table 1 describes the meaning of the SNMP tracing flags.

Table 1: SNMP Tracing Flags

Flag

Description

Default Setting

all

Log all operations.

Off

configuration

Log reading of the configuration at the [edit snmp] hierarchy level.

Off

database

Log events involving storage and retrieval in the events database.

Off

events

Log important events.

Off

general

Log general events.

Off

interface-stats

Log physical and logical interface statistics.

Off

nonvolatile-set

Log nonvolatile SNMP set request handling.

Off

pdu

Log SNMP request and response packets.

Off

policy

Log policy processing.

Off

protocol-timeouts

Log SNMP response timeouts.

Off

routing-socket

Log routing socket calls.

Off

server

Log communication with processes that are generating events.

Off

subagent

Log subagent restarts.

Off

timer

Log internal timer events.

Off

varbind-error

Log variable binding errors.

Off

To display the end of the log for an agent, issue the show log agentd | last operational mode command:

where agent is the name of an SNMP agent.