Junos traceoptions is the same as the debugging tools from Cisco and many other vendors. You can use the traceoptions feature to monitor the device background process and traffic to and from the Juniper device.

Traceoptions is a critical tool in troubleshooting, but it takes up a lot of disk space and needs to be enabled when needed and disabled after troubleshooting is complete.

Juniper Junos "traceoptions" concept

Traceoptions can be limited to a specific scope such as all interfaces or a specific interface, routing protocols such as OSPF, BGP, and many other contexts.

Juniper Junos traceoptions
Juniper Junos traceoptions

To configure traceoptions, you must first activate it in a specific Context. Then you need to configure at least two options “flag” and “file”.

With “flag” option, you specify which part of this specific content should be monitored. For example, in OSPF context, do you want to monitor only OSPF neighborship packets, or also monitor OSPF database traffic.

With “file” option, allows you to configure the name of the file where the monitored information output will be stored. You can also configure the maximum size of the file and also the number of file to store the latest information.

Juniper Junos traceoptions Configuration

To configure traceoptions, you must first enter the context in which you want to debug the background process or traffic flow.

For example, if you want to debug interface-related information, enter to the interface context to enable traceoptions.

Under Traceoptions, you have two necessary options that need to be configured. the “flag” option that allows you to limit debugging information to a specific type and the “file” option to specify the name of the file, the size of the file and the number of the files to store the debugging result.

rayka@vSRX1# set interfaces traceoptions ?    
Possible completions:
+ apply-groups         Groups from which to inherit configuration data
+ apply-groups-except  Don't inherit configuration data from these groups
> file                 Trace file information
> flag                 Tracing parameters
  no-remote-trace      Disable remote tracing
[edit]
rayka@vSRX1# set interfaces traceoptions flag ?                           
Possible completions:
  alert                Log DCD alert events
  all                  Enable all configuration logging
  bfd-events           Log BFD related events
  change-events        Log changes that produce configuration events
  config-states        Log the configuration state machine changes
  critical             Log DCD critical events
  debugging            Log DCD debug events
  emergency            Log DCD emergency events
  error                Log DCD error events
  gres-events          Log the events related to GRES 
  informational        Log DCD informations
  japi                 Log DCD JAPI events
  kernel               Log configuration IPC messages to kernel
  kernel-detail        Log details of configuration messages to kernel
  lib-events           Log DCD library related events
  notice               Log DCD notification events
  reserved             Reserved DCD logs
  resource-usage       Log the resource usage for different states
  select-events        Log the events on select state machine 
  verbose              Log DCD debug all events
  warning              Log DCD warning events
[edit]
rayka@vSRX1# set interfaces traceoptions file ?  
Possible completions:
  <filename>           Name of file in which to write trace information
  files                Maximum number of trace files (2..1000)
  match                Regular expression for lines to be logged
  no-world-readable    Don't allow any user to read the log file
  size                 Maximum trace file size (10240..1073741824)
  world-readable       Allow any user to read the log file
[edit]
rayka@vSRX1#

As an example, I choose “all” for “flag” option to debug all interface related information.

For “file” option,  I choose a name for the file name, limit the number of file to 3 and size of each file to 2MB.

It is also possible to enable traceoptions for specific interface. For example I enable traceoptions for ge-0/0/0 interface.

[edit]
rayka@vSRX1# set interfaces ge-0/0/0 traceoptions ?
Possible completions:
  <[Enter]>            Execute this command
+ apply-groups         Groups from which to inherit configuration data
+ apply-groups-except  Don't inherit configuration data from these groups
> flag                 Tracing parameters
  |                    Pipe through a command
[edit]
rayka@vSRX1#         

To review the configuration, we can check it with “show | compare” command before entering “commit” command.

[edit]
rayka@vSRX1# show | compare                                                      
[edit interfaces]
+   traceoptions {
+       file interfaceslogs size 2000000 files 3;
+       flag all;
+   }
[edit interfaces ge-0/0/0]
+    traceoptions {
+        flag all;
+    }

After commit command, you can check activated traceoptions with “show configuration” command.

[edit]
rayka@vSRX1# run show configuration | display set | grep traceoptions 
set interfaces traceoptions file interfaceslogs
set interfaces traceoptions file size 2000000
set interfaces traceoptions file files 3
set interfaces traceoptions flag all
set interfaces ge-0/0/0 traceoptions flag all

[edit]
rayka@vSRX1# 

You can enable “traceoptions” in many context like OSPF and BGP routing protocol.

[edit]
rayka@vSRX1# set protocols bgp traceoptions ?                    
Possible completions:
+ apply-groups         Groups from which to inherit configuration data
+ apply-groups-except  Don't inherit configuration data from these groups
> file                 Trace file options
> flag                 Tracing parameters
[edit]
rayka@vSRX1# set protocols ospf traceoptions ?    
Possible completions:
+ apply-groups         Groups from which to inherit configuration data
+ apply-groups-except  Don't inherit configuration data from these groups
> file                 Trace file options
> flag                 Tracing parameters
[edit]
rayka@vSRX1# 

You can check the output of traceoptions outputs with show log command.

[edit]
rayka@vSRX1# run show log interfaceslogs | last 
May 29 20:40:44.011823 20291 parser_util.c:20176 is_aggr_child_link() DEBUG : Link sp-0/0/0 is not a child of any aggrgated device
May 29 20:40:44.011881 20291 telemetry_db.c:802 dcd_telemetry_is_curr_and_prev_parent_same() DEBUG : Not an ae child link
May 29 20:40:44.011939 20291 telemetry_db.c:883 dcd_build_and_publish_telemetry() DEBUG : prev and cur not equal
May 29 20:40:44.011995 20291 telemetry_db.c:900 dcd_build_and_publish_telemetry() DEBUG : prev parent is (NULL). no change
May 29 20:40:44.012052 20291 telemetry_db.c:906 dcd_build_and_publish_telemetry() DEBUG : Curr pat ae (null)
May 29 20:40:44.012110 20291 parser_util.c:20176 is_aggr_child_link() DEBUG : Link sp-0/0/0 is not a child of any aggrgated device
May 29 20:40:44.012168 20291 telemetry_patricia.c:136 dcd_telemetry_find_ae_from_member() INFO : Could not find ae node for member sp-0/0/0
May 29 20:40:44.012321 20291 telemetry_db.c:917 dcd_build_and_publish_telemetry() DEBUG : Parent ae-ifd (null) of mem-intf sp-0/0/0
May 29 20:40:44.012376 20291 telemetry_db.c:928 dcd_build_and_publish_telemetry() DEBUG : sp-0/0/0 not found in patricia tree. return
May 29 20:40:44.012436 20291 dcd_sock.c:2310 dcd_process_async_ifd_subtree() INFO : Entering async operation [2] on [sp-0/0/0]
May 29 20:40:44.012496 20291 dcd_sock.c:2367 dcd_process_async_ifd_subtree() INFO : tree_entry [0x224b920], conf[0x225cf90], overlay[0x0], kernel[0x225dc80], defaults [0x2735660], dcd_added_ifd [0].
May 29 20:40:44.012566 20291 dcd_sock.c:2371 dcd_process_async_ifd_subtree() INFO : IFD_PRESENT flag is set.
May 29 20:40:44.012638 20291 dcd_sock.c:2226 dcd_async_update_speed() INFO : Same speed interface sp-0/0/0 new speed 800000000 old speed 800000000
May 29 20:40:44.012717 20291 dcd_sock.c:2554 dcd_process_async_ifd_subtree() DEBUG :  sp-0/0/0 Updating admin-state to 0
May 29 20:40:44.012783 20291 dcd_sock.c:2727 dcd_process_async_ifd_subtree() INFO : Updating LACP params Kernel DB: LACP port mode: 0x0, Port Muxm state: 0x0, LACP state: 0
....

Because traceoptions output takes up a lot of space, it’s important to temporarily disable or permanently delete it when troubleshooting is complete.

[edit]
rayka@vSRX1# deactivate interfaces traceoptions                                    

[edit]
rayka@vSRX1# show | compare 
[edit interfaces]
!    inactive: traceoptions { ... }

[edit]
rayka@vSRX1# delete interfaces ge-0/0/0 traceoptions    

[edit]
rayka@vSRX1# show | compare 
[edit interfaces]
!    inactive: traceoptions { ... }
[edit interfaces ge-0/0/0]
-    traceoptions {
-        flag all;
-    }

[edit]
rayka@vSRX1# 
Back to: Juniper Junos Associate version 22.1R1.10 (JNCIA-Junos) > Junos Configuration Basics

Leave a Reply

Your email address will not be published. Required fields are marked *


Post comment