Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Using Operational Commands to Monitor a Device

 

Operational mode CLI commands enable you to monitor and control the operation of a device running the Junos OS. The operational mode commands exist in a hierarchical structure. For more information, see the following topics:

Examples: Using the Junos OS CLI Command Completion

The following examples show how you can use the command completion feature in Junos OS. Issue the show interfaces command:

user@host> sh<Space>ow i<Space>
user@host> show in<Space>terfaces
user@host>

Display a list of all log files whose names start with the string “messages,” and then display the contents of one of the files:

user@myhost> show log mes?
user@myhost> show log mes<Tab>sages.4<Tab>.gz<Enter>

Controlling the Scope of an Operational Mode Command

The Junos OS CLI operational commands include options that you can use to identify specific components on a device running Junos OS. For example:

  1. Type the show interfaces command to display information about all interfaces on the router.

  2. To display information about a specific interface, type that interface as a command option:

Operational Mode Commands on a TX Matrix Router or TX Matrix Plus Router

When you issue operational mode commands on the TX Matrix router, CLI command options allow you to restrict the command output to show only a component of the routing matrix rather than the routing matrix as a whole.

These are the options shown in the CLI:

  • scc—The TX Matrix router (or switch-card chassis)

  • sfc—The TX Matrix Plus router (also referred to as or switch-fabric chassis)

  • lcc number—A specific router in a routing matrix based on a TX Matrix router or a TX Matrix Plus router.

  • all-lcc—All T640 routers (in a routing matrix based on a TX Matrix router) or all T1600 routers or T4000 routers (in a routing matrix based on a TX Matrix Plus router).

If you specify none of these options, then the command applies by default to the whole routing matrix.

Examples of Routing Matrix Command Options

The following output samples, using the show version command, demonstrate some different options for viewing information about the routing matrix.

user@host> show version ?

Sample Output: No Routing Matrix Options Specified

user@host> show version

Sample Output: TX Matrix Router Only (scc Option)

user@host> show version scc

Sample Output: Specific T640 Router (lcc number Option)

user@host> show version lcc 0

Sample Output: All T640 Routers (all-lcc Option)

user@host> show version all-lcc

Monitoring Who Uses the Junos OS CLI

Depending upon how you configure Junos OS, multiple users can log in to the router, use the CLI, and configure or modify the software configuration.

If, when you enter configuration mode, another user is also in configuration mode, a notification message is displayed that indicates who the user is and what portion of the configuration the person is viewing or editing:

Viewing Files and Directories on a Device Running Junos OS

Junos OS stores information in files on the device, including configuration files, log files, and router software files. This topic shows some examples of operational commands that you can use to view files and directories on a device running Junos OS.

Sections include:

Directories on the Router or Switch

Table 1 lists some standard directories on a device running Junos OS.

Table 1: Directories on the Router

DIrectory

Description

/config

This directory is located on the device’s router’s internal flash drive. It contains the active configuration (juniper.conf) and rollback files 1, 2, and 3.

/var/db/config

This directory is located on the router’sdevice’s hard drive and contains rollback files 4 through 49.

/var/tmp

This directory is located on thedevice’s hard drive. It holds core files from the various processes on the Routing Engines. Core files are generated when a particular process crashes and are used by Juniper Networks engineers to diagnose the reason for failure.

/var/log

This directory is located on the device’s hard drive. It contains files generated by both the device’s logging function as well as the traceoptions command.

/var/home

This directory is located on the device’s hard drive. It contains a subdirectory for each configured user on the device. These individual user directories are the default file location for many Junos OS commands.

/altroot

This directory is located on the device’s hard drive and contains a copy of the root file structure from the internal flash drive. This directory is used in certain disaster recovery modes where the internal flash drive is not operational.

/altconfig

This directory is located on the device’s hard drive and contains a copy of the /config file structure from the internal flash drive. This directory is also used in certain disaster recovery modes when the internal flash drive is not operational.

Listing Files and Directories

You can view the device’s directory structure as well as individual files by issuing the file command in operational mode.

  1. To get help about the file command, type the following:

    Help shows that the file command includes several options for manipulating files.

  2. Use the list option to see the directory structure of the device. For example, to show the files located in your home directory on the device:

    The default directory for the file list command is the home directory of the user logged in to the device. In fact, the user’s home directory is the default directory for most of Junos OS commands requiring a filename.

  3. To view the contents of other file directories, specify the directory location. For example:

  4. You can also use the device’s context-sensitive help system to locate a directory. For example:

  5. You can also display the contents of a file. For example:

Specifying Filenames and URLs

In some CLI commands and configuration statements—including file copy, file archive, load, save, set system login user username authentication load-key-file, and request system software add—you can include a filename. On a routing matrix, you can include chassis information as part of the filename (for example, lcc0, lcc0-re0, or lcc0-re1).

You can specify a filename or URL in one of the following ways:

  • filename—File in the user’s current directory on the local flash drive. You can use wildcards to specify multiple source files or a single destination file. Wildcards are not supported in Hypertext Transfer Protocol (HTTP) or FTP.

    Note

    Wildcards are supported only by the file (compare | copy | delete | list | rename | show) commands. When you issue the file show command with a wildcard, it must resolve to one filename.

  • path/filename—File on the local flash disk.

  • /var/filename or /var/path/filename—File on the local hard disk. You can also specify a file on a local Routing Engine for a specific T640 router on a routing matrix:

    user@host> file delete lcc0-re0:/var/tmp/junk
  • a:filename or a:path/filename—File on the local drive. The default path is / (the root-level directory). The removable media can be in MS-DOS or UNIX (UFS) format.

  • hostname:/path/filename, hostname:filename, hostname:path/filename, or scp://hostname/path/filename—File on an scp/ssh client. This form is not available in the worldwide version of Junos OS. The default path is the user’s home directory on the remote system. You can also specify hostname as username@hostname.

  • ftp://hostname/path/filename—File on an FTP server. You can also specify hostname as username@hostname or username:password@hostname. The default path is the user’s home directory. To specify an absolute path, the path must start with %2F; for example, ftp://hostname/%2Fpath/filename. To have the system prompt you for the password, specify prompt in place of the password. If a password is required, and you do not specify the password or prompt, an error message is displayed:

    user@host> file copy ftp://username@ftp.hostname.net//filename
    user@host> file copy ftp://username:prompt@ftp.hostname.net//filename
  • http://hostname/path/filename—File on an HTTP server. You can also specify hostname as username@hostname or username:password@hostname. If a password is required and you omit it, you are prompted for it.

  • re0:/path/filename or re1:/path/filename—File on a local Routing Engine. You can also specify a file on a local Routing Engine for a specific T640 router on a routing matrix:

    user@host> show log lcc0-re1:chassisd

Displaying Junos OS Information

You can display Junos OS version information and other status to determine if the version of Junos OS that you are running supports particular features or hardware.

To display Junos OS information:

  1. Make sure you are in operational mode.

  2. To display brief information and status for the kernel and Packet Forwarding Engine, enter the show version brief command. This command shows version information for Junos OS packages installed on the router. For example:

    If the Junos Crypto Software Suite is listed, the router has Canada and USA encrypted Junos OS. If the Junos Crypto Software Suite is not listed, the router is running worldwide nonencrypted Junos OS.

  3. To display detailed version information, enter the show version detail command. This command display shows the hostname and version information for Junos OS packages installed on your router. It also includes the version information for each software process. For example:

    user@host> show version detail

Managing Programs and Processes Using Junos OS Operational Mode Commands

This topic shows some examples of Junos operational commands that you can use to manage programs and processes on a device running Junos OS.

Sections include:

Showing Software Processes

To verify system operation or to begin diagnosing an error condition, you may need to display information about software processes running on the device.

To show software processes:

  1. Make sure you are in operational mode.

  2. Type the show system processes extensive command. This command shows the CPU utilization on the device and lists the processes in order of CPU utilization. For example:

    user@host> show system processes extensive

Table 2 lists and describes the output fields included in this example. The fields are listed in alphabetical order.

Table 2: show system process extensive Command Output Fields

Field

Description

COMMAND

Command that is running.

CPU

Raw (unweighted) CPU usage. The value of this field is used to sort the processes in the output.

last pid

Last process identifier assigned to the process.

load averages

Three load averages, followed by the current time.

Mem

Information about physical and virtual memory allocation.

NICE

UNIX “nice” value. The nice value allows a process to change its final scheduling priority.

PID

Process identifier.

PRI

Current kernel scheduling priority of the process. A lower number indicates a higher priority.

processes

Number of existing processes and the number of processes in each state (sleeping, running, starting, zombies, and stopped).

RES

Current amount of resident memory, in KB.

SIZE

Total size of the process (text, data, and stack), in KB.

STATE

Current state of the process (sleep, wait, run, idle, zombi, or stop).

Swap

Information about physical and virtual memory allocation.

USERNAME

Owner of the process.

WCPU

Weighted CPU usage.

Restarting the Junos OS Process

To correct an error condition, you might need to restart a software process running on the device. You can use the restart command to force a restart of a software process.

Caution

Do not restart a software process unless specifically asked to do so by your Juniper Networks customer support representative. Restarting a software process during normal operation of a device could cause interruption of packet forwarding and loss of data.

To restart a software process:

  1. Make sure you are in operational mode.

  2. Type the following command:

    • process-name is the name of the process that you want to restart. For example, routing or class-of-service. You can use the command completion feature of Junos OS to see a list of software processes that you can restart using this command.

    • gracefully restarts the software process after performing clean-up tasks.

    • immediately restarts the software process without performing any clean-up tasks.

    • soft rereads and reactivates the configuration without completely restarting the software processes. For example, BGP peers stay up and the routing table stays constant.

The following example shows how to restart the routing process:

When a process restarts, the process identifer (PID) is updated. (See Figure 1.)

Figure 1: Restarting a Process
Restarting a Process

Stopping Junos OS

To avoid damage to the file system and to prevent loss of data, you must always gracefully shut down Junos OS before powering off the device.

Note

SRX Series Services Gateway devices for the branch and EX Series Ethernet Switches support resilient dual-root partitioning.

If you are unable to shut down a device gracefully because of unexpected circumstances such as a power outage or a device failure, resilient dual-root partitioning prevents file corruption and enables a device to remain operational. In addition, it enables a device to boot transparently from the second root partition if the system fails to boot from the primary root partition.

Resilient dual-root partitioning serves as a backup mechanism for providing additional resiliency to a device when there is an abnormal shutdown. However, it is not an alternative to performing a graceful shutdown under normal circumstances.

To stop Junos OS:

  1. Make sure you are in operational mode.

  2. Enter the request system halt command. This command stops all system processes and halts the operating system. For example:

    user@host> request system halt

Rebooting Junos OS

After a software upgrade or to recover (occasionally) from an error condition, you must reboot Junos OS.

To reboot Junos OS:

  1. Make sure you are in operational mode.

  2. Enter the request system reboot command. This command displays the final stages of the system shutdown and executes the reboot. Reboot requests are recorded to the system log files, which you can view with the show log messages command. For example:

    user@host>request system rebootReboot the system? [yes,no] (no)yes

Using the Junos OS CLI Comment Character # for Operational Mode Commands

The comment character in Junos OS enables you to copy operational mode commands that include comments from a file and paste them into the CLI. A pound sign (#) at the beginning of the command-line indicates a comment line. This is useful for describing frequently used operational mode commands; for example, a user’s work instructions on how to monitor the network. To add a comment to a command file, the first character of the line must be #. When you start a command with #, the rest of the line is disregarded by Junos OS.

To add comments in operational mode, start with a # and end with a new line (carriage return):

comment-string is the text of the comment. The comment text can be any length, but each comment line must begin with a #.

Example: Using Comments in Junos OS Operational Mode Commands

The following example shows how to use comments in a file:

The following example shows how to copy and paste contents of a file into the CLI:

Displaying the Junos OS CLI Command and Word History

To display a list of recent commands that you issued, use the show cli history command:

You can press Esc+. (period) or Alt+. (period) to insert the last word of the previous command. Repeat Esc+. or Alt+. to scroll backwards through the list of recently entered words. For example:

user@host> show interfaces terse fe-0/0/0
user@host> <Esc>
user@host> fe-0/0/0

If you scroll completely to the beginning of the list, pressing Esc+. or Alt+. again restarts scrolling from the last word entered.