ON THIS PAGE
Example: Trace NETCONF and Junos XML Protocol Session Operations
This example demonstrates how to configure tracing operations for NETCONF and Junos XML protocol sessions.
Starting in Junos OS Release
16.1, when you enable tracing operations at the [edit system
services netconf traceoptions]
hierarchy, Junos OS enables tracing
operations for both NETCONF and Junos XML protocol sessions and adds
the [NETCONF]
and [JUNOScript]
tags to the log file entries to distinguish the type of session.
Prior to Junos OS Release 16.1, only NETCONF session data was logged,
and the [NETCONF]
tag was omitted.
Requirements
A routing, switching, or security device running Junos OS Release 16.1 or later is required.
Overview
This example configures basic tracing operations for NETCONF
and Junos XML protocol sessions. The example configures the trace
file netconf-ops.log and sets a maximum
number of 20 trace files and a maximum size of 3 MB for each
file. The flag all
statement configures tracing for all
incoming and outcoming NETCONF or Junos XML protocol data. The world-readable
option enables unrestricted access to the trace
files.
Configuration
CLI Quick Configuration
To quickly configure this example, copy the following
commands, paste them in a text file, remove any line breaks, change
any details necessary to match your network configuration, and then
copy and paste the commands into the CLI at the [edit]
hierarchy
level.
set system services netconf ssh set system services netconf traceoptions file netconf-ops.log set system services netconf traceoptions file size 3m set system services netconf traceoptions file files 20 set system services netconf traceoptions file world-readable set system services netconf traceoptions flag all
Configuring NETCONF and Junos XML Protocol Tracing Operations
Step-by-Step Procedure
To configure NETCONF and Junos XML protocol tracing operations:
For NETCONF sessions, enable NETCONF over SSH.
[edit] user@R1# set system services netconf ssh
Configure the traceoptions flag to specify which session data to capture.
You can specify incoming, outgoing, or all data. This example configures tracing for all session data.
[edit] user@R1# set system services netconf traceoptions flag all
(Optional) Configure the filename of the trace file.
The following statement configures the trace file netconf-ops.log, which is stored in the /var/log directory. If you do not specify a filename, NETCONF and Junos XML protocol session data is stored in /var/log/netconf.
[edit] user@R1# set system services netconf traceoptions file netconf-ops.log
(Optional) Configure the maximum number of trace files and the maximum size of each file.
The following statements configure a maximum of 20 trace files with a maximum size of 3 MB per file.
[edit] user@R1# set system services netconf traceoptions file files 20 user@R1# set system services netconf traceoptions file size 3m
(Optional) Restrict the trace output to include only those lines that match a particular regular expression.
The following configuration, which is not used in this example, matches on and logs only session data that contains “error-message”.
[edit] user@R1# set system services netconf traceoptions file match error-message
(Optional) Configure on-demand tracing to control tracing operations from the NETCONF or Junos XML protocol session.
The following configuration, which is not used in this example, enables on-demand tracing.
[edit] user@R1# set system services netconf traceoptions on-demand
(Optional) Configure the permissions on the trace file by specifying whether the file is
world-readable
orno-world-readable
.This example enables unrestricted access to the trace file.
[edit] user@R1# set system services netconf traceoptions file world-readable
Commit the configuration.
[edit] user@R1# commit
Results
[edit] system { services { netconf { ssh; traceoptions { file netconf-ops.log size 3m files 20 world-readable; flag all; } } } }
Verification
Verifying NETCONF and Junos XML protocol Tracing Operation
Purpose
Verify that the device is writing NETCONF and Junos XML protocol session data to the configured trace file. This example logs both incoming and outgoing NETCONF and Junos XML protocol data. In the sample NETCONF session, which is not detailed here, the user modifies the candidate configuration on R1 to include the bgp-troubleshoot.slax op script and then commits the configuration.
Action
Display the trace output of the configured trace file /var/log/netconf-ops.log by issuing the show log operational mode command.
user@R1 show log netconf-ops.log Apr 3 13:09:04 [NETCONF] Started tracing session: 3694 Apr 3 13:09:29 [NETCONF] - [3694] Incoming: <rpc> Apr 3 13:09:29 [NETCONF] - [3694] Outgoing: <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/16.1R1/junos"> Apr 3 13:09:39 [NETCONF] - [3694] Incoming: <edit-config> Apr 3 13:09:43 [NETCONF] - [3694] Incoming: <target> Apr 3 13:09:47 [NETCONF] - [3694] Incoming: <candidate/> Apr 3 13:09:53 [NETCONF] - [3694] Incoming: </target> Apr 3 13:10:07 [NETCONF] - [3694] Incoming: <default-operation>merge</default-operation> Apr 3 13:10:10 [NETCONF] - [3694] Incoming: <config> Apr 3 13:10:13 [NETCONF] - [3694] Incoming: <configuration> Apr 3 13:10:16 [NETCONF] - [3694] Incoming: <system> Apr 3 13:10:19 [NETCONF] - [3694] Incoming: <scripts> Apr 3 13:10:23 [NETCONF] - [3694] Incoming: <op> Apr 3 13:10:26 [NETCONF] - [3694] Incoming: <file> Apr 3 13:10:44 [NETCONF] - [3694] Incoming: <name>bgp-troubleshoot.slax</name> Apr 3 13:10:46 [NETCONF] - [3694] Incoming: </file> Apr 3 13:10:48 [NETCONF] - [3694] Incoming: </op> Apr 3 13:10:52 [NETCONF] - [3694] Incoming: </scripts> Apr 3 13:10:56 [NETCONF] - [3694] Incoming: </system> Apr 3 13:11:00 [NETCONF] - [3694] Incoming: </configuration> Apr 3 13:11:00 [NETCONF] - [3694] Outgoing: <ok/> Apr 3 13:11:12 [NETCONF] - [3694] Incoming: </config> Apr 3 13:11:18 [NETCONF] - [3694] Incoming: </edit-config> Apr 3 13:11:26 [NETCONF] - [3694] Incoming: </rpc> Apr 3 13:11:26 [NETCONF] - [3694] Outgoing: </rpc-reply> Apr 3 13:11:26 [NETCONF] - [3694] Outgoing: ]]>]]> Apr 3 13:11:31 [NETCONF] - [3694] Incoming: ]]>]]> Apr 3 13:14:20 [NETCONF] - [3694] Incoming: <rpc> Apr 3 13:14:20 [NETCONF] - [3694] Outgoing: <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/16.1R1/junos"> Apr 3 13:14:26 [NETCONF] - [3694] Incoming: <commit/> Apr 3 13:14:35 [NETCONF] - [3694] Outgoing: <ok/> Apr 3 13:14:35 [NETCONF] - [3694] Incoming: </rpc> Apr 3 13:14:35 [NETCONF] - [3694] Outgoing: </rpc-reply> Apr 3 13:14:35 [NETCONF] - [3694] Outgoing: ]]>]]> Apr 3 13:14:40 [NETCONF] - [3694] Incoming: ]]>]]> Apr 3 13:30:48 [NETCONF] - [3694] Outgoing: <!-- session end at 2016-12-03 13:30:48 PDT -->
Meaning
This example configured the flag all
statement,
so the trace file displays all incoming and outgoing NETCONF or Junos
XML protocol session operations. Each operation includes the date
and timestamp. The log file indicates the type of session, either
NETCONF or Junos XML protocol, by including the [NETCONF]
or [JUNOScript]
tag, respectively.
Multiple NETCONF and Junos XML protocol sessions are distinguished
by a session number. In this example, only one NETCONF session, using
session identifier 3694, is active.
Change History Table
Feature support is determined by the platform and release you are using. Use Feature Explorer to determine if a feature is supported on your platform.
[edit system
services netconf traceoptions]
hierarchy, Junos OS enables tracing
operations for both NETCONF and Junos XML protocol sessions and adds
the [NETCONF]
and [JUNOScript]
tags to the log file entries to distinguish the type of session.
Prior to Junos OS Release 16.1, only NETCONF session data was logged,
and the [NETCONF]
tag was omitted.