16 Linux Server Monitoring commands you need to know _linux

Source: Internet
Author: User
Tags memory usage cpu usage
Some Linux distributions provide GUI programs for system monitoring, such as SUSE Linux has a great and professional tool yast,kde the 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 take up a lot of system resources, so although the GUI is good for basic server health monitoring, if you want to know what really happens, turn off the GUI and start the command line.

You should just start the GUI when you need it and turn it off when you're not using it. If you want the server to maintain optimal performance, you should set the Linux server run level runlevel to 3, the console mode, and use the STARTX command to start it when you need a graphical desktop.

If your server is launched directly into the graphical interface, you need to modify the configuration/etc/inittab find Initdefault, Id:5:initdefault modified to Id:3:initdefault.

If you don't find the/etc/inittab file, create a new one, add the contents of the file Id:3 such a line. This will not go into the graphics interface the next time the server starts. 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 with what we're going to do next.

Iostat

The Iostat command is used to display detailed information about the storage subsystem, which is typically used to monitor disk I/O. Pay special attention to the%iowait value in the iostat statistic, too large to indicate that your system storage subsystem is performing poorly.

Meminfo and free

Meminfo allows you to get detailed information about the memory, and you can use the cat and grep commands to display meminfo information:

1cat/proc/meminfo

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

Mpstat

  Mpstat Mpstat is an abbreviation of multiprocessor statistics, a real-time system monitoring tool. Some statistical information about the report and CPU, which is stored in the/proc/stat file. In a CPUs system, it is not only possible to view the average information of all CPUs, but also to view information about a particular CPU.

Refer to this post for parameter meaning in Mpstat execution results.

Netstat

The Netstat and PS commands are similar to the tools that Linux administrators use almost every day, showing a lot of information related to the web, such as the use of sockets, routing, interfaces, protocols, networks, and so on, and here are some common parameters:

1-A Show All socket information

2-r Show Routing information

3-i Show Network Interface statistics

4-s Show Network Protocol statistics

Nmon

Nmon, an acronym for Nigel's Monitor, is a popular open-source tool to monitor the performance of Linux systems. Nmon monitors performance data for multiple subsystems, such as processor usage, memory usage, 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, then select the subsystems to monitor, these subsystems should have a shortcut key, such as input C to view CPU information, M used to view memory, D used to view disk information, etc., you can also use the-f command to save Nmon execution results to a CSV file To facilitate the analysis in the future.

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

Pmap

The PMAP command is used to report details of the memory consumed by each process, and can be used to see if there is a process overrun, which requires a process ID as an argument.

PS and Pstree

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

Sar

The SAR program is the Swiss Army knife in the system monitoring tool. The program contains three tools: The SAR is used to display data, and 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 disk device activity details. The biggest difference between SAR and Nmon is that 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 programmers to debug, but 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 sparingly.

Tcpdump

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

Top

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

Uptime

The uptime command tells you how long the server has been running from boot up to now. 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 statistical information about kernel threads, virtual memory, disks, traps, and CPU activity. Reports generated by the Vmstat command can be used to balance system load activities. The system-wide statistics (in all processors) calculate the average as a percentage, or calculate the sum.

Wireshark

Wireshark, formerly known as Ethereal, is a network protocol detection program, allowing you to crawl the operation of the Web site related information, including each packet flow and its contents, information according to the operating system to see, easy to view, monitor TCP session dynamics and so on.

  

Here's a list of most valuable Linux monitoring programs, and of course, you might use other tools to share

-->

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.