How to Check the CPU Usage and Memory Occupancy of Linux Server

How to Check the CPU Usage and Memory Occupancy of Linux Server

As a Linux operation and maintenance engineer, we need to check the CPU usage, memory usage, and bandwidth usage frequently in the system maintenance process and daily work, and analyze the overall operation of the system from the degree of resource usage.

 

There are many commands to check resource usage on Linux. The CPU, memory, IO, NETWORK and other resource usage can be queried through certain commands. Today Aixi will explain in detail how to check CPU usage and memory usage.

To call the resource viewing command, our first step is to know what the viewing commands are

The following is the TOP command

PID: process identification number

USER: process owner

PR: Process priority

NI: process priority number

VIRT: the virtual memory value occupied by the process

RES: the physical memory value occupied by the process

SHR: Shared memory value used by the process

S: The status of the process, where S means dormant, R means running, and Z means zombie

%CPU: The CPU usage rate occupied by the process

%MEM : Percentage of physical memory occupied by the process

TIME+: The total CPU time occupied by the process since it started

Command: The name of the startup command for the process startup

Free command

View total memory, usage, free, etc.

total: total physical memory size

used: how much has been used

free: how many are available

Shared: the total amount of memory shared by multiple processes

Buffers/cached: the size of the disk cache

 

Vmstat command

Procs (process):

r: The number of processes in the run queue. This value can also determine whether to increase the CPU. (Long term greater than 1)

b: number of processes waiting for IO

 

Memory (memory):

swpd: use virtual memory size

free: free physical memory size

buff: memory size used as buffer

cache: memory size used as cache

 

Swap:

si: The size written from the swap area to the memory per second, transferred from the disk to the memory

so: The memory size written to the swap area per second, transferred from the memory to the disk

IO:

bi: the number of blocks read per second

bo: number of blocks written per second

system:

in: Number of interrupts per second, including clock interrupts.

cs: The number of context switches per second.

CPU (in percent):

us: user process execution time percentage (user time)

sy: Kernel system process execution time percentage (system time)

wa: IO waiting time percentage

id: percentage of idle time

jps command: You can list the process pids of all java applications on the machine.

jps [ options ] [ hostid ]

options

-q Output only the VM identifier, excluding class name, jar name, arguments in main method.

-m Output the parameters of the main method.

-l Output the full package name, application main class name, full path name of jar.

-v Output jvm parameters.

-V Outputs the parameters passed to the JVM through the flag file (.hotspotrc file or -XX:Flags= specified file).

-Joption Pass parameters to vm.

ps command: Display the process status of the current system.

Check which processes are running and their status, whether the process is terminated, whether the process is dead, the resources occupied by the process, etc.

[root@xxx /]# ps -l

 

 

Use the following command to find out the threads with high CPU usage:

ps H -eo user,pid,ppid,tid,time,%cpu,cmd --sort=%cpu

1.linux View the programs that occupy the most memory

ps aux|head -1;ps aux|grep -v PID|sort -rn -k +4|head

**

2. View the programs that occupy the most CPU

**

ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head

I'm Chiwang Aixi, and that's all for today's sharing. I hope it will be helpful to friends in need. See you next time!

Guess you like

Origin blog.csdn.net/V13807970340/article/details/130171079