1. View memory from large to small arrangement
PS-E-O "%c:%p:%z:%a" |sort-k5-nr
Analysis:
-E Display Process
-O display by user-defined format
%c CPU
%p Parent Process ID
%z Virtual Memory
%a
Sort Order Command
-k5 sorted by 5th column
-nr comparing numbers from large size
-N Compare numbers from small to large
Example 1.1: Sort by memory from large to small, display the first five elements
1[[Email Protected]_1 ~]$PS-e-o"%c:%p:%z:%a"|Sort-k5-nr |Head-52 0.0:2045:1139104:/usr/local/mysql/bin/mysqld--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data--plugin-dir=/usr/local/mysql/lib/plugin--user=mysql--log-error=/usr/local/mysql/data/test_1.smartpay.com.cn.err--pid-file=/usr/local/mysql/data/Test_1.smartpay.com.cn.pid3 0.0:2211:1033640:/usr/sbin/console-kit-daemon--no-Daemon4 0.0:2347:427884:/usr/bin/pulseaudio--start--log-target=syslog5 0.0:2326:405280:/usr/libexec/gdm-simple-greeter6 0.0:1886:385704: AutoMount--pid-file/var/run/autofs.pid
Instance 1.2 per process ID from small to large
[[Email Protected]_1 ~]$PS-e-o"%c:%p:%z:%a"|Sort-k3-n |Head-5%CPU:PID:VSZ:COMMAND0.0:1:19356:/sbin/Init0.0:2:0: [Kthreadd]0.0:3:0: [migration/0] 0.0:4:0: [ksoftirqd/0]
Instance 1.3 by CPU utilization from large to small
[[Email Protected]_1 ~]$PS-e-o"%c:%p:%z:%a"|Sort-k1-nr |Head-5 0.1:3157:218380: SMBD-D%CPU:PID:VSZ:COMMAND0.0:9:0: [ksoftirqd/1] 0.0: -:0: [kstriped]0.0:8:0: [migration/1]
View Code
2 Viewing the number of concurrent requests for HTTP and their connection status
awk ' /^tcp/{++s[$NF]} END {for (a in S) print A,s[a]} ' 3
$NF This value is established not read. Now I understand.
awk ' /^tcp/{print $NF} ' awk'/^tcp/{print NF}'666
NF is the number of domains that are browsing records, and $NF is the last field to get.
awk '/^tcp/{++s[$NF]} END {for (a in S) print A,s[a]} '
The implication is that the beginning of the TCP is over, then the last field is sorted, and the number of each classification is calculated,
Common shell Command collation