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 Juniper Networks device. The operational mode commands exist in a hierarchical structure.

CLI Command Completion Example

The command completion feature can help make it easier both to enter commands or to learn what possible completion options are available at any given time.

This example shows the result of issuing the show interfaces command. In this case, the spacebar is used to autocomplete the command.

This example shows how to display a list of all log files whose names start with the string “messages,” and then display the contents of one of the files. Here, the Tab key is used to perform the autocompletion.

Operational Mode Commands: Overview of Controlling the Scope

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

  • You use the show interfaces command to display information about all interfaces on the router.

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

    Note:

    This example output shows only one interface, for the sake of brevity, but in reality, the interfaces information for all four would be shown after the —(more)— prompts.

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

Routing Matrix Command Options

The show version command offers several options for viewing information about the routing matrix.

Viewing Files and Directories on a Device

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

Directories on the Device

The following table lists some standard directories on a Juniper Networks device.

Table 1: Directories on the Device

DIrectory

Description

/config

This directory is located on the device’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 device’s hard drive and contains rollback files 4 through 49.

/var/tmp

This directory is located on the device’s hard drive. It holds core files from the various processes on the Routing Engines. Core files are generated when a particular process crashes. Juniper Networks engineers use these core files to diagnose the cause of the failure.

/var/log

This directory is located on the device’s hard drive. It contains files generated by both the device’s logging function and 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 software 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.

List 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, enter file ?:

    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 the 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:

Filenames and URLs

You can include a filename in CLI commands and configuration statements such as these:

  • file copy
  • file archive,
  • load,
  • save
  • set system login user
  • username
  • authentication
  • load-key-file
  • request system software add

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. Neither HTTP nor FTP supports wildcards.

    Note:

    Only the file (compare | copy | delete | list | rename | show) commands support wildcards. When you issue the file show command with a wildcard, the command 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:

  • 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 the operating system. 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:

  • 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:

Display Operating System Information

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

To display this 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 software packages installed on the router.

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

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

Managing Programs and Processes Using Operational Mode Commands

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

Show 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. Enter the show system processes extensive command. This command shows the CPU utilization on the device and lists the processes in order of CPU utilization.

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

Table 2: The show system process extensive Command Output Fields

Field

Description

COMMAND

Command that is running.

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.

Restart the Software 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 can interrupt packet forwarding and cause data loss.

To restart a software process:

  1. Make sure you are in operational mode.

  2. Enter 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 the system to see a list of software processes that you can restart using this command.

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

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

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

Note:

The gracefully, immediately, and soft options for the restart command are optional and not required for executing the command.

The following example shows how to restart the routing process:

When a process restarts, the process identifier (PID) is updated.

Figure 1: Restarting a ProcessRestarting a Process

Stop the Software

CAUTION:

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

You must stop the software on a device through a direct console connection, not through the network. As the software shuts down, the network will go down, and if you were connected that way, you will not see the results output.

To stop the software:

  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:

Reboot the Software

After a software upgrade or to recover (occasionally) from an error condition, you must reboot the software. As with the shutdown command, you must reboot through a direct console connection otherwise you will not see the command output when the network goes down during the reboot process.

To reboot the software:

  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:

CLI Comment Character # for Operational Mode Commands

The comment character enables you to copy operational mode commands that include comments from a file and paste them into the CLI. A pound or hash symbol (#) at the beginning of the command line indicates a comment line. This command is useful for describing frequently used operational mode commands, such as a user’s work instructions on how to monitor the network. To add a comment to a command file, you must place # as the first character of the line. When you start a command with #, the operating system disregards the rest of the line.

Note:

The device configuration does not save the comments you enter in the CLI, whether individually or by pasting in the contents of a configuration file. Comments entered at the CLI are ignored.

To add comments in operational mode, you 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 #.