depending on which Linux distribution you use, you can get a lot of information from these shell commands through a graphical user interface (GUI) program. For example, SUSE Linux has an excellent, graphical configuration and management tool YAST,KDE KDE System guard.
However, a common sense for Linux administrators is that the GUI should be run on the server only if absolutely necessary. That's because the Linux GUI consumes system resources that could have been used more rationally elsewhere. So, although using GUI programs is good for a basic check of server health, if you want to know what's going on, turn off the GUI and start using the tools from the Linux command shell.
This also means that you should open the GUI on the server as long as it is needed, and turn it off when not in use. To ensure optimal performance, the Linux server should run at run level (RunLevel) 3, which fully supports the network and multiple users, but does not turn on the GUI when the machine is booted. If you really need a graphical desktop, you can always run StartX from the shell prompt to get a graphical desktop.
If your server starts up and goes to the graphical desktop, you will need to change this situation. To do this, go to the terminal window, use the SU command to switch to the root user, and then open the/etc/inittab file with your favorite editor.
Once inside the file, find Initdefault this line, will Id:5:initdefault: Changed to Id:3:initdefault:.
If you do not have a/etc/inittab file, create one and add the Id:3 line. Exit after saving. The next time you boot into the server, it will boot into RunLevel 3. If you do not want to restart after making this change, you can also use command init 3 to set the server's runlevel immediately.
Once your server is running under init 3, you can start using the following shell to see what's happening in your server.
Iostat
The Iostat command shows the storage subsystem in detail. You typically use Iostat to monitor the overall health of the storage subsystem, and to detect slow input/output problems before the user notices that the server is running slowly. Believe me, you should find these problems before users find them!
meminfo and freE
Meminfo shows you the memory situation in detail. You can usually use another program, such as Cat and grep, to access the Meminfo information. For example, Cat/proc/meminfo shows you the usage of the server's memory at any one time in detail.
You can use the free command if you want to get a quick overview of the memory. In short, free gives you a summary of the information, and Meminfo provides you with detailed information.
Mpstat
The Mpstat command can report the activity of each processor available on a multiprocessor server. Today, because of multicore processors, this command is available for almost any server. Mpstat can also report the average activity of processors on all servers. It allows you to display the total processor statistics by system or by processor. This profile can alert you to potential application problems before they annoy users.
Netstat
Netstat, like PS, is the Linux tool that Linux administrators use every day. It shows a large amount of information about the network, such as the set of interface usage, routing, interfaces, protocols, network statistics, and more. Some of the most common options are as follows:
-A display all information of the socket interface
-R Display Routing information
-I display statistics for network interfaces
-S displays statistics for network protocols
Nmon
Nmon is the abbreviation for Nigel's Monitor, a popular open source tool used to monitor the performance of Linux systems. Nmon can monitor performance information for multiple subsystems, such as processor utilization, memory usage, run queue information, disk input/output statistics, network input/output statistics, memory paging activity, and process metrics. You can then view Nmon's real-time system measurements by curses the "graphical" interface.
To run Nmon, you can start the tool from the shell. Once started, you can choose which subsystem to monitor by simply entering a single-touch command. For example, to get statistics on the processor, memory, and disk, just enter C, M, and D respectively. You can also use Nmon with the-f flag to save performance statistics to a CSV file for later analysis.
In terms of daily server monitoring, I think Nmon is one of the most useful programs in my Linux System Management Toolkit.
Pmap
The PMAP command is used to report the amount of memory used by the server's process. You can use this tool to determine which processes on the server are allocated memory, and who is using memory in a large number of these processes.
PS and Pstree
The two commands for PS and Pstree are the two right-hand assistants for Linux system administrators. They all display all currently running processes in the form of a list. PS can tell you how much memory and processor time the server's program is using. Pstree displays less information, but highlights which processes are child processes of other processes. With this information in hand, you will be able to detect runaway processes and then use the Linux Kill command with no survivors to terminate these processes.
Sar
The SAR program is like a Swiss Army knife in the field of system monitoring tools. The SAR command actually consists of three programs: the SAR that displays the data, the SA1 that collects the data, and the SA2 that holds the data. Once installed, the SAR generates detailed profile information, showing processor usage, memory paging activity, network input/output and transport statistics, process creation activity, and disk device activity. One big difference between SAR and Nmon is that the former is more suitable for long-term monitoring systems, and I think Nmon is better suited to help me quickly check the health of the server.
Strace
Strace is often considered a programmer's debugging tool, but its function is not just for debugging. It can intercept and record the situation of the process calling system. Thus, it is a practical tool for diagnosis, teaching and debugging. For example, you can use Strace to find out which profile a program actually uses when it starts.
But Strace does have a flaw. When it checks a process, the performance of the process is plummeted. Therefore, the use of strace is only possible if I have had very good reason to think that a program is causing problems.
Tcpdump
The tcpdump is a simple and reliable network monitoring utility. Its basic protocol analysis feature gives you a rough view of what's happening on your network. But to really delve into the network, you should use Wireshark (described below).
Top
The top command shows the status of the active process. By default, it shows the most processor-intensive tasks running on the server, and refreshes the list every 5 seconds. You can also classify processes by multiple criteria, such as PID (process ID), age, the latest column at the top, time, by cumulative time, and the total time it takes to host memory usage and use the processor since startup. I think it provides a quick and easy way to see if any process is starting to get out of control and causing problems.
Uptime
Uptime can be used to see how long a server has been running and how many users are logged on. It also shows a summary of the server's average load. The optimal value for the load is 1 or less, which means that each process can immediately access the processor and there is no case of processor cycle loss.
Vmstat
In general, you can use Vmstat to monitor virtual memory. Linux is constantly using virtual memory to achieve optimal storage performance.
If your application is consuming too much memory, you will experience frequent swapping out of memory (page-out)-The swap space from memory to the system hard drive. Your server may go into this phase: it spends more time managing memory paging than it spends on running applications-this is known as jitter (thrashing). When your computer shakes, performance is plummeted. Vmstat can display average data or actual samples, which can help you discover a lot of memory-consuming programs and processes, lest they cause the server to run like a snail.
Wireshark
Wireshark, previously known as ethereal (and still often called this), is Tcpdump's similar tool, but it is more advanced and has much more advanced protocol analysis and reporting capabilities. Wireshark has both GUI interface and Shell interface. If you are engaged in professional-level network management, you can only use ethereal. And if you're using wireshark/ethereal, I'd highly recommend reading the "Practical Packet Analysis" by Chris Sander, Practical Packet, which provides an easy way to make the most of the utility.
16 Monitoring commands for CentOS server