Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common performance analysis commands in Linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces what Linux commonly used performance analysis commands are, which have a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.

Performance analysis.

Vmstat

Virtual memory statistics

Usage

Usage: vmstat [options] [delay [count]] Options:-a,-- active active/inactive memory-f,-- forks number of forks since boot-m,-- slabs slabinfo-n,-- one-header do not redisplay header-s,-- stats event counter statistics-d,-- disk disk statistics-D,-- disk-sum summarize disk statistics-p,-- partition partition specific statistics-S,-- unit define display unit-w -- wide wide output-t,-- timestamp show timestamp-h,-- help display this help and exit-V,-- version output version information and exit

Example

[root@localhost] # vmstat procs-memory- swap---io-----system---cpu- r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0 71256 92720 0 565120 0 1 115 22 36 1 0 99 0

Among them

R: the number of processes running and waiting for CPU time slices. If the value is greater than the number of system CPU, the CPU is insufficient.

B: indicates the number of processes waiting for resources

Swpd: the amount of memory switched to the memory swap area (in KB)

Free: the amount of free physical memory. My machine has a total of 2G of memory, leaving 92m.

Buff: the Linux/Unix system is used to store the contents of the directory, permissions, etc.

Cache: directly used to remember the files we opened, buffered the files, and used part of the free physical memory to cache files and directories, in order to improve the performance of program execution. When the program uses memory, buffer/cached will be used quickly.

Si: the amount of virtual memory read from disk per second. If this value is greater than 0, it means that the physical memory is insufficient or there is a memory leak. Find the memory consuming process to solve it.

So: the amount of virtual memory written to disk per second. If this value is greater than 0, same as above.

Bi: number of blocks received by the block device per second (read disk) (kb/s)

Bo: number of blocks sent by block devices per second (write disk) (kb/s)

In: the number of interrupts per second of CPU, including time interrupts

Cs: number of context switches per second.

Us: percentage of CPU time consumed by user processes

Sy: the kernel process consumes a percentage of CPU time. When the value of sy is high, the kernel consumes a lot of CPU resources.

Id: percentage of idle CPU time

Percentage of time wt:IO waited for CPU

Free

Memory usage

[root@localhost] # free total used free shared buff/cache available Mem: 1849336 1193336 90344 1752 565656 460000 Swap: 2097148 71248 2025900 [root@localhost] # free-h total used free shared buff/cache available Mem: 1.8G 1.1G 88M 1.7M 552M 449m Swap: 2.0G 69m 1.9G [root@localhost] # free-m total used free shared buff/cache available Mem: 1805 1165 88 1552 449 Swap: 2047 69 1978 [root@localhost] # free-h 2 total used free shared buff/cache available Mem: 1.8G 1.1G 88M 1.7M 552M 449m Swap: 2.0G 69m 1.9G [root@localhost] # free-h-s 2 total Used free shared buff/cache available Mem: 1.8G 1.1G 88M 1.7M 552M 449M Swap: 2.0G 69M 1.9G total used free shared buff/cache available Mem: 1.8G 1.1G 88M 1.7M 552M 449M Swap: 2.0G 69M 1.9G total used free shared buff/cache available Mem: 1.8G 1.1G 88M 1.7M 552M 449M Swap: 2.0G 69M 1.9G

Uptime

Statistics on the operation of the current system

[root@localhost] # uptime 09:59:55 up 2 days, 7 min, 1 user, load average: 0.00,0.01,0.05 load average: average load of the system for 1 minute, 5 minutes, 15 minutes

Netstat

Current network information

Usage

Usage: netstat [- vWeenNcCF] []-r netstat {- V |-- version |-h |-- help} netstat [- vWnNcaeol] [...] Netstat {[- vWeenNac]-I [] | [- veenNac]-I | [- cnNe]-M |-s [- 6tuw]} [delay]-r,-- route display routing table-I,-- interfaces= display interface table for-I,-- interfaces display interface table-g,-- groups display multicast group memberships-s -- statistics display networking statistics (like SNMP)-M,-- masquerade display masqueraded connections-v,-- verbose be verbose-W,-- wide don't truncate IP addresses-n -- numeric don't resolve names-- numeric-hosts don't resolve host names-- numeric-ports don't resolve port names-- numeric-users don't resolve user names-N,-- symbolic resolve hardware names-e,-- extend display other/more information-p -- programs display PID/Program name for sockets-o,-- timers display timers-c,-- continuous continuous listing-l,-- listening display listening server sockets-a,-- all display all sockets (default: connected)-F -- fib display Forwarding Information Base (default)-C,-- cache display routing cache instead of FIB-Z -- context display SELinux security context for sockets = {- t |-- tcp} {- u |-- udp} {- U |-- udplite} {- w |-- raw} {- x |-- unix}-- ax25-- ipx-- netrom = Use'- 6 |-4' or'- A'or'-' Default: inet List of possible address families (which support routing): inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25) netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP) x25 (CCITT X.25)

Among them

-a (all) shows all options, but does not show LISTEN correlation by default

-t (tcp) displays only tcp related options

-u (udp) shows only udp related options

-n refuses to display aliases and can show that all numbers are converted into numbers

-l lists only the status of services in Listen (monitoring)

-p displays the name of the program that established the relevant link

-r displays routing information, routing table

-e displays extended information, such as uid, etc.

-s statistics based on each protocol

-c execute the netstat command at regular intervals.

Tip: the status of LISTEN and LISTENING can only be seen with-an or-l

Top

[root@localhost java_demos] # top top-14:36:14 up 2 days, 4:43, 1 user, load average: 0.00,0.01,0.05 Tasks: 110 total, 2 running, 108 sleeping, 0 stopped, 0 zombie% Cpu (s): 0.3 us, 0.2 sy, 0.0 ni, 99.3 id, 0.2 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem: 1849336 total, 963348 free, 542372 used 343616 buff/cache KiB Swap: 2097148 total, 2011496 free, 85652 used. 1126908 avail Mem PID USER PR NI VIRT RES SHR S% CPU% MEM TIME+ COMMAND 1858 mysql 1465504 200800 6212 S 1.0 10.9 34 mysqld 56.46 mysqld 1 root 56636 4308 2808 S 0.00.05 systemd 2 root 20000 S 0.00.04 kthreadd 3 root 20 00 00 S 0.0 0.00: 01.53 ksoftirqd/0 5 root 0-20 000 S 0.0 0.00: 00.00 kworker/0:0H 7 root rt 00 00 S 0.0 0.00: 00.07 migration/0 8 root 20 0 00 0 S 0.0 0.00: 00.00 rcu_bh 9 root 20 00 00 S 0.0 0.00: 00.00 rcuob/0 10 root 20 00 00 S 0.0 0.00: 00.00 rcuob/1 11 root 20 00 00 S 0. 00.00: 00.00 rcuob/2 12 root 20 00 00 S 0.0 0.00: 00.00 rcuob/3 13 root 20 00 00 S 0.0 0.00: 14.63 rcu_sched 14 root 20 00 00 S 0.0 0.00: 10.43 rcuos/ 0 15 root 20 0 0 0 S 0.0 0.0 0:04.67 rcuos/1

Among them

* Line:

14:36:14 current system time

Days, 4:43 the system has been running for 2 days, 4 hours and 43 minutes (no reboot during this period)

1 users currently has 1 user logged on to the system

Load average: 0.00,0.01,0.05, the following three numbers are 1 minute, 5 minutes, 15 minutes of load respectively. Load average data is the number of active processes checked every 5 seconds and then calculated according to a specific algorithm. If this number is divided by the number of logical CPU, a result higher than 5 indicates that the system is overloaded.

Line 2: Tasks task (process)

The system now has 10 processes, of which 2 are running, 108 are in sleep, 0 are in stoped, and 0 are in zombie (zombie).

Line 3: cpu status

Percentage of us user space occupied by CPU

Percentage of sy kernel space occupied by CPU

Ni percentage of CPU occupied by processes that have changed priority

Percentage of id idle CPU

Percentage of CPU occupied by wa IO waiting

Percentage of CPU occupied by hi hard interrupt (Hardware IRQ)

Percentage of CPU occupied by si soft interrupt (Software Interrupts)

Line 4: memory status

Total total physical memory

Total free memory in free

Total memory in use of used

Amount of memory cached by buff/cache

Line 5: swap swap partition

Total amount of total exchange area

Total free free swap area

Total number of switching areas used by used

Total swap area of avail Mem buffer

Line 6: status monitoring of each process (task)

PID process id

USER process owner

PR process priority

NI nice value. Negative values indicate high priority, while positive values indicate low priority.

The total amount of virtual memory used by the VIRT process, in kb. VIRT=SWAP+RES

The amount of physical memory used by the RES process that has not been swapped, in kb. RES=CODE+DATA

SHR shared memory size (in kb)

S process status. D = uninterruptible sleep state R = run S = sleep T = track / stop Z = zombie process

% percentage of time spent by CPU from last update to present CPU

% percentage of physical memory used by the MEM process

Total CPU time used by the TIME+ process (in 100 seconds)

COMMAND process name (command name / command line)

Monitor the number of java threads

Ps-eLf grep java wc-l

Monitor the number of network customer connections:

Netstat-n grep tcp grep listening port wc-l Thank you for reading this article carefully. I hope the article "what are the common Linux performance analysis commands shared by the editor will be helpful to you?" at the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report