Linux System Status Command

Source: Internet
Author: User
Tags switches high cpu usage

Top command

The top command is a common performance analysis tool under Linux that shows the resource usage of individual processes in the system in real time, similar to the Task Manager for Windows. Top is a dynamic display process where the current state can be refreshed continuously with the user key. If the command is executed in the foreground, it will monopolize the foreground until the user terminates the program. More accurately, the top command provides real-time status monitoring of the system's processor. It will display the most "sensitive" CPU in the system. Task List. This command can be used by CPU. Memory usage and execution time to sort tasks, and many of the features of the command can be set through interactive commands or in personal customization files.

    • First line

System time, System startup experience time, current online user, one minute, five minutes, 15 minutes average load

    • Second line

Total system tasks, tasks to be run, tasks to sleep, tasks to stop, zombie missions

    • Third line

The user-state process consumes a percentage of CPU time, does not contain the CPU time that the Renice value is negative, the percentage of CPU consumed by the kernel, the percentage of CPU that the process that has changed priority, the percentage of idle CPU time, the percentage of CPU time waiting for I/O, and the percentage of CPU hard Interrupt Time CPU Soft Terminal time percentage
Note: This shows that the data is the average of all CPUs, if you want to see the processing of each CPU, press 1, fold, press 1 again.

    • Line Four

The total amount of physical memory, the physical memory used, the free physical memory, the physical memory used for the working kernel cache

    • Line Five

The amount of swap used; The swap usage of the buffer swap area.

    • Process information for remaining rows

PID: Process PID
User: Users executing the process
PR: Priority, smaller priority higher
Ni:nice Value
VIRT: Virtual memory consumed by the process
RES: The physical memory occupied by the process
SHR: Shared memory used by the process
S: The state of the process. s for hibernation, R for running, Z for Zombie, n for the process priority value is negative
%CPU: The process consumes CPU utilization
%MEM: The percentage of physical memory and total memory that the process occupies
time+: The total CPU time that is consumed after the process is started, which is the cumulative value of CPU time
command: Process-initiated name

    • The following is a list of some common top command action directives
Q: Exit top command <space>: Refresh now (SPACEBAR) s: Set refresh interval c: Show command full mode T: : Show or hide process and CPU status information m: Show or hide memory status information L: Show or hide uptime information f: Increase or decrease the process display flag S: Cumulative mode, the CPU time occupied by a completed or exited subprocess is accumulated to the mite+p of the parent process: by% CPU Usage ranking T: by mite+ m: by%mem u: Specify show user process R: Modify process Renice value Kkill: Process I: Show only running processes W: Save settings for top to file ~/.TOPRC, The next boot will automatically invoke the settings of the TOPRC file. H: Help command

Free command

    • Brief introduction

Subtracting the value of buffer and cache from the value of used is your current real memory usage ———— – A parameter that is mem for the operating system. Buffers/cached are all belong to be used.

For the application It is (-/+ Buffers/cach). buffers/cached is equivalent, because buffer/cached is designed to improve the performance of the program execution, and when the program uses memory, buffer/cached is quickly used. So, take a look at the application, to (-/+ Buffers/cache) of the free and used-based.

In order to improve disk and memory access efficiency, Linux has done a lot of careful design, in addition to the Dentry cache (for VFS, speed up the file path name to Inode conversion), but also adopted two main cache mode: Buffer cache and Page cache. The former is for the disk block read and write, the latter for the file inode read and write. These caches can effectively shorten the time for I/O system calls (such as read,write,getdents). Remember that memory is for use, not to take a look. Unlike Windows, no matter how much real physical memory you have, he will have to take the hard disk swap files to read. This is why Windows often prompts for a lack of virtual space. You think, how boring, in memory and most of the time, Take out some of the hard disk space to act as memory. So we look at Linux, as long as we don't swap space with swap, we don't have to worry about too little memory. If you use a lot of swap, you might want to consider adding physical memory. This is also the standard for Linux to see if memory is sufficient.

    • Syntax and parameters

Syntax: free [-bkmotv][-s < interval of seconds;]
Additional Note: The free instruction shows memory usage, including physical memory, virtual swap file memory, shared memory segments, and buffers used by the system core.
Parameters
-B Displays memory usage in bytes.
-K displays memory usage in kilobytes.
-m displays memory usage in megabytes. (most commonly used)
-O does not display buffer throttling columns.
-s< interval seconds > Continuous observation of memory usage.
-T displays the memory sum column.
-V Displays version information.

    • Detailed command

Total: Indicates the amount of physical memory (totals = used + free).
Used: Represents the amount that the total is allocated to the cache (including buffers and cache), but may not be actually used in some of the caches.
Free: Memory that has not been allocated.
GKFX: Shared memory, general system will not be used, nor discussed here.
Buffers: The number of buffers that are allocated but not used by the system.
Cached: The number of caches that the system allocates but has not been used.

-/+ Buffers/cache represents cache statistics for physical memory
Used2:used1–buffers1-cached1 (439-57-80) is also the amount of memory actually used.
Free2= buffers1 + cached1 + free1 (49+57+80) unused buffers with cache and unallocated memory, this is the current actual available memory of the system

Swap indicates the usage of the swap partition on the hard disk
Cat/proc/meminfo |grep-i Swap


The exchange will reduce the number of physical pages used in the system in three ways:
1. Reduce the buffer and the size of the page cache,
2. Swap out the memory page of the System V type
3. Swap out or discard the page. (Application occupies a memory page, that is, insufficient physical memory).
In fact, a small amount of swap use does not affect the performance of the system.


The difference between buffers and cached
For applications, buffers/cached is equal to available, because buffer/cached is designed to improve the performance of file reads, and buffer/cached is quickly recycled when applications need to use memory.
So, from the application's point of view, available memory = System Free memory+buffers+cached (as explained in the command above).
Buffers is the buffer size used to make a block device, and he only records the metadata of the filesystem and tracking in-flight pages.
Cached is used to buffer files.
That is to say: buffers is used to store, what content inside the directory, permissions and so on.

Vmstat command

    • Brief introduction

Vmstat is a comprehensive profiling tool that observes the system's process state, memory usage, virtual memory usage, disk IO, interrupts, context switches, CPU usage, and more.

    • Detailed

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 blocked process. 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, what content inside the directory, permissions, such as the cache, I am about to occupy more than 300 Mcache cache directly used to remember the file we opened, to buffer the file, I am about 300 m of this machine (here is linux/ The smart thing about UNIX is that a portion of the free physical memory is used to cache files and directories in order to improve the performance of the program execution, and when the program uses memory, the buffer/cached will be in use 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 is resolved. 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 is almost 140M per second the number of blocks sent by Bo block devices, such as when we read files, 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 the number of interrupts per second of the CPU, including the time interrupt CS per second number of context switches, for example, we call the system function, the context switch, the thread switch, and the process context switch, the smaller the better, too big, to consider the number of low thread or process, For example, in the Apache and Nginx Web server, we generally do performance testing in thousands of concurrent or even tens of thousands of concurrent testing, the process of selecting a Web server can be the peak of the process or the thread has been down, pressure measurement, until CS to a relatively small value, This process and the number of threads is the more appropriate value. System calls are also, each time a system function is called,Our code will enter the kernel space, resulting in context switching, which is very resource-intensive, and 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.

Mpstat command

    • Brief introduction

Mpstat is the abbreviation of multiprocessor statistics and is a real-time system monitoring tool. Its reports are some of the CPU's statistics, which are stored in the/proc/stat file. In a multi-CPUs system, it not only can view the average status information of all CPUs, but also can view the information of specific CPU. Mpstat's biggest feature is the ability to view statistics for each compute core in a multi-core CPU, while a tool like Vmstat can only view the overall CPU of the system.

    • Detailed

all: Refers to all CPUs
%usr: Displays the percentage of CPU utilization that is performed at the user level (for example, application)
%nice: Displays the percentage of CPU utilization that is performed at the user level with the nice priority
%sys: Percentage of CPU utilization at system level (e.g. kernel) execution
%iowait: Displays the percentage of CPU idle time during the system having outstanding disk I/O requests
%IRQ: Shows the percentage of time spent on CPU service hardware interrupts
%soft: Shows the percentage of time spent on CPU service software outages
%steal: Shows the percentage of virtual CPUs that spend time in an involuntary wait when the virtual Machine Manager is serving a second virtual processor
%guest: Shows the percentage of CPU time spent running virtual processors
%idle: Displays the percentage of time that the CPU is idle and the system does not have outstanding disk I/O requests

Http://sebastien.godard.pagesperso-orange.fr/man_mpstat.html

Linux System Status Command

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.