[Linux] Dynamic monitoring process: top

Dynamic monitoring process

introduce

top is very similar to the ps command. They are all used to show the process being executed. The biggest difference between top and ps is that top can update running processes during execution for a period of time.

grammar

top [选项]: Displays information about the process currently being executed by the system, including process ID, memory usage, CPU usage, etc.

Options

Options Function
-b batch processing
-c show complete command
-I Ignore dead processes
-S Privacy Mode
-S Cumulative mode
-i<时间> set interval time
-u<用户名> specify username
-p<进程号> specified process
-n<次数> Number of times the signal is displayed
example
  • Display process information
top - 16:39:09 up 5 days,  2:58,  1 user,  load average: 0.00, 0.01, 0.05
Tasks: 121 total,   1 running, 120 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.1 us,  0.0 sy,  0.0 ni, 99.8 id,  0.2 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  7908716 total,  2271720 free,   422856 used,  5214140 buff/cache
KiB Swap:  8388604 total,  8388604 free,        0 used.  7051856 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                     
  710 root      20   0   21476   1216    976 S   0.3  0.0   0:45.37 irqbalance                   
    1 root      20   0  190996   3980   2544 S   0.0  0.1   1:34.99 systemd                    
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.11 kthreadd                     
    3 root      20   0       0      0      0 S   0.0  0.0   0:00.66 ksoftirqd/0                 
    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H                 
    //... ...省略部分显示内容

The first five lines are the overall statistical information area of ​​the current system situation.

The first line: task queue information

Second line: Tasks — tasks (processes)

The third line: the state of the CPU
Fourth line: memory status

Line 5: \swap swap partition information

View system network netstat (important)

netstat:[ Detailed explanation of Linux netstat command ]

Command name: netstat
command path: /bin/netstat
Execution authority: all users
Syntax : netstat [options]
function description: display network-related information
Options :
-t: TCP protocol
-u: UDP protocol
-l: monitoring
-r: routing
-n : Display IP address and port number

Example:
[root@localhost ~]# netstat -tlun View the port number monitored by this machine
[root@localhost ~]# netstat -an View all network connections of this machine
[root@localhost ~]# netstat -rn View this machine routing table


Reference link:

A linux command per day (44): top command
Bird brother's linux private kitchen
Linux Use ps and top commands to find the program that consumes the most CPU and memory resources
Linux study notes eleven network commands

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325478072&siteId=291194637