You should know the 16 Linux server monitoring commands

  

In different Linux distributions, there will be different GUI programs that can display various system information, such as SUSE Linux distribution, there is a very good graphical The configuration and management tool YaST, the KDE System Guard in the KDE desktop environment is also very good.

However, for a Linux system administrator, such a GUI program will not run on a Linux server unless it is forced to do so, mainly because the GUI consumes a lot of system resources. So, using GUI tools is generally a simple troubleshooting, if you really want to know what really happens in the system, then please turn off your GUI, hurry into the world of Linux command line.

If you want to pursue the best performance, then the Linux server should run at runlevel 3, which supports network and multi-user functions, but does not support GUI functions. If you really need a GUI, you can type startx into the GUI at the command line.

If your Linux system is entering the GUI by default, you can adjust the configuration and let him enter runlevel 3 by default. The specific method is:
1 Open a terminal, su to the root account 2 Open the /etc/inittab file with your favorite editor (vi/emacs/...) 3 Find the initdefault keyword, and “ld:5” :initdefault:”Change to “id:3:initdefault:”

If there is no /etc/inittab file in the system, it doesn't matter, create this file directly and add a new line“id: 3”. In this case, if you restart the server, you will enter the command line state by default. Of course, if you only want to enter the command line state temporarily, then simply enter "ld";init 3” in the terminal.

At this point, our command line is ready, and we can start to see through powerful commands to see what happened in the server.:
[01 - iostat ][02/03 - Meminfo/free ][04 - mpstat ][05 - netstat ][06 - nmon ][07 - pmap ][08/09 - ps/pstree ][10 - sar ][11 - strace ][12 - tcpdump ][13 - top ][14 - uptime ][15 - vmstat ][16 - wireshark ]

[01 - iostat]

The iostat command shows the details of your storage system. . You can usually use this command to check if your storage device is working properly.

The system IO problem can be found through this command before the user complains that the server is slow.

As you can see, iostat can display both CPU usage and IO status of each disk.
# iostat 1Linux 2.6.32-220.4.1.el6.i686 (roclinux) December 22, 2012 _i686_ (4 CPU) avg-cpu: %user %nice %system %iowait %steal %idle0.55 0.00 0.03 0.02 0.00 99.40 Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtnsdb 0.41 2.61 5.76 2558664 5653872sda 0.24 0.80 4.12 784650 4038344

[02/03 - meminfo/free]

Meminfo provides very detailed memory usage. You can use the cat command to view:
cat /proc/meminfo

Of course, meminfo contains too much detail, you can use the free command to view a summary of the memory.
# free -mtotal used free shared buffers cachedMem: 1513 1429 83 0 343 836-/+ buffers/cache: 249 1263Swap: 0 0 0

[04 - mpstat]

mpstat is used on multiprocessor servers to display the status of each CPU.

In addition, mpstat will also display the average status of all processors.

You can set the CPU statistics for each server, or the CPU statistics for each process.
# mpstat -P ALLLinux 2.6.32-220.4.1.el6.i686 (roclinux) December 22, 2012 _i686_ (4 CPU) 17:46:35 CPU %usr %nice %sys %iowait % Irq %soft %steal %guest %idle17°46 minutes 35 seconds all 0.55 0.00 0.03 0.02 0.00 0.00 0.00 0.00 99.4017°46 minutes 35 seconds0 0.84 0.00 0.04 0.03 0.00 0.01 0.00 0.00 99.0817 hours 46 minutes 35 seconds 1 0.51 0.00 0.03 0.02 0.00 0.00 0.00 0.00 99.4417 hours 46 minutes 35 seconds 2 0.45 0.00 0.02 0.01 0.00 0.00 0.00 0.00 99.5117 hours 46 minutes 35 seconds 3 0.40 0.00 0.02 0.01 0.00 0.00 0.00 0.00 99.56 # mpstat -P 0Linux 2.6.32-220.4.1.el6.i686 (roclinux) December 22, 2012 _i686_ (4 CPU) 17:46:39 CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle17°46 minutes 39 seconds0 0.84 0.00 0.04 0.03 0.00 0.01 0.00 0.00 99.08

The meaning of each field is as follows:
1 CPU: processor number, if all, this line represents the statistical average of all processors 2 %usr: user mode CPU utilization 3% nice: user state CPU utilization with scheduling priority 4% sys: kernel state CPU utilization (this value does not include responsive hardware The time of the break and software interrupt) 5% iowait: the percentage of time that the IO request causes the CPU to be in the IDLE state. 6 %irq: the ratio of the time the CPU responds to the hardware interrupt. 7 %soft: the ratio of the time the CPU responds to the software interrupt 8% steal: when virtual The passive wait time ratio of the virtual CPU when serving the other virtual processors is 9 % guest: the ratio of CPU time consumed by running a virtual processor

[05 - netstat]

The netstat command is a command that Linux system administrators use almost every day (it has been gradually replaced by the ss command). He can display a lot of information about the network, such as socket usage, routing, and network card conditions. , protocol status, network traffic statistics, and more.

Some common netstat options include:
-a : Display all socke information -r : Display routing information -i : Display network card interface statistics -s : Display network protocol statistics

[ ,null,null,3],06 - nmon]

nmon is the abbreviation of Nigel&squo;s Monitor, a well-known tool for monitoring the performance of Linux systems.

nmon can view processor utilization, memory usage, run queue information, disk IO statistics, network IO statistics, page break statistics, and more.

You can view this information through a curses-based GUI interface.


nmon Monitoring Tool

Copyright © Windows knowledge All Rights Reserved