In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
What are the performance monitoring and optimization commands in Linux? I believe many inexperienced people are at a loss about this. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
1 top command
Top command is a commonly used performance analysis tool under Linux, which can display the resource consumption of each process in the system in real time, similar to the task manager of Windows.
How to use it is described in detail below. Top is a dynamic display process, that is, the user can press the key to constantly refresh the current state. If the command is executed at the foreground, it will monopolize the foreground until the user terminates the program.
More accurately, the top command provides real-time monitoring of the state of the system processor. It will display a list of CPU's most "sensitive" tasks in the system. This command can be used by CPU.
Memory usage and execution time sort tasks; and many of the features of this command can be set through interactive commands or in personal customization files.
Command format:
Top [parameters]
Command function:
Displays information about the processes being executed by the current system, including process ID, memory usage, CPU occupancy, etc.
Command parameters:
-b batch processing
-c displays the complete governance command
-I ignore the failure process
-s security mode
-S accumulation model
-I set the interval
-u specify user name
-p specify the process
The number of times the-n loop is displayed
4. Use an example:
Example 1: display process information
Command: top
Output:
[root@TG1704 log] # toptop-14:06:23 up 70 days, 16:44, 2 users, load average: 1.25,1.32, 1.35Tasks: 206total, 1 running, 205 sleeping, 0 stopped, 0 zombie Cpu (s): 5.9%us, 3.4%sy, 0.0%ni, 90.4%id, 0.0%wa, 0.0%hi, 0.2%si, 0.0%st Mem: 32949016k total, 14411180k used, 18537836k free 169884k buffers Swap: 32764556k total, 0k used, 32764556k free 3612636k cached PID USER PR NI VIRT RES SHR S% CPU% MEM TIME+ COMMAND 28894 root 22 0 1501m 405m 10m S 52.2 1.32534R 16 java 18249 root 18 03201m 1.9g 11m S 35 . 9 6.0 569:39.41 java 2808 root 25 0 3333m 1.0g 11m S 24.3 3.1 526:51.85 java 25668 root 23 0 3180m 704m 11m S 14.0 2.2 360:44.53 java 574 root 25 0 3168m 611m 10m S 12.6 1.9 556:59.63 java 1599 root 20 0 3237m 1.9g 11m S 12.3 6.2 262:01. 14 java 1008 root 21 0 3147m 842m 10m S 0.3 2.6 4:31.08 java 13823 root 23 0 3031m 2.1g 10m S 0.3 6.8 176:57.34 java 28218 root 15 0 12760 1168 808 R 0.3 0.0 0:01.43 top 29062 root 20 0 1241m 227m 10m S 0.3 0.7 2:07.32 java 1 root 15 0 10368 684 572 S 0.0 1 root RT 30.85 init 2 root RT-5000 S 0.0 01.01 migration/0 3 root 34 19 00 S 0.0 0.00: 00.00 ksoftirqd/0 4 root RT-5000 S 0.0 0.00: 00.00 watchdog / 0 5 root RT-5 000 S 0.0 0 purl 00.80 migration/1 6 root 34 19 00 S 0.0 0:00 .00 ksoftirqd/1 7 root RT-5000 S 0.0 0.00: 00.00 watchdog/1 8 root RT-5000 S 0.00 .00: 20.59 migration/2 9 root 34 19 00 S 0.0 ksoftirqd/2 00.09 ksoftirqd/2 10 root RT-5000 S 0 .00.00: 00.00 watchdog/2 11 root RT-5000 S 0.00.00: 23.66 migration/3 12 root 34 19 00 0 S 0.0 0.00: 00.03 ksoftirqd/3 13 root RT-5000 S 0.0 0.00: 00.00 watchdog/3 14 root RT-5 00 S 0.0 0 ksoftirqd/4 20.29 migration/4 15 root 34 19 00 0 S 0.0 0 ksoftirqd/4 16 root RT- 5000 S 0.0 0.00: 00.00 watchdog/4 17 root RT-5000 S 0.0 0.00: 23.07 migration/5 18 root 34 19 00 S 0.0 0.00: 00.07 ksoftirqd/5 19 root RT-5000 S 0.0 0.00: 00.00 watchdog/5 20 root RT-5000 S 0.0 0.0 ksoftirqd/6 17.16 migration/6 21 root 34 19 00 S 0.0 0.0 ksoftirqd/6 22 root RT-5000 S 0.0 0.00: 00.00 watchdog/6 23 root RT-5000 S 0.0 0.00: 58.28 migration/7
Description:
Statistics area: the first five lines are the statistics area of the current system as a whole. Let's look at the specific meaning of each line of information.
In the first line, the task queue information is the same as the execution result of the uptime command. The specific parameters are as follows:
14:06:23: current system time
Up 70 days, 16:44: the system has been running for 70 days, 16 hours and 44 minutes (during which time the system has not been restarted! )
2 users: there are currently 2 users logged in to the system
Load average: 1.15,1.42, the three numbers after 1.44:load average are 1 minute, 5 minutes and 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.
The second line, Tasks-Task (process), the specific information is as follows:
The system now has a total of 206processes, of which 1 is running, 205 is in sleep, 0 is in stoped, and 0 is in zombie (zombie).
The third line, cpu status information. The specific attributes are described as follows:
5.9%us: the percentage of CPU occupied by user space.
3.4% sy: the percentage of CPU occupied by kernel space.
0.0% ni: percentage of CPU occupied by processes that have changed priority
90.4% id: percentage of idle CPU
0% percentage of CPU occupied by wa:IO waiting
0.0% hi: percentage of CPU occupied by hard interrupt (Hardware IRQ)
0.2% si: percentage of CPU occupied by soft interrupt (Software Interrupts)
Note: here the usage ratio of CPU is different from the concept of windows, so you need to understand the user space and kernel space of linux system!
The fourth line, memory status, the details are as follows:
32949016k total-Total physical memory (32GB)
14411180k used-Total memory in use (14GB)
18537836k free-Total free memory (18GB)
169884k buffers-amount of cached memory (169m)
On the fifth line, swap exchanges partition information. The details are as follows:
32764556k total-Total Exchange area (32GB)
0k used-Total number of swap areas used (0K)
32764556k free-Total Free Exchange area (32GB)
3612636k cached-Total swap area buffered (3.6GB)
Note:
The total amount of memory in use (used) in the fourth line refers to the amount of memory currently controlled by the system kernel, and the total amount of free memory (free) is the amount that the kernel does not yet control. Not all the memory managed by the kernel is in use, and it also includes memory that has been used in the past and can be reused now, and the kernel does not return the reusable memory to free, so there will be less and less free memory on linux, but don't worry about it.
If you are used to calculating the amount of available memory, here is an approximate formula: free on the fourth line + buffers on the fourth line + cached on the fifth line. According to this formula, the available memory of this server: 18537836k + 169884k + 3612636k = 22GB.
For memory monitoring, we should always monitor the used of the fifth line of swap swap partition in top. If this value is constantly changing, it means that the kernel is constantly exchanging data between memory and swap, which is really out of memory.
The sixth line, blank line.
The seventh line is as follows: status monitoring of each process (task). The project column information is described as follows:
PID: process id
USER: process owner
PR: process priority
NI: nice value. Negative values indicate high priority, while positive values indicate low priority.
VIRT: the total amount of virtual memory used by the process, in kb. VIRT=SWAP+RES
RES: the amount of physical memory used by a process that has not been swapped out, 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
% CPU: percentage of CPU time elapsed since last update
% MEM: percentage of physical memory used by the process
Total CPU time used by the TIME+: process (in 100 seconds)
COMMAND: process name (command name / command line)
Other tips for using:
1. Multi-U and multi-core CPU monitoring
In the top base view, press the keyboard number "1" to monitor the status of each logical CPU:
Looking at the figure above, the server has 16 logical CPU, which is actually 4 physical CPU. Press the numeric key 1 again and you will return to the top base view interface.
two。 Highlight the currently running process
When you tap the keyboard "b" (turn the highlighting effect on / off), the view of top changes as follows:
We find that the "top" process with a process id of 2570 is highlighted, and the top process is the only runing process shown in the second line of the view. You can turn off or turn on the highlighting effect of the running process by hitting the "y" key.
3. Process field sorting
When entering top by default, each process is sorted according to the amount of CPU. In the following figure, the java process with an ID of 28894 ranks first (14.2% for cpu), and the java process with an ID of 574 ranks second (16% for cpu).
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.