Linux Server monitoring and linux Server monitoring
Overview
This article mainly describes how to monitor information such as I/O, CPU, disk, and memory using linux commands.
Directory
- IO and CPU monitoring
- Other Monitoring
- Memory
- Disk
- Process
- System Load
- Summary
Iostat command for IO and CPU monitoring
It is mainly used to monitor the IO load of system devices.
View Command help
Iostat -- help
[-C] [-d] [-N] [-n] [-h] [-k |-m] [-t] [-V] [-x] [-z] [<device> [...] | ALL] [-p [<device> [,...] | ALL]
Iostat
Linux 2.6.32-71. el6.x86 _ 64 (localhost. localdomain) December 24, 2015 _ x86_64 _ (1 CPU)
Avg-cpu: % user % nice % system % iowait % steal % idle
1.98 0.00 0.80 3.04 0.00 94.18
% User: CPU usage
% Nice: the percentage of CPU used by the nice operation.
% System: CPU usage percentage of the Operating system
% Iowait: Percentage of CPU used by IO operations such as CPU. This value increases when the disk IO is large.
% Steal: Percentage of CPU used by the VM
% Idle: Percentage of CPU idle time
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
Sda 17.78 128.39 1107.66 9968098 86000772
Tps: the number of I/O requests sent per second (which can be understood as the number of disk I/O requests processed per second, which may be better understood) Blk_read/s: The number of blocks read per second
Blk_wrtn/s: number of blocks written per second
Blk_read: Total number of read Blocks
Blk_wrtn: Total number of blocks written
-C parameters:
Divided into the CPU status, that is, the CPU part above
-D parameters
Analyzes the status of the disk Device, that is, the Device section above.
-N Parameter
Analyze the file system status
Filesystem: rBlk_nor/s wBlk_nor/s rBlk_dir/s wBlk_dir/s rBlk_svr/s wBlk_svr/s ops/s rops/s wops/s
[-N or-h] Parameters
The difference between iostat and iostat is mainly the device part. Here, the device reads and writes bytes per second. The default value is kB.
Avg-cpu: % user % nice % system % iowait % steal % idle
2.06 0.00 0.82 3.09 0.00 94.03
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
Sda 18.20 65.63 556.45 5169933 43834154
KB_read/s: Number of KB read from the device per second
KB_wrtn/s: Number of KB written to the device per second
KB_read: the number of KB read from the device per second.
KB_wrtn: the number of KB written to the device per second.
[-K |-m] Parameter
Unit: KB and MB. The default unit is KB. It is used for disk analysis.
For example, iostat-d-M (displayed in MB)
Device: tps MB_read/s MB_wrtn/s MB_read MB_wrtn
Sda 18.65 0.06 0.55 5102 43654
-T Parameter
Display time
December 24, 2015
Avg-cpu: % user % nice % system % iowait % steal % idle
2.07 0.00 0.83 3.17 0.00 93.94
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
Sda 18.59 131.96 1128.88 10450530 89403980
[-V or-Z] Parameters
No special features found
-X Parameters
Displays CPU and device information in the most detail.
Avg-cpu: % user % nice % system % iowait % steal % idle
2.06 0.00 0.83 3.16 0.00 93.96
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm % util
Sda 1.58 125.86 2.49 16.04 131.51 1124.71 67.80 0.41 22.29 2.69 4.98
There is no change in the CPU part. Here we mainly look at the device part:
Rrqm/s: the number of read requests sent to the device per second after the read requests are merged.
Wrqm/s: Number of write requests sent to the device per second after the write requests are merged.
R/s: The number of read requests sent to the device per second.
W/s: the number of write requests sent to the device per second.
Rsec/s: number of sectors read from the device per second.
Wsec/s: number of sectors written to the device per second.
RkB/s: the amount of data read from the device per second. Unit: K.
WkB/s: the amount of data written to the device per second. The unit is K.
Avgrq-sz: Average size of the request sent to the device, in the unit of sector.
Avgqu-sz: average queue length of requests sent to devices.
Await: average execution time of I/O requests, including the time for sending and executing requests. Unit: milliseconds.
Svctm: the average execution time of the I/O requests sent to the device. The unit is milliseconds.
% Uti: Percentage of CPU time consumed when I/O requests are sent to the device. This is used to display the bandwidth usage of the device.
When the value is close to 100%, the bandwidth of the device is full.
-P Parameter
Analyzes specified devices, such as sda and sdb.
Iostat-p sda
Avg-cpu: % user % nice % system % iowait % steal % idle
2.05 0.00 0.82 3.13 0.00 93.99
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
Sda 18.40 130.78 1116.56 10472250 89406772
Sda1 0.01 0.07 0.00 28
Sda2 16.72 118.34 1089.36 9476202
Sda3 0.36 12.36 27.20 989616
Common usage:
Display Device and CPU status, print once per second, and display time
Iostat-x-k-t 1
Displays the device and CPU status, once per second, 10 times, and time
Iostat-x-k-t 1 10
Displays the sda and CPU status of the device, once per second, 10 times, and time
Iostat-x-k-t-p sda 1 10
Other monitoring memory
Free command
View the/etc/proc/meminfo File
Disk
Df command
View the cat/etc/proc/diskstats File
Process
Top Command
/Etc/proc
There are files for each process.
System Load
Uptime command
10:18:23 up, 3 users, load average: 0.00, 0.00, 0.79
- 10:18:23 current time
- The system has been running for 22 hours and 43 minutes.
- Current online user 3 user
- Average load: 0.00, 0.00, 0.79 system load in the last 1 minute, 5 minutes, 15 minutes
View files
Cat/proc/loadavg
0.00 0.00 0.70 1/317 41562
In addition to the first three digits, the number of processes on average is counted as the number of processes in the system. The denominator represents the total number of processes in the system and the numerator represents the number of processes in the running state. The last digit represents the ID of the most recently running process.
The average system load is definedAverage number of processes in the running queue within a specific interval. If a process meets the following conditions, it will be in the running queue:
- It has no results waiting for I/O operations
- It does not take the initiative to enter the waiting status (that is, it does not call 'wait ')
- Not stopped (for example, waiting for termination)
Generally, if the number of active processes per CPU core is no greater than 3, the system runs well! Of course, this is about every cpu kernel, that is, if your host is a quad-core cpu, as long as the number of characters output by uptime is smaller than 12, the system load is not very serious. of course, if it reaches 20, it indicates that the current system load is very serious. It is estimated that the web script is very slow to be opened.
Uptime part from: http://www.cnblogs.com/kaituorensheng/p/3602812.html
Summary
The commands that come with linux are quite good for daily monitoring. Of course, there are also a lot of third-party tools, such as the dstat tool for monitoring IO, the usage of the dstat tool will be discussed separately later.
I hope the article will help more people and help them. Thank you !!!
Note: Author: pursuer. chen Blog: http://www.cnblogs.com/chenmh All essays on this site are original. You are welcome to repost them. However, you must indicate the source of the article and clearly provide the link at the beginning of the article. Otherwise, you will be held accountable. Welcome to discussion |