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.
user@host>sh<Space>ow i<Space>
'i' is ambiguous. Possible completions: igmp Show information about IGMP interface Show interface information isis Show information about IS-IS user@host>show in<Space>
terfaces Physical interface: at-0/1/0, Enabled, Physical link is Up Interface index: 11, SNMP ifIndex: 65 Link-level type: ATM-PVC, MTU: 4482, Clocking: Internal, SONET mode Speed: OC12, Loopback: None, Payload scrambler: Enabled Device flags: Present Running Link flags: 0x01 ... user@host>
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.
user@myhost>show log mes?
Possible completions: <filename>Log file to display messagesSize: 1417052, Last changed: Mar 3 00:33 messages.0.gzSize: 145575, Last changed: Mar 3 00:00 messages.1.gzSize: 134253, Last changed: Mar 2 23:00 messages.10.gzSize: 137022, Last changed: Mar 2 14:00 messages.2.grSize: 137112, Last changed: Mar 2 22:00 messages.3.gzSize: 121633, Last changed: Mar 2 21:00 messages.4.gzSize: 135715, Last changed: Mar 2 20:00 messages.5.gzSize: 137504, Last changed: Mar 2 19:00 messages.6.gzSize: 134591, Last changed: Mar 2 18:00 messages.7.gzSize: 132670, Last changed: Mar 2 17:00 messages.8.gzSize: 136596, Last changed: Mar 2 16:00 messages.9.gzSize: 136210, Last changed: Mar 2 15:00 user@myhost> show logmes<Tab>sages.4<Tab>.gz<Enter>
Jan 15 21:00:00 myhost newsyslog[1381]: logfile turned over ...
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.
-
Type the
show interfaces
command to display information about all interfaces on the router.user@host>
show interfaces
Physical interface: so-0/0/0, Enabled, Physical link is Up Interface index: 128, SNMP ifIndex: 23 Link-level type: PPP, MTU: 4474, Clocking: Internal, SONET mode, Speed: OC3, Loopback: None, FCS: 16, Payload scrambler: Enabled Device flags : Present Running Interface flags: Point-To-Point SNMP-Traps Internal: 0x4000 Link flags : Keepalives Keepalive settings: Interval 10 seconds, Up-count 1, Down-count 3 Keepalive: Input: 13861 (00:00:05 ago), Output: 13891 (00:00:01 ago) LCP state: Opened NCP state: inet: Opened, inet6: Not-configured, iso: Opened, mpls: Not-configured CHAP state: Closed PAP state: Closed CoS queues : 4 supported, 4 maximum usable queues Last flapped : 2008-06-02 17:16:14 PDT (1d 14:21 ago) Input rate : 40 bps (0 pps) Output rate : 48 bps (0 pps) ---(more)---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. -
To display information about a specific interface, type that interface as a command option:
user@host>
show interfaces fe-0/1/3
Physical interface: fe-0/1/3, Enabled, Physical link is Up Interface index: 135, SNMP ifIndex: 30 Link-level type: Ethernet, MTU: 1514, Speed: 100mbps, MAC-REWRITE Error: None, Loopback: Disabled, Source filtering: Disabled, Flow control: Enabled Device flags : Present Running Interface flags: SNMP-Traps Internal: 0x4000 Link flags : None CoS queues : 4 supported, 4 maximum usable queues Current address: 00:05:85:8f:c8:22, Hardware address: 00:05:85:8f:c8:22 Last flapped : 2008-06-02 17:16:15 PDT (1d 14:28 ago) Input rate : 0 bps (0 pps) Output rate : 0 bps (0 pps) Active alarms : None Active defects : None user@host>
Routing Matrix Command Options
The show version
command offers several options for viewing information
about the routing matrix.
user@host> show version ?
Possible completions:
<[Enter]> Execute this command
all-lcc Show software version on all LCC chassis
brief Display brief output
detail Display detailed output
lcc Show software version on specific LCC (0..3)
scc Show software version on the SCC
| Pipe through a command
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.
DIrectory |
Description |
---|---|
|
This directory is located on the device’s internal flash drive. It contains the active
configuration ( |
|
This directory is located on the device’s hard drive and contains rollback files 4 through 49. |
|
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. |
|
This directory is located on the device’s hard drive. It
contains files generated by both the device’s logging function and the
|
|
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. |
|
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. |
|
This directory is located on the device’s hard
drive and contains a copy of the |
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.
To get help about the
file
command, enterfile ?
:user@host>
file ?
Possible completions: <[Enter]> Execute this command archive Archives files from the system change-owner Change owner of file change-permission Change permission of file checksum Calculate file checksum compress Compress file copy Copy files (local or remote) delete Delete files from the system delete-directory Delete a directory link Create link between files list List file information make-directory Create a new make-directory Create a new user@host> fileHelp shows that the
file
command includes several options for manipulating files.-
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:user@host>
file list
.ssh/ commonThe 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. To view the contents of other file directories, specify the directory location. For example:
user@host>
file list /config
juniper.conf juniper.conf.1.gz juniper.conf.2.gz juniper.conf.3.gzYou can also use the device’s context-sensitive help system to locate a directory. For example:
user@host>
file list /?
Possible completions: <[Enter]> Execute this command <path> Path to list /COPYRIGHT Size: 6355, Last changed: Feb 13 2017 /altconfig/ Last changed: Aug 07 2017 /altroot/ Last changed: Aug 07 2017 /bin/ Last changed: Apr 09 22:31:35 /boot/ Last changed: Apr 09 23:28:39 /config/ Last changed: Apr 16 22:35:35 /data/ Last changed: Aug 07 2017 /dev/ Last changed: Apr 09 22:36:21 /etc/ Last changed: Apr 11 03:14:22 /kernel Size: 27823246, Last changed: Aug 07 2017 /mfs/ Last changed: Apr 09 22:36:49 /mnt/ Last changed: Jan 11 2017 /modules/ Last changed: Apr 09 22:33:54 /opt/ Last changed: Apr 09 22:31:00 /packages/ Last changed: Apr 09 22:34:38 /proc/ Last changed: May 07 20:25:46 /rdm.taf Size: 498, Last changed: Apr 09 22:37:31 /root/ Last changed: Apr 10 02:19:45 /sbin/ Last changed: Apr 09 22:33:55 /staging/ Last changed: Apr 09 23:28:41 /tmp/ Last changed: Apr 11 03:14:49 /usr/ Last changed: Apr 09 22:31:34 /var/ Last changed: Apr 09 22:37:30 user@host> file list /var/?
<[Enter]> Execute this command <path> Path to list /var/account/ Last changed: Jul 09 2017 /var/at/ Last changed: Jul 09 2017 /var/backups/ Last changed: Jul 09 2017 /var/bin/ Last changed: Jul 09 2017 /var/crash/ Last changed: Apr 09 22:31:08 /var/cron/ Last changed: Jul 09 2017 /var/db/ Last changed: May 07 20:28:40 /var/empty/ Last changed: Jul 09 2017 /var/etc/ Last changed: Apr 16 22:35:36 /var/heimdal/ Last changed: Jul 10 2017 /var/home/ Last changed: Apr 09 22:59:18 /var/jail/ Last changed: Oct 31 2017 /var/log/ Last changed: Apr 17 02:00:10 /var/mail/ Last changed: Jul 09 2017 /var/msgs/ Last changed: Jul 09 2017 /var/named/ Last changed: Jul 10 2017 /var/packages/ Last changed: Jan 18 02:38:59 /var/pdb/ Last changed: Oct 31 2017 /var/preserve/ Last changed: Jul 09 2017 /var/run/ Last changed: Apr 17 02:00:01 /var/rundb/ Last changed: Apr 17 00:46:00 /var/rwho/ Last changed: Jul 09 2017 /var/sdb/ Last changed: Apr 09 22:37:31 /var/spool/ Last changed: Jul 09 2017 /var/sw/ Last changed: Jul 09 2017 /var/tmp/ Last changed: Apr 09 23:28:41 /var/transfer/ Last changed: Jul 09 2017 /var/yp/ Last changed: Jul 09 2017 user@host> file list /var/You can also display the contents of a file. For example:
user@host>
file show /var/log/inventory
Jul 9 23:17:46 CHASSISD release 8.4I0 built by builder on 2017-06-12 07:58:27 UTC Jul 9 23:18:05 CHASSISD release 8.4I0 built by builder on 2017-06-12 07:58:27 UTC Jul 9 23:18:06 Routing Engine 0 - part number 740-003239, serial number 9000016755 Jul 9 23:18:15 Routing Engine 1 - part number 740-003239, serial number 9001018324 Jul 9 23:19:03 SSB 0 - part number 710-001951, serial number AZ8025 Jul 9 23:19:03 SSRAM bank 0 - part number 710-001385, serial number 243071 Jul 9 23:19:03 SSRAM bank 1 - part number 710-001385, serial number 410608 ...
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 thefile 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:
user@host>
file delete lcc0-re0:/var/tmp/junk
-
a:
filename
ora:
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,
orscp://
hostname
/
path
/
filename
—File on anscp/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 specifyhostname
asusername
@
hostname
. -
ftp://
hostname
/
path
/
filename
—File on an FTP server. You can also specifyhostname
asusername
@
hostname
orusername
: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
/%2F
path
/
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 orprompt
, an error message is displayed:user@host>
file copy ftp://username@ftp.hostname.net//filename
file copy ftp.hostname.net: Not logged in. user@host>file copy ftp://username:prompt@ftp.hostname.net//filename
Password for username@ftp.hostname.net: -
http:
//hostname
/path
/filename
—File on an HTTP server. You can also specifyhostname
asusername
@
hostname
orusername:
password
@
hostname
. If a password is required and you omit it, you are prompted for it. -
re0
:/
path
/
filename
orre1
:/
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
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:
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:
-
Make sure you are in operational mode.
-
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.
Field |
Description |
---|---|
|
Command that is running. |
|
Last process identifier assigned to the process. |
|
Three load averages, followed by the current time. |
|
Information about physical and virtual memory allocation. |
|
UNIX “nice” value. The nice value allows a process to change its final scheduling priority. |
|
Process identifier. |
|
Current kernel scheduling priority of the process. A lower number indicates a higher priority. |
|
Number of existing processes and the number of processes in
each state ( |
|
Current amount of resident memory, in KB. |
|
Total size of the process ( |
|
Current state of the process ( |
|
Information about physical and virtual memory allocation. |
|
Owner of the process. |
|
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.
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:
-
Make sure you are in operational mode.
-
Enter the following command:
user@host>
restart
process-name < (immediately | gracefully | soft) >
-
process-name
is the name of the process that you want to restart. For example,routing
orclass-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.
-
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:
user@host> restart routing
Routing protocol daemon started, pid 751
When a process restarts, the process identifier (PID) is updated.
Stop the Software
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:
-
Make sure you are in operational mode.
-
Enter the
request system halt
command. This command stops all system processes and halts the operating system. For example:user@host>
request system halt
Halt the system? [yes,no] (no) yes shutdown: [pid 3110] Shutdown NOW! *** FINAL System shutdown message from root@host *** System going down IMMEDIATELY user@host> Dec 17 17:28:40 init: syslogd (PID 2514) exited with status=0 Normal Exit Waiting (max 60 seconds) for system process `bufdaemon' to stop...stopped Waiting (max 60 seconds) for system process `syncer' to stop...stopped syncing disks... 4 done Uptime: 3h31m41s ata0: resetting devices.. done The operating system has halted. Please press any key to reboot.
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:
-
Make sure you are in operational mode.
-
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 theshow log messages
command. For example:user@host>
request system reboot
Reboot the system? [yes,no] (no)yes
shutdown: [pid 845] Shutdown NOW! *** FINAL System shutdown message from root@host *** System going down IMMEDIATELY user@host> Dec 17 17:34:20 init: syslogd (PID 409) exited with status=0 Normal Exit Waiting (max 60 seconds) for system process `bufdaemon' to stop...stopped Waiting (max 60 seconds) for system process `syncer' to stop...stopped syncing disks... 10 6 done Uptime: 2m45s ata0: resetting devices.. done Rebooting...
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.
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):
user@host> #comment-string
comment-string
is the text of the comment. The comment text can be any length, but
each comment line must begin with a #.