3 linux system detection tool

layout: POST
title: detection means. 3 of Linux systems
the Categories: Linux
Description: Linux, system monitoring tools
keywords: linux, top, vmstat, w


Foreword

Use Linux systems also have a long period of time, with little thought to monitor server performance, you want to write this blog also want in this way from the knowledge of these pieces recorded, and try its built-in commands and some additional tools.

These tools provide acquisition system activities related indicators, possible causes can use these tools to find new energy issues, then mentioned some of the basic commands for system analysis and debugging of server, for example,

  1. Identify system bottlenecks

  2. Disk (storage) bottleneck

  3. CPU and memory bottlenecks

  4. Network bottlenecks

top - Process Activity Monitor Command

The top command displays the Linux process, can be seen from the figure in the system which provides real-time dynamic view of a run, shows the actual process activity, by default, the highest CPU usage task running on the server will be displayed, and is updated once every five seconds (can be changed), top the detailed meaning of commands and parameters can refer to this blog .

figure-1: linux top command

The main argument I do not understand instructions before:

1. up 11:24 是系统运行时间,格式是时:分
2. load average:0.07,0.05,0.01 系统负载,即任务队列的平均长度,是那个值分别是前1分钟、5分钟、15分钟到现在的平均值
3. zombie 是僵尸进程
4. Mem 是物理内存总量,buffers 是用作内存缓存的内存量
5. Swap 是交换区的总量,cached是换成的交换区总量
6. PR 优先级;NI nice值,负值表示高优先级,正值表示低优先级;VIRT 进程使用的虚拟内存总量,单位kb。VIRT=SWAP+RES;RES j进程使用的、未被换出的物理内存大小,单位kb;SHR 共享内存大小,单位kb;S 进程状态:D=不可中断的睡眠状态、R=运行、S=睡眠、T=跟踪/停止、Z=僵尸进程

Instructions

1
2
3
4
5
6
7
8
9
top [-] [d] [p] [q] [c] [C] [S] [s] [n]

d specifies the time interval between refresh the screen information. Of course, users can use the s interactive command to change.
p to only monitor the status of a process by specifying the monitoring process ID.
q This option will allow top without any delay refresh. If the calling process has superuser privileges, then the top will be the highest possible priority.
Accumulation mode designated S
s makes top command to run in safe mode. This will remove potentially dangerous interactive command brings.
i so top does not show any idle or zombie processes.
c display command line rather than just display the command name

hot key

1
2
3
4
5
6
7
8
9
10
top [-] [d] [p] [q] [c] [C] [S] [s] [n]

Summary information is displayed t
m whether to display memory information
A to be sorted according to the process of utilization of various system resources, the system helps to quickly identify the performance of tasks without
f for top interactive configuration screen, in accordance with requirements set top of the display, By default, display only the more important the PID, the USER, PR, the NI, VIRT, the RES, the SHR, S, the CPU%,% MEM, the TIME +, the COMMAND column
o interactively adjusted tone top sequence of each column
r adjust the priority (renice)
K to kill the process (the kill)
Z is switched to the color or black and white mode


vmstat - Virtual Memory Statistics

vmstat virtual memory statistics, display information about processes, memory, paging, block IO, interrupt and CPU activities. Specific information can refer to this blog
figure-2: linux vmstat command

Note: Use a general tool vmstat by two numbers is accomplished parameters, the first parameter is the number of sampling time intervals, in seconds, the second parameter is the number of samples, such as:

1
2
3
4
5
vmstat 3 2
## 参数1=3 表示间隔2秒;参数2=2,表示采样2

vmstat 5
## 表示vmstat每2秒采集数据,一直采集,直到我结束进程(如图figure-2

主要说明我自己之前不了解的参数:

1. r 表示运行队列(就是说多少个进程真的分配到CPU),当这个值超过了CPU数目,就会出现CPU瓶颈了。这个也和top的负载有关系,一般负载超过了3就比较高,超过了5就高,超过了10就不正常了,服务器的状态很危险。top的负载类似每秒的运行队列。如果运行队列过大,表示你的CPU很繁忙,一般会造成CPU使用率很高。
2. b 表示阻塞的进程
3. swpd 虚拟内存已使用的大小,如果大于0,表示你的机器物理内存不足了,如果不是进程内存泄露的原因,那么你该升级内存了或者把耗内存的任务迁移到其他机器。
4. free 空闲的物理内存的大小
5. buff   Linux系统是用来存储,目录里面有权限等的缓存
6. cache cache直接用来记忆我们打开的文档,给文档做缓冲,把空闲的物理内存的一部分拿来做文档和目录的缓存,是为了提高进程执行的性能,当进程使用内存时,buffer/cached会很快地被使用。
7. si  每秒从磁盘读入虚拟内存的大小,如果这个值大于0,表示物理内存不够用或者内存泄露了,要查找耗内存进程解决掉。
8. so  每秒虚拟内存写入磁盘的大小,如果这个值大于0,同上。
9. bi  块设备每秒接收的块数量,这里的块设备是指系统上所有的磁盘和其他块设备。
10. bo 块设备每秒发送的块数量,例如我们读取文档,bo就要大于0。bi和bo一般都要接近0,不然就是IO过于频繁,需要调整。
11.in 每秒CPU的中断次数,包括时间中断
12.cs 每秒上下文切换次数,例如我们调用系统函数,就要进行上下文切换,线程的切换,也要进程上下文切换,这个值要越小越好,太大了,要考虑调低线程或者进程的数目。
13.us 用户CPU时间。
14.sy 系统CPU时间,如果太高,表示系统调用时间长,例如是IO操作频繁。
15.id  空闲 CPU时间,一般来说,id + us + sy = 100,一般我认为id是空闲CPU使用率,us是用户CPU使用率,sy是系统CPU使用率。
16. wt 等待IO CPU时间。

其他命令

1
2
3
4
5
sudo vmstat -m
##显示slab缓存的利用率

vmstat -a
## 获取有关活动和非活动内存页面的信息


w - 找出登录的用户以及他们在做什么

w 命令显示当前在该系统上的用户及其进程,具体参考这篇博客

1
2
3
4
5
6
7
8
9
10
11
12
语  法:w [-fhlsuV][用户名称]

Additional information: implementation of the command that is currently logged in user have those people, and processes they are performing. W alone execute
command displays all of the users, you can also specify a user name, displays only information about a user's.

Parameters:
-f user logs on or off the display where the system.
-h does not display the title of each column of the columns of information.
-l use a detailed list format, this is the default.
-s Use simple list format, no user login time, terminal phase of operations and processes consuming CPU time.
-u Ignore the name of the implementation process, and the process is time-consuming CPU information.
-V Display version information.

figure-3: linux w command

Verbatim large column  https://www.dazhuanlan.com/2019/08/27/5d64c41399498/


Guess you like

Origin www.cnblogs.com/petewell/p/11418543.html
Recommended