System status detection and Process Control

Source: Internet
Author: User
Tags high cpu usage server memory

View Linux Server CPU

Two Guiding Principles

# CPU with the same core ID is hyper-threading of the same core #

# A cpu with the same physical ID is a thread or core encapsulated by the same CPU #

CAT/proc/cpuinfo | grep 'siblings'

[[Email protected] ~] # Arch# This is my R51 old notebook #

I686

[[Email protected] ~] # Cat/proc/cpuinfo # This is my R51 old notebook #

Processor: 0 # This indicates the first CPU kernel from 0 #

Vendor_id: genuineintel

CPU family: 6

Model: 13

Model name:Intel (r) celeon (r) m processor 1.60 GHz

Stepping: 8

CPU MHz: 1600.000The clock speed is 1.6 GHz.

Cache size: 1024 KBCache is 1 MB

Fdiv_bug: No

Hlt_bug: No

F00f_bug: No

Coma_bug: No

FPU: Yes

Fpu_exception: Yes

Cpuid level: 2

WP: Yes

Flags: fpu vme de pse tsc msr pae mce cx8 APIC Sep mtrr pge mca cmov clflush dts acpi mmx fxsr SSE sse2 ss tm pbe nx up BTS

Bogomips: 3190.82

Clflush size: 64

Cache_alignment: 64

Address sizes: 32 bits physical, 32 bits virtual

Power Management:

[Email protected]:/> Arch# This is the 64-bit VM under r720 server #

X86_64

[Email protected]:/> CAT/proc/cpuinfo # This is the VM under r720 server #

Processor: 0

Vendor_id: genuineintel

CPU family: 6

Model: 44

Model name:Intel (r) Xeon (r) CPU x5680 @ 3.33 GHz

Stepping: 2

CPU MHz: 3324.027

Cache size: 12288 KB

FPU: Yes

Fpu_exception: Yes

Cpuid level: 11

WP: Yes

Flags

Bogomips: 6654.76

Clflush size: 64

Cache_alignment: 64

Address sizes: 40 BITs physical, 48 bits virtual

Power Management:

Processor: 1

Vendor_id: genuineintel

CPU family: 6

Model: 44

Model name: Intel (r) Xeon (r) CPU x5680 @ 3.33 GHz

Stepping: 2

CPU MHz: 3324.027

Cache size: 12288 KB

FPU: Yes

Fpu_exception: Yes

Cpuid level: 11

WP: Yes

Flags

Bogomips: 6651.14

Clflush size: 64

Cache_alignment: 64

Address sizes: 40 BITs physical, 48 bits virtual

Power Management:

Processor: 2

Vendor_id: genuineintel

CPU family: 6

Model: 44

Model name: Intel (r) Xeon (r) CPU x5680 @ 3.33 GHz

Stepping: 2

CPU MHz: 3324.027

Cache size: 12288 KB

FPU: Yes

Fpu_exception: Yes

Cpuid level: 11

WP: Yes

Flags

Bogomips: 6651.00

Clflush size: 64

Cache_alignment: 64

Address sizes: 40 BITs physical, 48 bits virtual

Power Management:

Processor: 3

Vendor_id: genuineintel

CPU family: 6

Model: 44

Model name: Intel (r) Xeon (r) CPU x5680 @ 3.33 GHz

Stepping: 2

CPU MHz: 3324.027

Cache size: 12288 KB

FPU: Yes

Fpu_exception: Yes

Cpuid level: 11

WP: Yes

Flags

Bogomips: 6650.94

Clflush size: 64

Cache_alignment: 64

Address sizes: 40 BITs physical, 48 bits virtual

Power Management:

[Email protected]:/> CAT/proc/cpuinfo | grep "processor" | WC-L # WC-L indicates that four rows are displayed, and four cores are displayed ···#

4

Certificate -------------------------------------------------------------------------------------------------------------------------------------------------

View Linux Server Memory

Guiding Principles:

In Windows, no matter how much memory you have left, it still calls the disk swap file to read.

In Linux, As long as swap space is not used, the memory is still available.

[[Email protected] ~] # Free-M # My R51 notebook #

Total used free shared buffers cached

Mem: 1129 508 621 0 76 338

-/+ Buffers/cache: 93 1036

Swap: 1022 0 1022

[Email protected]:/> free-M # Dell server #

Total used free shared buffers cached

Mem: 3824 3796 27 0 197 3342

-/+ Buffers/cache: 256 3567

Swap: 8197 0 8197

Here is an interesting part.

System Logs

  • /Var/log/dmesg core startup log

  • /Var/log/messages System Error Log

  • /Var/log/maillog Mail System Log

  • /Var/log/boot. Log pilot process log

  • /Var/log/cron record the child process derived from the daemon

  • /Var/log/syslog record warning information

  • /Var/log/wtmp permanently records user logon events

  • /Var/log/xferlog FTP session

  • /Var/log/secure Security Information

What is process

An event is defined as a process and assigned an ID, also known as PID.

Set the permissions of the PID group based on the relationship between the user who triggered the event and related attributes.

Certificate -------------------------------------------------------------------------------------------------------------------------------------------------

Use vmstat to monitor overall Linux system performance

CH-HOV-FTP1:/# vmstat 1 4 # display 4 times a second #

Procs ----------- memory ---------- --- swap -- ----- Io -----System -- ---- CPU ----

R B SWPD free buff cache Si Sobi Bo in CS us Sy ID wa

0 0 116 32836 189844 3437880 0 0 2 14 1 1 1 0 99 0

0 0 116 32836 189844 0 0 0 3437880 10 0 0 264 0

0 0 116 32836 189872 3437904 0 0 112 294 103 0 100 0

0 0 116 32836 189872 0 0 0 52 3437904 12 0 0 264 0

RIndicates the running Queue (that is, how many processes are actually allocated to the CPU). When this value exceeds the number of CPUs, a CPU bottleneck will occur. This is also related to the top load. Generally, when the load exceeds 3, it is relatively high. If the load exceeds 5, it is high. If the load exceeds 10, it is abnormal and the server status is very dangerous. The top load is similar to the running queue column per second. If the running queue is too large, it indicates that your CPU is very busy, which may cause high CPU usage.

BIndicates a blocked process. This is not to mention that the process is blocked. You can understand it.

SWPDThe size of the virtual memory used. If it is greater than 0, the physical memory of your machine is insufficient. If it is not the cause of program memory leakage, you should upgrade the memory or migrate the memory-consuming tasks to other machines. # My Linux FTP memory is a little small #

FreeIdle physical memory size

BuffThe Linux/Unix system is used to store the contents and permissions in the directory. My local machine occupies about 189 MB.

CacheCache is used directly to remember the files we opened and buffer the files. My local machine occupies more than 3400 MB (here is the cleverness of Linux/Unix, cache part of the idle physical memory for files and directories to Improve the Performance of program execution. When the program uses the memory, buffer/cached will be quickly used .) # I am an FTP server that reads data from more than 300 people every day. It can improve the memory, but it is not added because there is no chance of downtime #

SiThe size of the virtual memory read from the disk per second. If the value is greater than 0, it indicates that the physical memory is insufficient or the memory is leaked. Find out the memory-consuming process to solve the problem. My machine has plenty of memory and everything is normal.

SoThe size of the virtual memory written to the disk per second. If the value is greater than 0, the same as above.

BiThe number of blocks received by Block devices per second. The Block devices here refer to all disks and other Block devices in the system. The default block size is 1024 bytes. I have no IO operations on this machine, so it has always been 0, but I have seen it on a machine that processes a large amount of data (2-3 TB) that can reach 140000/s, and the disk write speed is almost MB per second.

BoThe number of blocks sent by the block device per second. For example, if we read files, the number of Bo messages must be greater than 0. Bi and Bo are generally close to 0. Otherwise, Io is too frequent and needs to be adjusted.

InThe number of CPU interruptions per second, including time interruptions

CSThe number of context switches per second. For example, if we call a system function, we need to perform context switching, thread switching, and process context switching. The smaller the value, the better, the larger the value, we need to reduce the number of threads or processes. For example, on a Web server such as Apache and nginx, we generally perform thousands or even tens of thousands of concurrent tests during performance tests, the process of selecting the Web server can be lowered from the peak of the process or the user thread until CS reaches a relatively small value. This process and the number of threads are a suitable value. The same is true for system calls. Every time we call a system function, our Code will enter the kernel space, resulting in context switching. This is resource-consuming and we should try to avoid frequent calls to system functions. Too many context switches indicate that most of your CPU is wasted on context switches, resulting in less time for proper CPU operations and insufficient CPU utilization.

UsCPU time of the user, I used to perform encryption and decryption on a very frequent server. We can see that US is close to 100, and r runs a queue of 80 (the machine is doing a stress test and the performance is not good ).

SyThe system CPU time. If it is too high, it indicates that the system call time is long, for example, frequent Io operations.

IDIdle CPU time. Generally, ID + US + Sy = 100. Generally, Id indicates idle CPU usage, US indicates user CPU usage, and SY indicates system CPU usage.

WTWait for the io cpu time.

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.