View cpu usage and memory usage under linux

top

The top command is a commonly used performance analysis tool under Linux. It can display the resource usage status of each process in the system in real time, similar to the Windows task manager. The following describes its usage in detail;

top is a dynamic display process, which can continuously refresh the current state by pressing the user's key. If the command is executed in the foreground, it will monopolize the foreground until the user terminates the program.

The top command provides real-time monitoring of the status of the system processor; it will display information about the processes currently being executed by the system, including process ID, memory usage, CPU usage, etc.;

-b:批处理

-c:显示完整的治命令

-I:忽略失效过程

-s:保密模式

-S:累积模式

-i<时间>:设置间隔时间

-u<用户名>:指定用户名

-p<进程号>:指定进程

-n<次数>:循环显示的次数

insert image description here

top命令可以看到总体的系统运行状态和cpu的使用率;
%us:表示用户空间程序的cpu使用率(没有通过nice调度);
%sy:表示系统空间的cpu使用率,主要是内核程序;
%ni:表示用户空间且通过nice调度过的程序的cpu使用率;
%id:空闲cpu;
%wa:cpu运行时在等待io的时间;
%hi:cpu处理硬中断的数量;
%si:cpu处理软中断的数量;
%st:被虚拟机偷走的cpu;

insert image description here

PID:进程标示号
USER:进程所有者
PR:进程优先级
NI:进程优先级别数值
VIRT:进程占用的虚拟内存值
RES:进程占用的物理内存值
SHR :进程使用的共享内存值
S :进程的状态,其中S表示休眠,R表示正在运行,Z表示僵尸进程
%CPU :进程占用的CPU使用率
%MEM :进程占用的物理内存百分比
TIME+:进程启动后占用的总的CPU时间
Command:进程启动的启动命令名称

free

insert image description here

total:总计物理内存的大小
used:已使用多大
free:可用有多少
Shared:多个进程共享的内存总额
Buffers/cached:磁盘缓存的大小

ps

# 这个命令是可以对cpu、内存使用率进行一个排序展示
# 各自代表什么意思,有时间再说
ps aux --sort -rss

Part of the content is reproduced from:
https://blog.csdn.net/weixin_45926547/article/details/126141295

My insight is that the doers are the real thinkers. Those who have really done things that change the industry are both thinkers and doers. Many people easily attribute their
achievements to thinking, but usually, doers More specifically, when you analyze a little bit, you will find that the people who really do things are the ones who really think hard.

Jobs

おすすめ

転載: blog.csdn.net/weixin_44431371/article/details/131528718