Monitoring Logical Systems for Routers and Switches
Logical systems enable you to monitor the operational mode commands for router and switches. For more information, see the following topics:
Example: Running Operational Mode Commands on Logical Systems
This example shows how to set the CLI to a specified logical system view, run operational-mode commands for the logical system, and then return to the main router view.
Requirements
You must have the view privilege for the logical system.
Overview
For some operational-mode commands, you can include a logical-system option to narrow the output of the command or
to limit the operation of the command to the specified logical system.
For example, the show route
command has a logical-system option. To run this command on a logical system called LS3, you
can use show route logical-system LS3
. However, some commands,
such as show interfaces
, do not have a logical-system option. For commands like this, you need another approach.
You can place yourself into the context of a specific logical
system. To configure a logical system context, issue the set
cli logical-system logical-system-name
command.
When the CLI is in logical system context mode and you enter an operational-mode command, the output of the command displays information related to the logical system only.
Configuration
Procedure
Step-by-Step Procedure
The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.
To set the CLI to a specific logical system context:
From the main router, configure the logical system.
[edit] user@host# set logical-systems LS3
If you are done configuring the device, commit the configuration.
[edit] user@host# commit user@host# exit
Set the CLI to view the logical system.
user@host> set cli logical-system LS3 Logical system: LS3 user@host:LS3>
Run an operational-mode command.
user@host:LS3> show interfaces terse Interface Admin Link Proto Local Remote lt-1/2/0 lt-1/2/0.3 up up inet 10.0.2.1/30
Enter configuration mode to edit the logical system configuration.
user@host:LS3> edit Entering configuration mode user@host:LS3#
Exit configuration mode to return to operational mode.
user@host:LS3# exit Exiting configuration mode
Clear the logical system view to return to the main router view.
user@host:LS3> clear cli logical-system Cleared default logical system user@host>
To achieve the same effect when using a Junos XML protocol client application, include the <set-logical-system> tag.
<rpc> <set-logical-system> <logical-system>LS1</logical-system> </set-logical-system> </rpc>
Logical System Logging Overview
The Junos OS generates system log messages (also called syslog messages) to record system events that occur on the device.
Each system log message identifies the Junos OS process that generated the message and briefly describes the operation or error that occurred. This reference provides more detailed information about each system log message, and when applicable, describes possible causes of the message and action you can take to correct error conditions.
When a logical system is created, the system log messages known
as syslog is configured at the [edit system]
hierarchy level. The syslog is written with the same files as the
default logical system with the name of the logical system prepended
to the syslog message.
Each logical system has a directory structure created in the /var/logical-systems/logical-system-name directory. If the traceoptions are configured under the logical system, then the system log messages are saved in the /var/logical-systems/logical-system-name directory.
The syslog do not pass to /var/logical-systems/logical-system-name directory, but the traceoptions pass to the /var/logical-systems/logical-system-name directory.
Example: Viewing BGP Trace Files on Logical Systems
This example shows how to list and view files that are stored on a logical system.
Requirements
You must have the view privilege for the logical system.
Configure a network, such as the BGP network shown in Example: Configuring Internal BGP Peering Sessions on Logical Systems.
Overview
Logical systems have their individual directory structure created in the /var/logical-systems/logical-system-name directory. It contains the following subdirectories:
/config—Contains the active configuration specific to the logical system.
/log—Contains system log and tracing files specific to the logical system.
To maintain backward compatibility for the log files with previous versions of Junos OS, a symbolic link (symlink) from the /var/logs/logical-system-name directory to the /var/logical-systems/logical-system-name directory is created when a logical system is configured.
/tmp—Contains temporary files specific to the logical system.
The file system for each logical system enables logical system users to view trace logs and modify logical system files. Logical system administrators have full access to view and modify all files specific to the logical system.
Logical system users and administrators can save and load configuration files at the logical-system level using the save and load configuration mode commands. In addition, they can also issue the show log, monitor, and file operational mode commands at the logical-system level.
This example shows how to configure and view a BGP trace file on a logical system. The steps can be adapted to apply to trace operations for any Junos OS hierarchy level that supports trace operations.
To view a list of hierarchy levels that support tracing operations, enter the help apropos traceoptions command in configuration mode.
Configuration
- CLI Quick Configuration
- Configuring Trace Operations
- Viewing the Trace File
- Deactivating and Reactivating Trace Logging
- Results
CLI Quick Configuration
To quickly configure this example, copy the following commands, paste them into 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 logical-systems A protocols bgp group internal-peers traceoptions file bgp-log set logical-systems A protocols bgp group internal-peers traceoptions file size 10k set logical-systems A protocols bgp group internal-peers traceoptions file files 2 set logical-systems A protocols bgp group internal-peers traceoptions flag update detail
Configuring Trace Operations
Step-by-Step Procedure
The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.
To configure the trace operations:
Configure trace operations on the logical system.
[edit logical-systems A protocols bgp group internal-peers] user@host# set traceoptions file bgp-log user@host# set traceoptions file size 10k user@host# set traceoptions file files 2 user@host# set traceoptions flag update detail
If you are done configuring the device, commit the configuration.
[edit] user@host# commit
Viewing the Trace File
Step-by-Step Procedure
To view the trace file:
In operational mode on the main router, list the directories on the logical system.
user@host> file list /var/logical-systems/A /var/logical-systems/A: config/ log/ tmp/
In operational mode on the main router, list the log files on the logical system.
user@host> file list /var/logical-systems/A/log/ /var/logical-systems/A/log: bgp-log
View the contents of the bgp-log file.
user@host> file show /var/logical-systems/A/log/bgp-log Aug 10 17:12:01 trace_on: Tracing to "/var/log/A/bgp-log" started Aug 10 17:14:22.826182 bgp_peer_mgmt_clear:5829: NOTIFICATION sent to 192.163.6.4 (Internal AS 17): code 6 (Cease) subcode 4 (Administratively Reset), Reason: Management session cleared BGP neighbor Aug 10 17:14:22.826445 bgp_send: sending 21 bytes to 192.163.6.4 (Internal AS 17) Aug 10 17:14:22.826499 Aug 10 17:14:22.826499 BGP SEND 192.168.6.5+64965 -> 192.163.6.4+179 Aug 10 17:14:22.826559 BGP SEND message type 3 (Notification) length 21 Aug 10 17:14:22.826598 BGP SEND Notification code 6 (Cease) subcode 4 (Administratively Reset) Aug 10 17:14:22.831756 bgp_peer_mgmt_clear:5829: NOTIFICATION sent to 192.168.40.4 (Internal AS 17): code 6 (Cease) subcode 4 (Administratively Reset), Reason: Management session cleared BGP neighbor Aug 10 17:14:22.831851 bgp_send: sending 21 bytes to 192.168.40.4 (Internal AS 17) Aug 10 17:14:22.831901 Aug 10 17:14:22.831901 BGP SEND 192.168.6.5+53889 -> 192.168.40.4+179 Aug 10 17:14:22.831959 BGP SEND message type 3 (Notification) length 21 Aug 10 17:14:22.831999 BGP SEND Notification code 6 (Cease) subcode 4 (Administratively Reset) ...
Filter the output of the log file.
user@host> file show /var/logical-systems/A/log/bgp-log | match "flags 0x40" Aug 10 17:14:54.867460 BGP SEND flags 0x40 code Origin(1): IGP Aug 10 17:14:54.867595 BGP SEND flags 0x40 code ASPath(2) length 0: <null> Aug 10 17:14:54.867650 BGP SEND flags 0x40 code NextHop(3): 192.168.6.5 Aug 10 17:14:54.867692 BGP SEND flags 0x40 code LocalPref(5): 100 Aug 10 17:14:54.884529 BGP RECV flags 0x40 code Origin(1): IGP Aug 10 17:14:54.884581 BGP RECV flags 0x40 code ASPath(2) length 0: <null> Aug 10 17:14:54.884628 BGP RECV flags 0x40 code NextHop(3): 192.163.6.4 Aug 10 17:14:54.884667 BGP RECV flags 0x40 code LocalPref(5): 100 Aug 10 17:14:54.911377 BGP RECV flags 0x40 code Origin(1): IGP Aug 10 17:14:54.911422 BGP RECV flags 0x40 code ASPath(2) length 0: <null> Aug 10 17:14:54.911466 BGP RECV flags 0x40 code NextHop(3): 192.168.40.4 Aug 10 17:14:54.911507 BGP RECV flags 0x40 code LocalPref(5): 100 Aug 10 17:14:54.916008 BGP SEND flags 0x40 code Origin(1): IGP Aug 10 17:14:54.916054 BGP SEND flags 0x40 code ASPath(2) length 0: <null> Aug 10 17:14:54.916100 BGP SEND flags 0x40 code NextHop(3): 192.168.6.5 Aug 10 17:14:54.916143 BGP SEND flags 0x40 code LocalPref(5): 100 Aug 10 17:14:54.920304 BGP RECV flags 0x40 code Origin(1): IGP Aug 10 17:14:54.920348 BGP RECV flags 0x40 code ASPath(2) length 0: <null> Aug 10 17:14:54.920393 BGP RECV flags 0x40 code NextHop(3): 10.0.0.10 Aug 10 17:14:54.920434 BGP RECV flags 0x40 code LocalPref(5): 100
View the tracing operations in real time.
user@host> clear bgp neighbor logical-system A Cleared 2 connections
CAUTION:Clearing the BGP neighbor table is disruptive in a production environment.
Run the monitor start command with an optional match condition.
user@host> monitor start A/bgp-log | match 0.0.0.0/0 Aug 10 19:21:40.773467 BGP RECV 0.0.0.0/0 Aug 10 19:21:40.773685 bgp_rcv_nlri: 0.0.0.0/0 Aug 10 19:21:40.773778 bgp_rcv_nlri: 0.0.0.0/0 belongs to meshgroup Aug 10 19:21:40.773832 bgp_rcv_nlri: 0.0.0.0/0 qualified bnp->ribact 0x0 l2afcb 0x0
Pause the monitor command by pressing Esc-Q. To unpause the output, press Esc-Q again.
Halt the monitor command by pressing Enter and typing monitor stop.
[Enter] user@host> monitor stop
When you are finished troubleshooting, consider deactivating trace logging to avoid any unnecessary impact to system resources.
[edit protocols bgp group internal-peers] user@host:A# deactivate traceoptions user@host:A# commit
When configuration is deactivated, it appears in the configuration with the inactive tag.To reactivate trace operations, use the activate configuration-mode statement.
[edit protocols bgp group internal-peers] user@host:A# show type internal; inactive: traceoptions { file bgp-log size 10k files 2; flag update detail; flag all; } local-address 192.168.6.5; export send-direct; neighbor 192.163.6.4; neighbor 192.168.40.4;
To reactivate trace operations, use the activate configuration-mode statement.
[edit protocols bgp group internal-peers] user@host:A# activate traceoptions user@host:A# commit
Deactivating and Reactivating Trace Logging
Step-by-Step Procedure
To deactivate and reactivate the trace file:
When you are finished troubleshooting, consider deactivating trace logging to avoid an unnecessary impact to system resources.
[edit protocols bgp group internal-peers] user@host:A# deactivate traceoptions user@host:A# commit
When configuration is deactivated, the statement appears in the configuration with the inactive tag.
[edit protocols bgp group internal-peers] user@host:A# show type internal; inactive: traceoptions { file bgp-log size 10k files 2; flag update detail; flag all; } local-address 192.168.6.5; export send-direct; neighbor 192.163.6.4; neighbor 192.168.40.4;
To reactivate logging, use the activate configuration-mode statement.
[edit protocols bgp group internal-peers] user@host:A# activate traceoptions user@host:A# commit
Results
From configuration mode, confirm your configuration by entering the show logical-systems A protocols bgp group internal-peers command. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.
user@host# show logical-systems A protocols bgp group internal-peers traceoptions { file bgp-log size 10k files 2; flag update detail; }