16 Linux Server monitoring commands to know

Source: Internet
Author: User
Tags cpu usage

If you want to know what your server is doing, you need to know some basic commands, and once you've mastered these commands, you're a professional Linux system administrator.

Some Linux distributions provide GUI programs to monitor the system, for example, SUSE Linux has a great and professional tool Yast,kde KDE system Guard is also excellent. Of course, to use these tools, you have to operate in front of the server, and these GUI programs occupy a lot of system resources, so, although the GUI used to do basic server health monitoring is good, but if you want to know what really happens, please turn off the GUI to start the command line tour.

You should start the GUI only when you need it and turn it off when you don't. If you want to keep your server running at peak performance, you should set the Linux server's RunLevel runlevel to 3, which is the console mode, and use the STARTX command to start it when you need a graphical desktop.

If your server starts up and goes directly to the graphical interface, you need to modify the configuration/etc/inittab find Initdefault, and change Id:5:initdefault to Id:3:initdefault.

If you do not find the/etc/inittab file, create a new one, add Id:3 to the file content. This will not enter the graphical interface the next time the server is started. If you don't want to wait until the server restarts, you can execute the init 3 command.

Once your server is running in console mode, you can start our next content.

Iostat

The Iostat command is used to display detailed information about the storage subsystem, which is typically used to monitor disk I/O conditions. Pay particular attention to the%iowait values in the IOSTAT statistics, which is too large to indicate that your system storage subsystem is performing poorly.

Meminfo and free

Meminfo allows you to get the details of the memory, you can use the cat and grep commands to display the Meminfo information:

1 cat /proc/meminfo

In addition, you can use the free command to display dynamic memory usage information, which gives you approximate memory information, and Meminfo provides more detailed information.

Mpstat

Mpstat Mpstat is the abbreviation of multiprocessor statistics and is a real-time system monitoring tool. Some statistical information about its report and CPU, which is 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.

Netstat

Similar to the PS command, Netstat is a tool that Linux administrators use almost every day, and it shows a lot of network-related information, such as socket usage, routing, interfaces, protocols, networks, and so on, which are some common parameters:

1 2 3 4 -a Show all socket information -r Show routing information -i Show network interface statistics -s Show network protocol statistics

Nmon

Nmon, the abbreviation for Nigel's monitor, is a popular open source tool for monitoring the performance of Linux systems. Nmon monitors performance data for multiple subsystems, such as processor usage, memory utilization, queues, disk I/O statistics, network I/O statistics, memory page processing, and process information. Nmon also provides a graphical tool:

To run Nmon, you can start it on the command line, and then select the subsystems you want to monitor, which have a shortcut key such as input C to view CPU information, m for memory, D to view disk information, and so on, you can also use the-f command to save Nmon execution results to a CSV file To facilitate future analysis.

In the daily monitoring work, I found that Nmon is my most used tool.

Pmap

The PMAP command is used to report the details of how each process consumes memory and can be used to see if there is a process overrun, which requires a process ID as a parameter.

PS and Pstree

The PS and Pstree commands are the best friends of Linux system administrators and can be used to list all processes that are running. PS tells you how much memory and CPU processing time is consumed by each process, and the information displayed by Pstree is less detailed, but it displays a tree structure of dependencies between processes, including child process information. Once you find a problem with a process, you can use kill to kill it.

Sar

The SAR program is the Swiss Army knife in the system monitoring tool. The program consists of three tools: the SAR is used to display data, SA1 and SA2 are used to collect data and save it. SAR can be used to display CPU usage, memory page data, network I/O and transport statistics, process creation activity, and activity details for disk devices. The biggest difference between SAR and Nmon is that the SAR is suitable for long-term monitoring, and nmon allows you to quickly understand the current state of the system.

Strace

Strace is often considered a tool for programmer debugging, but it is more than that. It can record the details of a process making a system call, so it is also a good diagnostic tool, such as you can use to find out if a program is opening a configuration file.

Strace also has a flaw, but it makes the performance of the process very poor when it tracks a process, so use it with caution.

Tcpdump

Tcpdump is a simple, reliable network monitoring tool used to perform basic protocol analysis to see which processes are using the network and how to use it. Of course, if you want to get detailed information, you should use Wireshark (below we will introduce).

Top

The top command displays the current active process, which, by default, is sorted by the severity of the CPU consumed, refreshes the list every 5 seconds, and you can choose a different sort method, for example, M is a shortcut key to sort by memory footprint.

Uptime

The uptime command tells you how long this server has been running since booting up to the present time. It also contains the average load from boot to current server.

Vmstat

You can use Vmstat to monitor virtual memory, and developers on Linux generally prefer to use virtual memory for optimal storage performance. This command reports statistics about kernel threads, virtual memory, disks, traps, and CPU activity. Reports generated by the Vmstat command can be used to balance system load activity. These system-wide statistics (all processors) calculate the average as a percentage, or calculate its sum.

Wireshark

Wireshark, formerly known as Ethereal, is a network protocol detection program that allows you to capture information about the running website through the program, including the flow of each packet and its contents, information can be seen by the operating system language, convenient to view, monitor the TCP session dynamic and so on.

Here is a list of most of the most valuable Linux monitoring programs, of course, you might also use other tools, may wish to share with you.


16 Linux Server monitoring commands to know

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.