Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Oracle database host patrol inspection

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Detailed explanation of TOP command

The basic function of the top command and the ps command is the same, showing the current progress and other conditions of the system, but top is a dynamic display process, that is, you can constantly refresh the current state by pressing the user key. Such as? The foreground executes the command, which monopolizes the foreground until the user terminates the program. More accurately, the top command provides real-time monitoring of the state of the system processor. It will display a list of CPU's most "sensitive" tasks in the system. This command can be used by CPU. Memory usage and execution time sort tasks; and many of the features of this command can be set through interactive commands or in personal customization files. Command parameters and interactive commands are described separately in a later introduction.

The following is the syntax format of the command:

Top [-] [d delay] [Q] [c] [s] [S] [I]

D specifies the time interval between every two screen information refreshes. Of course, the user can use the s interactive command to change it.

Q this option will allow top to refresh without any delay. If the caller has superuser privileges, top will run at the highest possible priority.

S specifies the accumulation mode.

S causes the top command to run in safe mode. This removes the potential danger of interactive commands.

I make top not show any idle or dead processes.

C displays the entire command line instead of just the command name

The top command displays a large number of items, and the default value is updated every 5 seconds, which can of course be set. The items displayed are:

The uptime entry shows the startup time of the system, the time it has run, and the three average load values (the last 1 second, 5 seconds, and 15 seconds).

The total number of running processes in processes since the last refresh. Of course, these processes are divided into running, dormant, stopped, and so on. Process and status display can be achieved through the interactive command t.

CPU states shows the percentage of CPU time taken up by user mode, system mode, priority processes (only negative priority is considered), idle, and so on. The time consumed by the priority process is also included in the user and system time, so the total percentage will be greater than 100%.

Mem memory usage statistics, including total available memory, free memory, used memory, shared memory, and memory occupied by cache.

Swap swap space statistics, including total swap space, available swap space, used swap space.

PID the ID of each process.

PPID the parent process of each process, ID.

UID the UID of each process owner.

USER the user name of each process owner.

PRI the priority of each process.

NI the priority value of the process.

SIZE the total code size of the process plus the data size plus the stack space size. The unit is KB.

TSIZE the code size of the process. This is a strange value for kernel processes.

The size of the DSIZE data and stack.

TRS text resident size.

D page items marked as "dirty".

The size of the library page used by LIB. Has no effect on the ELF process.

RSS the total amount of physical memory occupied by the process, in KB.

SHARE the amount of shared memory used by the process.

STAT the status of the process. Where S represents a dormant state; D represents an uninterruptible dormant state; R represents a running state; Z represents a dead state; and T represents a stopped or tracking state.

TIME the total CPU time spent by the process since it was started. If you are in cumulative mode, the time also includes the time taken by the process subprocess. And the title becomes CTIME.

% CPU the percentage of CPU time and total time spent by the process since it was last refreshed.

% MEM the percentage of physical memory consumed by this process as total memory.

COMMAND the command name of the process. If one line is not displayed, it will be intercepted. The process in memory will have a complete command line.

Here are some interactive commands that can be used during the execution of the top command. From a usage point of view, proficiency in these commands is more important than options. These commands are single-letter, and if the s option is used in the command line options, it is possible that some of these commands will be blocked.

$# @ 60; the space immediately refreshes the display.

Ctrl+L erases and rewrites the screen.

H or? Show the help screen and give some brief summary instructions for the command.

K terminates a process. The user will be prompted to enter the process PID that needs to be terminated and what kind of signal needs to be sent to the process. A general termination process can use a 15 signal; if it does not end properly, use signal 9 to force the process to end. The default value is signal 15. This command is blocked in safe mode.

I ignore idle and dead processes. This is a switch command.

Q exit the program.

R rearrange the priority of a process. The system prompts the user to enter the process PID that needs to be changed and the pomelo Mei Mu escapes the bank to burn the ton J gurgu Huanshu to stop the rough Chizhi tip to escape the scrubbing medium to flee and scratch the bank hot stool? 0.

S switches to cumulative mode.

S change the delay time between two refreshes. The user will be prompted to enter a new time in s. If there is a decimal, it is converted to m s. Enter a value of 0 and the system will continue to refresh, with a default value of 5 s. It should be noted that if you set too little time, it is likely to cause continuous refresh, so that it is too late to see the display at all, and the system load will be greatly increased.

F or F adds or removes items from the current display.

O or O change the order in which items are displayed.

L Toggle displays average load and startup time information.

M toggles to display memory information.

T toggles to display process and CPU status information.

C toggles the display command name and the full command line.

M sorts according to the amount of resident memory.

P sorts according to the percentage of CPU usage.

T is sorted by time / cumulative time.

W writes the current settings to the ~ / .toprc file. This is the recommended way to write top configuration files.

As you can see from the above introduction, the top command is a very powerful tool for monitoring the system, especially for system administrators. The average user may think that the ps command is enough, but the power of the top command does provide a lot of convenience. Let's take a look at the actual use.

[example 23] Type the top command to view the system status

$top

1:55pm up 7 min, 4 user, load average:0.07,0.09,0.06

29 processes:28 sleeping, 1 running, 0 zombie, 0 stopped

CPU states: 4.5 user, 3.6 system, 0.0% nice, 91.9% idle

Mem: 38916K av, 18564K used, 20352K free, 11660K shrd, 1220K buff

Swap: 33228K av, 0K used, 33228K free, 11820K cached

PID USER PRI NI SIZE RSS SHARE STAT LIB CPU MEM TIME COMMAND

363 root 14 0 708 708 552 R 0 8.1 1.8 0:00 top

1 root 0 0 404 404 344 S 0 0.0 1.0 0:03 init

2 root 00 00 0 SW 0 0.0 0.0 0:00 kflushd

3 root-12-12 00 SW$#@60; 0 0.0 0:00 kswapd

4 root 00 00 0 SW 0 0.0 0.0 0:00 md_thread

5 root 00 00 0 SW 0 0.0 0.0 0:00 md_thread

312 root 1 0 636 636 488 S 0 0.0 1.6 0:00 telnet

285 root 6 0 1140 1140 804 S 0 0.0 2.9 0.00 bash

286 root 00 1048 1048 792 S 0 0.0 2.6 0.00 bash

25 root 00 364 364 312 S 0 0.0 0.9 0.00 kerneld

153 root 00 456 456 372 S 0 0.0 1.1 0.00 syslogd

160 root 00 552 552 344 S 0 0.0 1.4 0.00 klogd

169 daemon 00 416 416 340 S 0 0.0 1.0 0.00 atd

178 root 2 0 496 496 412 S 0 0.0 1.2 0.00 crond

187 bin 00 352 352 284 S 0 0.0 0.9 0.00 portmap

232 root 00 500 500 412 S 0 0.0 1.2 0.00 rpc.mountd

206 root 00 412 412 344 S 0 0.0 1.0 0.00 inetd

215 root 00 436 436 360 S 0 0.0 1.1 0.00 icmplog

The items in the first line are the current time, the system startup time, the number of current system login users, and the average load. The second behavior process is the total number of processes, the number of dormant processes, the number of running processes, the number of dead processes, and the number of terminated processes. The third behavior is CPU state, which is user occupation, system occupation, priority process occupation and idle process occupation in turn. The fourth behavior is memory state, followed by average available memory, used memory, free memory, shared memory, cache usage memory. The fifth behavior switching state is the average available switching capacity, used capacity, idle capacity and cache capacity in turn. Then here is a list of processes similar to ps.

Generally speaking, the top command is more powerful than ps, but it takes a long time to occupy the foreground, so users should use this command according to their own situation.

Vmstat explains in detail

Vmstat: a tool for reporting the active status of kernel processes, virtual memory, disks, and cpu

There are several main uses:

Number of 1.vmstat interval tests

The output is as follows

Kthr memory page faults cpu

R b avm fre re pi po fr sr cy in sy cs us sy id wa

0 0 26258 18280 0 0 0 7 20 0 127 227 64 12 96 1

Where:

State of the kthr-- kernel process

-- the number of processes in the run queue should be less than 5 (r) at a stable workload

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report