linux-Basic Knowledge

Source: Internet
Author: User
Tags switches cpu usage high cpu usage

Commands for 1.W

[Email protected] ~]# W

22:59:41 up 15:46, 1 user, load average:0.00, 0.01, 0.05

USER TTY from [email protected] IDLE jcpu PCPU

Root pts/0 10.0.0.1 22:43 5.00s 0.05s 0.02s W

[Email protected] ~]#

2.uptime command

[Email protected] ~]# uptime

23:00:00 up 15:46, 1 user, load average:0.00, 0.01, 0.05

[Email protected] ~]#

3.vmstat Summary

[Email protected] ~]# Vmstat 1

procs-----------Memory-------------Swap-------io-----system--------CPU-----

R b swpd free buff cache si so bi bo in CS us sy ID WA St

1 0 0 298360 1696 591216 0 0 3 4 16 23 0 0 100 0 0

0 0 0 298360 1696 591216 0 0 0 0 38 51 0 0 100 0 0

0 0 0 298344 1696 591216 0 0 0 0 26 34 0 0 100 0 0

0 0 0 298344 1696 591216 0 0 0 16 32 40 0 0 100 0 0

0 0 0 298344 1696 591216 0 0 0 0 28 38 0 0 100 0 0

0 0 0 298344 1696 591216 0 0 0 3 33 49 0 0 100 0 0

0 0 0 298344 1696 591216 0 0 0 0 27 33 0 0 100 0 0

R means running the queue (that is, how many processes are really allocated to the CPU), the server I am testing is currently idle, there is no program running, when this value exceeds the number of CPUs, there will be a CPU bottleneck. This is also related to top of the load, the general load over 3 is relatively high, more than 5 is high, more than 10 is not normal, the state of the server is very dangerous. The load on top is similar to the run queue per second. If the running queue is too large, it means that your CPU is busy, which generally results in high CPU usage.

b represents the blocking process, which is not much to say, the process is blocked, you understand.

SWPD virtual memory has been used size, if greater than 0, indicates that your machine is out of physical memory, if not the cause of program memory leaks, then you should upgrade the memory or the memory-consuming task to other machines.

Free physical memory size, my machine memory total 8G, the remaining 3415M.

Buff Linux/unix system is used to store, directory inside what content, permissions, etc. of the cache, I am the machine about more than 300 m

The cache cache is used directly to memorize the files we open, to buffer the files, I have about 300 m of this machine (this is the smart place of Linux/unix, the spare part of the physical memory to do the file and directory cache, is to improve the performance of the program execution, when the program uses memory, Buffer/cached will be used very quickly. )

Si reads the size of the virtual memory from disk every second, if this value is greater than 0, it means that the physical memory is not enough or the memory leaks, to find out the memory process. My machine has plenty of memory and everything is fine.

So per second The virtual memory is written to the size of the disk, if this value is greater than 0, ibid.

The number of blocks received per second by the BI block device, where the block device refers to all the disks and other block devices on the system, the default block size is 1024byte, I have no IO operation on this machine, so it's been 0, but I've seen the 140000/s on machines that handle copying large amounts of data (2-3t). Disk write speed of almost 140M per second

The number of blocks that Bo block devices send per second, such as when we read a file, the Bo will be greater than 0. Bi and Bo are generally close to 0, otherwise the IO is too frequent and needs to be adjusted.

In CPU interrupts per second, including time interrupts

CS per second, such as the number of context switches, such as we call the system function, the context switch, the thread of the switch, but also the process context switch, the smaller the value of the better, too big, to consider the number of threads or processes, such as Apache and Nginx in the Web server, We generally do performance testing will carry out thousands of concurrent or even tens of thousands of concurrent tests, the selection of the Web server process can be the process or the peak of the thread has been down, pressure measurement, until CS to a relatively small value, the process and the number of threads is a more appropriate value. System calls are also, each time the system function is called, our code will enter the kernel space, resulting in context switching, this is very resource-intensive, but also try to avoid frequent calls to system functions. Too many context switches means that most of your CPU is wasted in context switching, resulting in less time for the CPU to do serious work, and the CPU not being fully utilized, is undesirable.

US user CPU time, I used to do encryption and decryption very frequently on the server, you can see us approaching 100,r running queue reached 80 (the machine is doing a stress test, poor performance).

SY system CPU time, if too high, indicates a long system call time, for example, the IO operation is frequent.

ID Idle CPU time, in general, ID + US + sy = 100, generally I think ID is idle CPU usage, US is the user CPU usage, SY is the system CPU utilization.

WT waits for IO CPU time.

Summary of the 4.top command

[email protected] ~]# Top

top-23:03:04 up 15:49, 1 user, load average:0.00, 0.01, 0.05

tasks:96 Total, 1 running, sleeping, 0 stopped, 0 zombie

%CPU (s): 0.0 us, 0.2 sy, 0.0 ni, 99.8 ID, 0.0 wa, 0.0 hi, 0.0 si, 0.0th

KiB mem:999964 Total, 298048 free, 109004 used, 592912 Buff/cache

KiB swap:2097148 Total, 2097148 free, 0 used. 691840 Avail Mem

PID USER PR NI VIRT RES SHR S%cpu%MEM time+ COMMAND

21308 Root 0 142972 5156 3884 S 0.3 0.5 0:00.32 sshd

1 root 0 128092 6728 3968 S 0.0 0.7 0:02.40 SYSTEMD

2 Root 0 0 0 0 S 0.0 0.0 0:00.01 Kthreadd

3 Root 0 0 0 0 S 0.0 0.0 0:00.09 ksoftirqd/0

5 root 0-20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0h

7 Root RT 0 0 0 0 S 0.0 0.0 0:00.03 migration/0

8 Root 0 0 0 0 S 0.0 0.0 0:00.00 RCU_BH

9 Root 0 0 0 0 S 0.0 0.0 0:03.98 rcu_sched

Root RT 0 0 0 0 S 0.0 0.0 0:00.63 watchdog/0

Root RT 0 0 0 0 S 0.0 0.0 0:00.61 WATCHDOG/1

Root RT 0 0 0 0 S 0.0 0.0 0:00.09 MIGRATION/1

Root 0 0 0 0 S 0.0 0.0 0:00.78 KSOFTIRQD/1

Ordinal column name meaning

A PID process ID

b PPID Parent Process ID

C ruser Real User name

D UID Process Owner's user ID

e username of user process Owner

Group name of the F group Process owner

The terminal name of the G TTY boot process. Processes that are not started from the terminal are displayed as?

H PR-Priority

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

The last CPU used by J P is meaningful only in a multi-CPU environment

K%cpu CPU time consumption percentage last updated to current

The total CPU time, in seconds, used by the timing process

The total CPU time used by the M time+ process, in units 1/100 seconds

n the percentage of physical memory used by the%MEM process

o The total amount of virtual memory used by the VIRT process, in kilobytes. Virt=swap+res

The P swap process uses the size of the virtual memory, which is swapped out, in kilobytes.

The size of the physical memory, in kilobytes, that the Q RES process uses and has not been swapped out. Res=code+data

R code executable code occupies the physical memory size, in kilobytes

The amount of physical memory that is used outside of the S data executable code (data segment + stack), in kilobytes

T SHR shared memory size, in kilobytes

U Nflt page Error count

V NDRT the number of pages that have been modified in the last write to now.

W S process status (d= non-interruptible sleep state, r= run, s= sleep, t= track/Stop, z= zombie process)

x command name/command line

Y Wchan If the process is sleeping, the system function name in sleep is displayed

Z Flags task Flag, reference sched.h

Commands for 5.sar

Common:

[Email protected] ~]# sar-n DEV

Linux 3.10.0-514.el7.x86_64 (Localhost.localdomain) July 10, 2017 _x86_64_ (2 CPU)

17:20 50 sec IFACE rxpck/s txpck/s rxkb/s txkb/s rxcmp/s txcmp/s rxmcst/s

17:30 01 sec Lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

17:30 01 sec ens33 1.34 0.82 0.13 0.15 0.00 0.00 0.00

17:40 02 sec Lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

17:40 02 sec ens33 0.07 0.07 0.01 0.01 0.00 0.00 0.00

17:50 01 sec Lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

17:50 01 sec ens33 0.04 0.05 0.00 0.00 0.00 0.00 0.00

18:00 01 sec Lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

18:00 01 sec ens33 0.03 0.03 0.00 0.00 0.00 0.00 0.00

18:10 01 sec Lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

18:10 01 sec ens33 0.02 0.02 0.00 0.00 0.00 0.00 0.00

18:20 01 sec Lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

18:20 01 sec ens33 0.03 0.02 0.00 0.00 0.00 0.00 0.00

18:30 01 sec Lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

18:30 01 sec ens33 0.01 0.01 0.00 0.00 0.00 0.00 0.00

18:40 01 sec Lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

18:40 01 sec ens33 0.01 0.02 0.00 0.00 0.00 0.00 0.00

18:50 01 sec Lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

18:50 01 sec ens33 0.01 0.01 0.00 0.00 0.00 0.00 0.00

19:00 01 sec Lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

19:00 01 sec ens33 0.01 0.01 0.00 0.00 0.00 0.00 0.00

19:10 01 sec Lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

19:10 01 sec ens33 0.01 0.01 0.00 0.00 0.00 0.00 0.00

6.nload command

Nload Direct return

Device Ens33 [10.0.0.201] (1/2):

=============================================================================================

Incoming:

curr:872.00 bit/s

avg:976.00 bit/s

min:872.00 bit/s

max:1.86 kbit/s

ttl:60.60 MByte

Outgoing:

curr:7.85 kbit/s

avg:8.17 kbit/s

min:4.90 kbit/s

max:8.98 kbit/s

ttl:4.02 MByte


linux-Basic Knowledge

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.