Support Support Downloads Knowledge Base Case Manager My Juniper Community

Knowledge Base

Search our Knowledge Base sites to find answers to your questions.

Ask All Knowledge Base Sites All Knowledge Base Sites JunosE Defect (KA)Knowledge BaseSecurity AdvisoriesTechnical BulletinsTechnotes Sign in to display secure content and recently viewed articles

How to use the “top” shell command and its options to monitor CPU utilization over time.

0

0

Article ID: KB17556 KB Last Updated: 23 Jun 2010Version: 1.0
Summary:
The "top" commmand from shell can be used for troubleshooting or monitoring to check CPU utilization over time.
Symptoms:
The purpose of this command is to monitor processes over time for troubleshooting.
Solution:
The “top” command can be used from the EX Switch shell to get interesting information about CPU load over time, or other processes.

The command is equivalent to the Junos CLI command “show system processes extensive”.

Examples:

The line below uses the following options:

          -n = non-interactive -> the top outputs are rolled in the terminal screen
          -s = delay between the samples
          -d = number of samples

root@Carlos-VC:RE:1% top -n -s 3 -d 2
last pid: 10857; load averages: 0.01, 0.03, 0.03 up 3+23:51:24 14:05:30
45 processes: 1 running, 44 sleeping

Mem: 174M Active, 19M Inact, 94M Wired, 6920K Cache, 110M Buf, 690M Free
Swap:


PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
8828 root 1 8 0 81540K 22548K nanslp 53:55 1.03% pfem
818 root 2 44 -52 63308K 5796K select 32:03 0.15% sfid
817 root 1 4 0 14948K 5412K kqread 89:30 0.00% chassism
819 root 1 4 -20 8496K 4028K kqread 11:07 0.00% vccpd
8934 root 1 96 0 20020K 10544K select 1:02 0.00% chassisd
826 root 1 96 0 4592K 1944K select 1:01 0.00% alarmd
10066 root 1 96 0 8060K 3592K select 0:53 0.00% jdiameterd
10061 root 1 4 0 32216K 11124K kqread 0:26 0.00% rpd
838 root 1 96 0 2892K 932K select 0:20 0.00% license-check
8946 root 1 96 0 5728K 2880K select 0:19 0.00% ppmd
10075 root 1 96 0 17520K 12884K select 0:16 0.00% snmpd
10067 root 1 4 0 8876K 4616K kqread 0:14 0.00% eswd
10072 root 1 96 0 21812K 6100K select 0:11 0.00% dcd
10069 root 1 4 0 5300K 2860K kqread 0:06 0.00% mcsnoopd
827 root 1 96 0 6484K 1984K select 0:06 0.00% craftd
10068 root 1 4 0 5348K 2432K kqread 0:06 0.00% sflowd
8947 root 1 96 0 7296K 3228K select 0:05 0.00% bfdd
10060 root 1 96 0 2448K 1524K select 0:05 0.00% ntpd

last pid: 10857; load averages: 0.01, 0.03, 0.03 up 3+23:51:27 14:05:33
45 processes: 1 running, 44 sleeping
CPU states: 3.1% user, 0.0% nice, 0.9% system, 0.2% interrupt, 95.8% idle
Mem: 174M Active, 19M Inact, 94M Wired, 6920K Cache, 110M Buf, 690M Free
Swap:

PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
8828 root 1 8 0 81540K 22548K nanslp 53:55 0.93% pfem
817 root 1 4 0 14948K 5412K kqread 89:30 0.00% chassism
818 root 2 44 -52 63308K 5796K select 32:03 0.00% sfid
819 root 1 4 -20 8496K 4028K kqread 11:07 0.00% vccpd
8934 root 1 96 0 20020K 10544K select 1:02 0.00% chassisd
826 root 1 96 0 4592K 1944K select 1:01 0.00% alarmd
10066 root 1 96 0 8060K 3592K select 0:53 0.00% jdiameterd
10061 root 1 4 0 32216K 11124K kqread 0:26 0.00% rpd
838 root 1 96 0 2892K 932K select 0:20 0.00% license-check
8946 root 1 96 0 5728K 2880K select 0:19 0.00% ppmd
10075 root 1 96 0 17520K 12884K select 0:16 0.00% snmpd
10067 root 1 4 0 8876K 4616K kqread 0:14 0.00% eswd
10072 root 1 96 0 21812K 6100K select 0:11 0.00% dcd
10069 root 1 4 0 5300K 2860K kqread 0:06 0.00% mcsnoopd
827 root 1 96 0 6484K 1984K select 0:06 0.00% craftd
10068 root 1 4 0 5348K 2432K kqread 0:06 0.00% sflowd
8947 root 1 96 0 7296K 3228K select 0:05 0.00% bfdd
10060 root 1 96 0 2448K 1524K select 0:05 0.00% ntpd


The output above can be filtered out to give more meaningful information.

For example all the processes that had non-zero WCPU over time (egrep –v):

root@Carlos-VC:RE:1% top -n -s 1 -d 100 | egrep "root|PID" | egrep -v " 0.00%"
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
8828 root 1 8 0 81540K 22548K nanslp 54:11 0.93% pfem
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
8828 root 1 96 0 81540K 22548K RUN 54:11 1.03% pfem
10863 root 1 96 0 22888K 1516K RUN 0:00 1.00% top
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
8828 root 1 8 0 81540K 22548K nanslp 54:11 0.93% pfem
817 root 1 4 0 14948K 5412K kqread 89:37 0.05% chassism
826 root 1 96 0 4592K 1944K select 1:01 0.05% alarmd
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
8828 root 1 8 0 81540K 22548K nanslp 54:11 1.07% pfem


If time recording is desirable the "egrep" can be changed to include that line. The output can be redirected to file for later analysis:

root@Carlos-VC:RE:1% top -n -s 2 -d 100 | egrep "root|PID|last pid" | egrep -v " 0.00%" > top.txt

root@Carlos-VC:RE:1%cat top.txt
last pid: 10879; load averages: 0.00, 0.01, 0.00 up 4+00:03:59 14:18:05
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
8828 root 1 8 0 81540K 22548K nanslp 54:25 0.93% pfem
last pid: 10879; load averages: 0.00, 0.01, 0.00 up 4+00:04:01 14:18:07
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
8828 root 1 99 0 81540K 22548K RUN 54:25 0.93% pfem
last pid: 10879; load averages: 0.00, 0.01, 0.00 up 4+00:04:03 14:18:09
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
8828 root 1 8 0 81540K 22548K nanslp 54:25 0.93% pfem
last pid: 10879; load averages: 0.00, 0.01, 0.00 up 4+00:04:05 14:18:11
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
8828 root 1 8 0 81540K 22548K nanslp 54:25 0.93% pfem
last pid: 10879; load averages: 0.00, 0.01, 0.00 up 4+00:04:07 14:18:13
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
8828 root 1 8 0 81540K 22548K nanslp 54:25 0.98% pfem
last pid: 10879; load averages: 0.00, 0.01, 0.00 up 4+00:04:09 14:18:15
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
8828 root 1 8 0 81540K 22548K nanslp 54:25 0.98% pfem
818 root 2 44 -52 63308K 5796K select 32:08 0.05% sfid

Comment on this article > Affected Products Browse the Knowledge Base for more articles related to these product categories. Select a category to begin.

Getting Up and Running with Junos

Getting Up and Running with Junos Security Alerts and Vulnerabilities Product Alerts and Software Release Notices Problem Report (PR) Search Tool EOL Notices and Bulletins JTAC User Guide Customer Care User Guide Pathfinder SRX High Availability Configurator SRX VPN Configurator Training Courses and Videos End User Licence Agreement Global Search