[CENTOS] Check the operating status of the server with the Linux top command

environment

[root@CENTOS7 ~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[root@CENTOS7 ~]#

1. top command

With the top command, you can check detailed information such as CPU and memory usage in a list for each process. By default, the top command displays the currently running processes in descending order of CPU usage. The display updates in real time and exits when you enter q.

top command format


top [option]

Main options for the top command

option Contents
-d interval Update interval "ss.Specify with "tt seconds"
-n times Specify the number of times to repeat the display
-b Batch mode. Do not accept key operations, "-The number of times specified by "n" or "CTRL"+Continues execution until killed by "C" etc.
Useful when saving the result of top to a file etc.
-s Operates in secure mode (does not accept "d" etc. during startup)
-U user
-u user
Specify the user to monitor by name or ID
-p process ID Specify the process ID to monitor. "-p number-p number "or"-p number,You can specify more than one like "number" (blanks can be omitted)
-c Switch the COMMAND column (far right) to display the program name or the command line (switch with "c" after startup)
-i Switch whether to display idle processes that are not executing anything (switch with "i" after startup)
-S Cumulative time mode (switch with "S" after startup)
-o item Specify the item used to sort the output (default is CPU usage). The item name that can be specified is "top"-Confirm with "O"
For example, if you want to display in descending order of used memory (physical memory occupancy), "top"-o %MEM "
-w Number of digits Output width

2. Interactive top command

You can use the following interactive commands while executing the top command.

command Details
Enter、Space Immediately update the display with the latest information.
h Displays the help screen for interactive commands.
h、? Displays the help screen for windows and field groups.
k Kill the process. You will be prompted for the process ID and the signal to send to the process.
n Change the displayed process number. You will be prompted to enter the number.
u Sort the list by user.
M Sort the list by memory usage.
P Sort the list by CPU usage.
q Exit the utility and return to the shell prompt.

3. How to read the output result of the top command

The following is displayed with the top command.

Output result of top command


top - 16:29:43 up 21:14,  1 user,  load average: 0.00, 0.01, 0.05
Tasks:  97 total,   1 running,  96 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.3 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1014820 total,   401940 free,   187588 used,   425292 buff/cache
KiB Swap:  1679356 total,  1679356 free,        0 used.   676612 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
    1 root      20   0  128040   6712   4176 S  0.0  0.7   0:03.53 systemd
    2 root      20   0       0      0      0 S  0.0  0.0   0:00.01 kthreadd
    4 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/0:0H
    5 root      20   0       0      0      0 S  0.0  0.0   0:00.19 kworker/u2:0
    6 root      20   0       0      0      0 S  0.0  0.0   0:00.91 ksoftirqd/0
    7 root      rt   0       0      0      0 S  0.0  0.0   0:00.00 migration/0
    8 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcu_bh
    9 root      20   0       0      0      0 S  0.0  0.0   0:00.90 rcu_sched
   10 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 lru-add-dra+
   11 root      rt   0       0      0      0 S  0.0  0.0   0:00.95 watchdog/0
   13 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kdevtmpfs
   14 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 netns
   15 root      20   0       0      0      0 S  0.0  0.0   0:00.03 khungtaskd
   16 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 writeback
   17 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kintegrityd
   18 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 bioset
   19 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 bioset

Display contents of the first line (top ~)

"Current time", "Operating time", "Number of logged-in users", and "Load average" are displayed on the first line.

Display contents on the first line


top - 16:29:43 up 21:14,  1 user,  load average: 0.00, 0.01, 0.05
item Contents
16:29:43 Current time (16:29:43)
up 21:14 Operating time (21 hours 14 minutes)
1 user Number of logged-in users (1 user is logged in)
load average: 0.00, 0.01, 0.05 Road average for the last 1, 5 or 15 minutes

Display contents of the second line (Tasks: ~)

The second line shows the status of the task.

Display contents on the second line


Tasks:  97 total,   1 running,  96 sleeping,   0 stopped,   0 zombie
item Contents
total Total number of tasks
running Number of running tasks
sleeping Number of waiting tasks
stopped Number of stopped tasks
zombie Number of zombie tasks

Display contents of the 3rd line (% Cpu (s): ~)

The third line shows the CPU status.

Display contents on the third line


%Cpu(s):  0.0 us,  0.3 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
item Contents
us Percentage of user process usage time
sy Percentage of system process usage time
ni Percentage of usage time of the user process whose execution priority has been changed
id Percentage of idle time
wa I/Percentage of time waiting for the end of O
hi Percentage of usage time for hardware interrupt requests
si Percentage of usage time for software interrupt requests
st Percentage of time waited for calculations by other virtual CPUs when using OS virtualization

Display contents of the 4th line (KiB Mem :)

The 4th line shows the memory status.

Display contents on the 4th line


KiB Mem :  1014820 total,   401940 free,   187588 used,   425292 buff/cache
item Contents
total Total memory capacity
free Unused memory capacity
used Memory capacity in use
buff/cache Buffer cache/Memory capacity allocated as page cache

Display contents of the 5th line (KiB Swap :)

The fifth line shows the status of the swap area.

Display contents on the 5th line


KiB Swap:  1679356 total,  1679356 free,        0 used.   676612 avail Mem
item Contents
total Total swap space capacity
free Unused swap space capacity
used Amount of swap space in use
avail Mem Memory capacity that new apps can use without swapping

Display contents after the 7th line

From the 7th line onward, the status of each running process is displayed.

Display contents after the 7th line


  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
    1 root      20   0  128040   6712   4176 S  0.0  0.7   0:03.53 systemd
    2 root      20   0       0      0      0 S  0.0  0.0   0:00.01 kthreadd
    4 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/0:0H
    5 root      20   0       0      0      0 S  0.0  0.0   0:00.19 kworker/u2:0
    6 root      20   0       0      0      0 S  0.0  0.0   0:00.91 ksoftirqd/0
    7 root      rt   0       0      0      0 S  0.0  0.0   0:00.00 migration/0
    8 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcu_bh
    9 root      20   0       0      0      0 S  0.0  0.0   0:00.90 rcu_sched
   10 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 lru-add-dra+
   11 root      rt   0       0      0      0 S  0.0  0.0   0:00.95 watchdog/0
   13 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kdevtmpfs
   14 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 netns
   15 root      20   0       0      0      0 S  0.0  0.0   0:00.03 khungtaskd
   16 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 writeback
   17 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kintegrityd
   18 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 bioset
   19 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 bioset
item Contents
PID Process ID
USER Process execution user
PR Process static priority (lower numbers have higher priority)
NI Relative process priority (based on 0)-20 (high priority) to 19 (low priority))
VIRT Process virtual memory size(Memory capacity plus swapped out memory usage)
RES Memory capacity used by the process(Physical memory capacity)
SHR Shared memory capacity used by the process
S Process state
D: Interrupt not possible (sleep)
R: Running
S: Sleep state
T: Stopped (stopped by job control signal)
t: Stopped (stopped by the debugger during tracing)
Z: Zombie state
%CPU CPU usage
%MEM Physical memory usage
TIME+ Process CPU usage time
COMMAND Command name currently being executed

that's all

Recommended Posts

Check the operating status of the server with the Linux top command
Check the memory status of the server with the Linux free command
Check the HTTP status code response with the curl command (#Linux #Shell)
Check server I / O device usage with the Linux iostat command
Hit the top command with htop
How to monitor the execution status of sqlldr with the pv command
Check the memory protection of linux kerne with the code for ARM
Check the existence of the file with python
Status check command used (sometimes) on linux
Linux server command
Adjust file permissions with the Linux command chmod
[2020July] Check the UDID of the iPad on Linux
Check the date of the flag duty with Python
The story of misreading the swap line of the top command
Linux: Understand the information displayed by the top command
Compress with zip command of java side linux
Check the status of your data using pandas_profiling
The story of stopping the production service with the hostname command
The story of replacing Nvidia GTX 1650 with Linux Mint 20.1.
Open Chrome version of LINE from the command line [Linux]
[Linux] Execute git pull regularly with the crontab command
Get the operation status of JR West with Python
Visualize the appreciation status of art works with OpenCV
Check the type and version of your Linux distribution
Understand the attributes of Linux files (ls -l command)
I tried to rewrite the WEB server of the normal Linux programming 1st edition with C ++ 14
The basics of building an in-house server for Linux (CentOS 8.1, openSUSE 15.1, Ubuntu 20.04)! File server with Samba
Get UNIXTIME at the beginning of today with a command
Let's execute the command on time with the bot of discord
Check the scope of local variables with the Python locals function.
Check the code with flake8
A Python script that allows you to check the status of the server from your browser
Install the latest version of Git on your Linux server
Linux PC spec check command
Commands and files to check the version of CentOS Linux
Get the host name of the host PC with Docker on Linux
[Linux] I tried to summarize the command of resource confirmation system
[Linux Nginx] Command collection used for initial setting of Web server
[Machine learning] Check the performance of the classifier with handwritten character data
How to output the output result of the Linux man command to a file
A command to easily check the speed of the network on the console
I want to check the position of my face with OpenCV!
I used the worldcup command to check the outcome of the World Cup.
[Linux] OS recovery with restore command
Completion of docker command on Linux
[linux] kill command to kill the process
Using cgo with the go command
The story of remounting the application server
Visualize the response status of the census 2020
Get the width of the div on the server side with Selenium + PhantomJS + Python
Replace the directory name and the file name in the directory together with a Linux command.
You can also check the communication of DB and cache with curl
[Ota Ward] Check the status of application processing for special flat-rate benefits
[Linux] Command to get a list of commands executed in the past
Extract the TOP command result with USER and output it as CSV
Edit the file of the SSH connection destination server on the server with VS Code
The --security option cannot be used with the dnf command on CentOS Linux
Display the status of COVID 19 infection in Japan with Splunk (GitHub version)
With the advent of systemd-homed in 2020, Linux user management will change dramatically.
[linux test command] Check the existence of the directory. Used to see if there are too many directories to specify
I tried the asynchronous server of Django 3.0