Common shell Command collation

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.