How to view the Linux system load

How to view the Linux system load
 

The operating system load status, reflecting the resource usage of the application, which can find applications to optimize bottlenecks.

The average load on the system, means the average number in operation or not to disturb the state of the process. \
In operation, it indicates the operating state, occupying CPU, or ready state, waiting for CPU scheduling. \
Not bother to indicate blocked waiting for I / O

On Linux systems, typically used to view the load uptime command (w command and also the top command line) *

A, uptime command

$ uptime\
16:33:56 up 69 days,  5:10,  1 user,  load average: 0.14, 0.24, 0.29

Resolve the above information as follows:

  • 16:33:56: current time
  • up 69 days, 5:10: the system is running 69 days 5 hours 10 minutes
  • 1 user: a user currently logged into the system load average: 0.14, 0.24, 0.29: in the last 1 minute, 5 minutes, within 15 minutes of the average load system
  • load average: 0.14, 0.24, 0.29: the system in the last 1 minute, 5 minutes, within 15 minutes of the average load

The average load resolved

View logical CPU cores:

$ grep 'model name' /proc/cpuinfo | wc -l\
1\

Operating results indicated that there is a logical CPU core. With one CPU core, for example, assume that the CPU processes up to 100 per minute -

  • load = 0, the process requires no CPU
  • load = 0.5, CPU 50 processes the processing
  • load = 1, CPU processing the 100 process, when the CPU has been filled, but the system can still operate smoothly
  • load = 1.5, CPU processing the 100 process, there are 50 processes are waiting for CPU processing excluded, then, CPU already overworked.

For systems running smoothly, load value should not exceed 1.0, and so there is no need to wait for the process, the first time all processes can be dealt with. \
Obviously, 1.0 is a critical value, above this value, the system is not in the best condition. General 0.7 is an ideal value. \
In addition, the health status of load values even went to a few core CPU system-related, if the CPU core number is 2, then the value of the health value of the load should be 2, and so on. \
Load evaluation system commonly used in the average load value of 15 minutes.

Two, w command

$ w\
 17:47:40 up 69 days,  6:24,  1 user,  load average: 0.46, 0.26, 0.25\
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT\
lvinkim  pts/0    14.18.144.2      15:55    0.00s  0.02s  0.00s w

Line 1: the same as a uptime. \
Line 2 or less, a list of users currently logged on.

Three, top command

$ top\
top - 17:51:23 up 69 days,  6:28,  1 user,  load average: 0.31, 0.30, 0.26\
Tasks:  99 total,   1 running,  98 sleeping,   0 stopped,   0 zombie\
Cpu(s):  2.3%us,  0.2%sy,  0.0%ni, 97.4%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st\
Mem:   1922244k total,  1737480k used,   184764k free,   208576k buffers\
Swap:        0k total,        0k used,        0k free,   466732k cached\
\
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                \
    1 root      20   0 19232 1004  708 S  0.0  0.1   0:01.17 init                                                                    \
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.01 kthreadd                                                                \
...

Line 1: the same as a uptime.

Line 2: Number of process information.

  • Tasks: 99 total: A total of 99 process
  • 1 running: 1 of processes are CPU-intensive
  • 98 sleeping: 98 -th sleep process
  • 0 stopped: 0 stop the process
  • 0 zombie: 0 zombie process

Line 3: CPU usage

  • us (user): Non-nice user process CPU occupancy rate of
  • sy (system): the kernel, the kernel process CPU ratio
  • ni (nice): within the space of a user process changed the priority of process CPU ratio
  • id (idle): CPU idle ratio, if this value is high and the system is slow, slow system described not because of high CPU load
  • wa (iowait): CPU waits for performing I / O operation time ratio, troubleshoot disk I / O issue the indicators it could be used, and generally binding wa determined id
  • hi (Hardware IRQ): CPU hardware interrupt processing time of the share ratio
  • si (Software Interrupts): CPU processing software interrupt time percentage rate
  • st (steal): elapsed time for other tasks, the virtual machine's CPU time share ratio

Some situations require attention:

  • High proportion of us user process, low I / O operations wa: explanation of reasons slow system is that the process takes a lot of CPU, usually will be accompanied by teaching low idle ratio id, description CPU idle time is small.
  • Low I / O operation wa, high idle rate id: can rule out the possibility of a bottleneck CPU resources.
  • I / O operations wa high: Description I / O takes a lot of CPU time required to check the use of swap space, swap space on disk, memory performance is far lower than when the memory is exhausted started swap space, will give a serious impact on performance, so the high performance requirements of servers, is generally recommended to close swap space. On the other hand, if enough memory, but wa very high, the need to check which process takes up a lot of I / O resources.

More load situation can be flexibly determined in practice.

Four, iostat command

iostat command to view the system partition IO usage

$ iostat \
Linux 2.6.32-573.22.1.el6.x86_64 (sgs02)   01/20/2017     _x86_64_   (1 CPU)\
\
avg-cpu:  %user   %nice %system %iowait  %steal   %idle\
           2.29    0.00    0.25    0.04    0.00   97.41\
\
Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn\
vda               1.15         3.48        21.88   21016084  131997520

Some notable IO indicators:

  • Device: Disk Name
  • tps: I / O per second transmission request amount
  • Blk_read / s: how many pieces read per second, the block size view command tune2fs
  • Blk_wrtn / s: second block number writing take
  • Blk_read: total number of blocks read
  • -Blk_wrtn: wrote a total of how many blocks

Five, iotop command

iotop top command similar to the command, the display of the I / O process each case, for the positioning of heavy I / O operation process has a relatively large effect. \

# iotop\
Total DISK READ: 0.00 B/s | Total DISK WRITE: 774.52 K/s\
  TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN     IO>    COMMAND                                                                \
  272 be/3 root        0.00 B/s    0.00 B/s  0.00 %  4.86 % [jbd2/vda1-8]\ 9072 be/4 mysql 0.00 B/s 268.71 K/s 0.00 % 0.00 % mysqld\ 5058 be/4 lvinkim 0.00 B/s 3.95 K/s 0.00 % 0.00 % php-fpm: pool www\ 1 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % init

You can see the strength of the different tasks of reading and writing.

Six, sysstat tools

Many times when detected or known history of high load conditions, you may need to replay historical monitoring data, then the sar command comes in handy, also from the sar command sysstat toolkit can record the load on the system CPU, I / O status and memory usage records, facilitate the playback of historical data.

sysstat configuration files in / etc / sysconfig / sysstat document, storage location history log is / var / log / sa \
statistics are recorded once every 10 minutes, every day 23:59 statistics will split the file, the frequency of these operations /etc/cron.d/sysstat are configured in the file. \

Seven, sar command

Use the sar command to check CPU usage that day:

$ sar\
Linux 2.6.32-431.23.3.el6.x86_64 (szs01)   01/20/2017     _x86_64_   (1 CPU)\
\
10:50:01 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle\
11:00:01 AM     all      0.45      0.00      0.22      0.40      0.00     98.93\
Average:        all      0.45      0.00      0.22      0.40      0.00     98.93

Use the sar command to view memory usage that day:

$ sar -r\
Linux 2.6.32-431.23.3.el6.x86_64 (szs01)   01/20/2017     _x86_64_   (1 CPU)\
\
10:50:01 AM kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit\
11:00:01 AM     41292    459180     91.75     44072    164620    822392    164.32\
Average:        41292    459180     91.75     44072    164620    822392    164.32

Use the sar command to see the day IO statistics record:

$ sar -b\
Linux 2.6.32-431.23.3.el6.x86_64 (szs01)   01/20/2017     _x86_64_   (1 CPU)\
\
10:50:01 AM       tps      rtps      wtps   bread/s   bwrtn/s\
11:00:01 AM      3.31      2.14      1.17     37.18     16.84\
Average:         3.31      2.14      1.17     37.18     16.84

More sar usage, man sar.

Fly to see that he is not a programmer, try to do the title. https://job.xyh.io

Guess you like

Origin www.cnblogs.com/xuanbjut/p/11988729.html