Some Commands Usually Used in Linux for System Performance Tuning

Keywords: Ubuntu Linux sudo Java

Have a good laugh

When we are young, we often make faces in the mirror. When we are old, the mirror is even. 2. Boys are poor, or they don't know how to struggle, girls are rich, or a piece of cake will be coaxed away. 3. If marriage is the grave of love, then I expect someone to bury me. 4. Sleep is an art. Nobody can stop me from pursuing art. 5. I won't say kill you. ]

Ask questions

What commands are commonly used by Linux servers to view performance???

Solve the problem

The task of recent work is to optimize the performance of the company's system. Among them, more commands are used. In summary, most of them refer to the online gods. I just refined the commands I used:

Output system log last 10 lines dmesg | tail

ubuntu@ubuntu:~$ dmesg | tail
[38060.138072] e1000: eno16777736 NIC Link is Down
[38068.362442] e1000: eno16777736 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
[38070.366445] e1000: eno16777736 NIC Link is Down
[38076.376947] e1000: eno16777736 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
[38084.386812] e1000: eno16777736 NIC Link is Down
[38090.411818] e1000: eno16777736 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
[38480.597723] e1000: eno16777736 NIC Link is Down
[38495.064487] e1000: eno16777736 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
[38607.910407] IPv6: ADDRCONF(NETDEV_UP): eno16777736: link is not ready
[38607.978329] e1000: eno16777736 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None

This command outputs the last 10 lines of the system log. These logs can help troubleshoot performance problems.

top command

top command is the most commonly used command for performance analysis, and it is also the most important command. What each parameter represents must be very clear.

top - 07:01:15 up 10:57,  3 users,  load average: 0.00, 0.04, 0.13
Tasks: 238 total,   1 running, 237 sleeping,   0 stopped,   0 zombie
%Cpu(s):  3.4 us,  3.8 sy,  0.0 ni, 92.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:   2040024 total,  2020312 used,    19712 free,    11220 buffers
KiB Swap:  3142652 total,   927204 used,  2215448 free.   121276 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                   
 6844 root      20   0  333020  20520   3600 S   6.0  1.0  29:48.44 Xorg                                                                      
61687 ubuntu    20   0 1635056  43716  18108 S   3.6  2.1   5:00.27 compiz                                                                    
 5444 ubuntu    20   0 3765292 875688  10020 S   2.7 42.9  42:13.69 java                                                                      
 6788 root      20   0  293028   9284   1112 S   2.3  0.5   0:51.92 dockerd                                                                   
 5175 ubuntu    20   0  578736  22496  14888 S   1.7  1.1   0:04.60 gnome-terminal-                                                           
   27 root      39  19       0      0      0 S   0.7  0.0   0:09.02 khugepaged                                                                
 7932 ubuntu    20   0 3060636  16560 

The top command contains the checks of the previous commands. For example, uptime, free memory usage, vmstat and so on. So with this command, you can see the source of the system load in a relatively comprehensive way. At the same time, the top command supports sorting and can be sorted according to different columns, so it is convenient to find out processes such as those with the most memory occupancy and those with the highest CPU occupancy.

However, the top command output is an instantaneous value relative to some of the previous commands, and if you don't keep looking, you may miss some clues. At this point, you may need to pause the top command refresh to record and compare data.

The first line:

top - 07:01:15 up 10:57,  3 users,  load average: 0.00, 0.04, 0.13

Explanation:

07:01:15 Current Time
 up 10:57 system runtime in time:
3 user Current number of logged-in users
 load average: 0.00, 0.04, 0.13 system load, that is, the average length of the task queue. The three values are 1 minute, 5 minutes and 15 minutes ago to the present average.

The second and third lines, when there are multiple CPU s, may exceed two lines. The contents are as follows:

total Total number of processes
running Number of running processes
sleeping Number of Sleep Processes
stopped Number of processes stopped
zombie zombie
Cpu(s): 
3.4% us User space occupancy CPU Percentage
3.8% sy Kernel space occupation CPU Percentage
0.0% ni Process occupancy that has changed priority in user process space CPU Percentage
92.8% id free CPU Percentage
0.0% wa Waiting for input and output CPU Percentage of time
0.0%hi: Hardware CPU Interruption Occupancy Percentage
0.0%si: Soft interrupt occupancy percentage
0.0%st: Percentage of virtual machine occupancy

The last two behaviors are memory information. The contents are as follows:

Mem:
2040024 total    Total physical memory
2020312 used    Total physical memory used
17616k free    Total free memory
11220 buffers    The amount of memory used as the kernel cache
Swap: 
3142652 total    Total Exchange Area
927204 used    Total switching area used
2215448 free    k free
121276 cached    Total switching area of buffer,Content in memory is swapped out to the swap area, and then into memory, but the used swap area has not been overwritten. This value is the size of the swap area where the content already exists in memory.,When the corresponding memory is swapped out again, there is no need to write to the swap area.

The details of each process are shown below the statistical information area of the process information area. First of all, let's get to know the meaning of each column.

Serial Number Column Name Meaning
 A PID process id
 B PPID parent process id
c    RUSER   Real user name
 D User id of UID process owner
 E USER process owner's username
 F GROUP process owner's group name
 G TTY Start Process Terminal Name. The process that is not started from the terminal is displayed as follows?
H PR Priority
 I NI nice value. Negative values denote high priority and positive values denote low priority.
The last CPU used by J P is meaningful only in multi-CPU environments
 Percentage of CPU time consumed since the last update of k% CPU
 Total CPU time used by the TIME process, in unit seconds
 Total CPU time used by M TIME + processes in 1/100 seconds
 Percentage of physical memory used by n% MEM processes
 The total amount of virtual memory used by the o VIRT process, per kb. VIRT=SWAP+RES
 In the virtual memory used by the P SWAP process, the size of the swap is in kb.
The size of physical memory used by the Q RES process and not swapped out, in kb. RES=CODE+DATA
 Physical memory occupied by R CODE executable code, unit kb
 The size of physical memory occupied by parts other than the executable code of s DATA (data segment + stack), per kb
 T SHR Shared Memory Size, Unit kb
 Number of page errors in U nFLT
 The last time v nDRT was written to the present, the number of pages that have been modified.
W S process state (D = Uninterruptible sleep state, R = running, S = sleep, T = tracking / stopping, Z = zombie process)
X COMMAND command name/command line
 Y WCHAN displays the name of the system function in sleep if the process is sleeping
 Z Flags Task Logo, refer to sched.h

Query the user information logged on to the current system: w command

ubuntu@ubuntu:~$ w
 20:15:44 up 11:17,  3 users,  load average: 0.21, 0.16, 0.16
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
ubuntu   :0       :0               Thu00   ?xdm?  30:09   1.63s /sbin/upstart --user
ubuntu   pts/7    :0               Thu23   45:01m 42:57   8.80s /home/ubuntu/inno/idea-IU-162.2032.8/bin/fsnotifier64
ubuntu   pts/18   :0               06:47    0.00s  0.47s  0.05s w

User information logged on to the current system can be queried, and what these users are currently doing

iostat

At runtime, if the following prompt message appears

ubuntu@ubuntu:~$ iostat
The program 'iostat' is currently not installed. You can install it by typing:
sudo apt-get install sysstat

Execute sudo apt-get install sysstat.

Iostat provides three reports: CPU utilization, device utilization and network file system utilization. The three reports can be independently displayed using - c, - d and - h parameters.

Memory analysis command: free m

ubuntu@ubuntu:~$ free -m
             total       used       free     shared    buffers     cached
Mem:          1992        672       1320          6         22        209
-/+ buffers/cache:        440       1552
Swap:         3068        403       2665

free: View the usage of system memory, and the - m parameter is shown in megabytes.
The last two columns represent the number of memory used for IO caching and the number of memory used for file system page caching, respectively. It should be noted that the second line - /+ buffers/cache seems to take up a lot of memory space. This is the memory usage strategy of Linux system. Make the best use of memory. If the application needs memory, this memory will be immediately reclaimed and allocated to the application. Therefore, this part of memory is also generally considered as available memory. If the available memory is very small, the system may use the swap area (if configured), which increases IO overhead (which can be found in the iostat command) and reduces system performance.

View CPU usage mpstat

Display the occupancy of each CPU. If one CPU occupies a particularly high rate, it may be caused by a single-threaded application.

ubuntu@ubuntu:~$ mpstat -P ALL 1
Linux 4.2.0-16-generic (ubuntu)     04/30/2017  _x86_64_    (2 CPU)

10:57:30 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
10:57:31 PM  all    1.52    0.00    0.51    0.00    0.00    0.51    0.00    0.00    0.00   97.47
10:57:31 PM    0    3.03    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00   96.97
10:57:31 PM    1    0.00    0.00    0.00    0.00    0.00    1.02    0.00    0.00    0.00   98.98

Reading Comprehension

From Crime and Punishment

  • Everything will be used to such a despicable thing as man.
  • My only concern is whether our life tomorrow will be worthy of the suffering we are enduring today.
  • Bullshit is the only privilege of all living species that only humans enjoy. Truth can be gained through nonsense.
  • If you act with your conscience, you can bleed at all costs.
  • Poverty is not a sin, but extreme poverty is a sin.
  • I may not be a hero, but I want to be a warrior.

Classic Story

 
My husband and I were lucky enough to book tickets to my mother-in-law's house that day. Last time, we found a lady sitting in our seat. My husband motioned me to sit next to her first, but did not ask the lady to give up her seat. When I looked carefully, I found that her right foot was a little inconvenient, so I could understand why her husband didn't ask her to give up her seat. He just stood from Jiayi to Taipei, and did not tell the lady that this seat was his from beginning to end. After getting off the bus, I told him that it was good to give up my seat, but after such a long time from Jiayi to Taipei, she could ask her to give you back her seat and take a seat for you. "It's inconvenient for people to do so," he said. For a lifetime, it's not convenient for us to spend three hours. Hearing my husband say so, I am relatively touched, with such a kind and unknown good husband, let me feel that the world has become much more gentle. When the mind changes, the world may be different from now on. Everything in life has the ability to turn, depending on how we think and how we turn. ]

Great God Articles

How to Check Linux Server Performance with Commands
linux Server Performance View
18 Command Line Tools for Monitoring Linux Performance
Several simple commands to check Linux server performance
Check Linux Server Performance in One Minute with Ten Commands
Detailed Explanation of top Command Parameters of linux

Other

If there is a trace of happiness to you, let happiness continue to pass on. Welcome to praise, praise, and leave valuable comments, thank you for your support! ___________

Posted by fypstudent on Thu, 04 Jul 2019 14:12:29 -0700