18 command line tools for Linux performance monitoring

Source: Internet
Author: User

Daily monitoring and debugging of Linux system performance is a heavy task for the system and network administrators. Five years after working as a Linux system administrator in the IT field, I gradually realized how difficult IT is to monitor and keep the system up and running. For this reason, we have compiled the list of 18 most commonly used command line tools that will help every Linux/Unix system administrator. These command line tools can be used in various Linux systems to monitor and find the causes of performance problems. This command line tool list provides enough tools for you to select a tool suitable for your monitoring scenario.

1. Top-Linux Process Monitoring

The Top command in Linux is a performance monitoring program. Many System Administrators often use it to monitor Linux performance. This command is available in many Linux or Unix-like operating systems. The Top command is used to display all running and Active Real-Time Processes in a certain order, and regularly update the display results. This command displays the CPU usage, memory usage, swap memory usage, Cache Usage, buffer usage, process PID, commands used, and others. It can also display the memory and CPU usage of running processes. For the system administrator, the top command is very useful. It can be used to monitor the system and take correct actions when necessary. Let's take a look at the top command in practice.

# top

For more examples of Top commands, see the following 12 examples of using Top commands in Linux.

2. VmStat-Virtual Memory statistics

The VmStat command in Linux is used to display statistics of virtual memory, kernel threads, disks, system processes, I/O blocks, interruptions, and CPU activity. By default, the vmstat command is unavailable in Linux. You need to install a sysstat package containing the vmstat program. Common usage of command format is:

 
 
  1. [root@ithomer ~]# vmstat 
  2. procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu----- 
  3.  r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st 
  4.  0  0      0 105368  90900 257588    0    0     9    33    4   11  2  0 97  0  0 

For more examples of vmstat, see Vmstat command instances in Linux 6.

3. Lsof-list opened files

In many Linux or Unix-like systems, lsof commands are commonly used to display all open files and processes in a list. Open files include disk files, network sockets, pipelines, devices, and processes. One of the main cases of using this command is when the disk cannot be mounted and an error message is displayed that is in use or a file is opened. Using this command, you can easily see which file is being used. The most common format of this command is as follows:

 
 
  1. # lsof 
  2. COMMAND     PID      USER   FD      TYPE     DEVICE     SIZE       NODE NAME 
  3. init          1      root  cwd       DIR      104,2     4096          2 / 
  4. init          1      root  rtd       DIR      104,2     4096          2 / 
  5. init          1      root  txt       REG      104,2    38652   17710339 /sbin/init 
  6. init          1      root  mem       REG      104,2   129900     196453 /lib/ld-2.5.so 
  7. init          1      root  mem       REG      104,2  1693812     196454 /lib/libc-2.5.so 
  8. init          1      root  mem       REG      104,2    20668     196479 /lib/libdl-2.5.so 
  9. init          1      root  mem       REG      104,2   245376     196419 /lib/libsepol.so.1 
  10. init          1      root  mem       REG      104,2    93508     196431 /lib/libselinux.so.1 
  11. init          1      root   10u     FIFO       0,17                 953 /dev/initctl 

For more information about the usage and examples of lsof commands, see 10 examples of lsof commands in Linux.

4. Tcpdump-network package analyzer

Tcpdump is one of the most widely used network packet analyzer or package monitoring programs. It is used to capture or filter TCP/IP packets received or transmitted on a specified interface on the network. It also has an option to save the captured package to the file for later analysis. Tcpdump can be used in almost all major Linux releases.

 
 
  1. # tcpdump -i eth0tcpdump: verbose output suppressed, use -v or -vv for full protocol decode 
  2. listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes 
  3. 22:08:59.617628 IP tecmint.com.ssh > 115.113.134.3.static-mumbai.vsnl.net.in.28472: P 2532133365:2532133481(116) ack 3561562349 win 9648 
  4. 22:09:07.653466 IP tecmint.com.ssh > 115.113.134.3.static-mumbai.vsnl.net.in.28472: P 116:232(116) ack 1 win 9648 
  5. 22:08:59.617916 IP 115.113.134.3.static-mumbai.vsnl.net.in.28472 > tecmint.com.ssh: . ack 116 win 64347 

For more information about tcpdump usage, see 12 examples of using Tcpdump commands in Linux.

5. Netstat-network status statistics

Netstat is a command line tool used to monitor inbound and outbound packets and network interface statistics. It is a very useful tool that the system administrator can use to monitor network performance, locate and solve network problems.

 
 
  1. # netstat -a | moreActive Internet connections (servers and established) 
  2. Proto Recv-Q Send-Q Local Address               Foreign Address             State 
  3. tcp        0      0 *:mysql                     *:*                         LISTEN 
  4. tcp        0      0 *:sunrpc                    *:*                         LISTEN 
  5. tcp        0      0 *:realm-rusd                *:*                         LISTEN 
  6. tcp        0      0 *:ftp                       *:*                         LISTEN 
  7. tcp        0      0 localhost.localdomain:ipp   *:*                         LISTEN 
  8. tcp        0      0 localhost.localdomain:smtp  *:*                         LISTEN 
  9. tcp        0      0 localhost.localdomain:smtp  localhost.localdomain:42709 TIME_WAIT 
  10. tcp        0      0 localhost.localdomain:smtp  localhost.localdomain:42710 TIME_WAIT 
  11. tcp        0      0 *:http                      *:*                         LISTEN 
  12. tcp        0      0 *:ssh                       *:*                         LISTEN 
  13. tcp        0      0 *:https                     *:*                         LISTEN 

For more examples of Netstat, see 20 examples of using the Netstat command in Linux.

6. Htop-Linux Process Monitoring

Htop is a very advanced interactive real-time linux Process Monitoring Tool. It is very similar to the top command, but it has more features, such as user-friendly management of processes, shortcut keys, vertical and horizontal display processes and so on. Htop is a third-party tool that is not included in the linux system. You need to install it using the YUM package management tool.

CentOS command installation: yum install htop,

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.