Real-time monitoring process under Linux system and location kill pending process

Source: Internet
Author: User

I. Real-time monitoring process
[email protected] ~]# Top
Top- -: the: theUp4Days -Min3Users, load average:0.01,0.05,0.05Tasks:94Total1Running theSleeping,0Stopped0Zombie%CPU (s):0.7us0.3Sy0.0Ni98.7Id0.0Wa0.0Hi0.0Si0.3Stkib Mem:997608Total81396Free559020Used,357192buff/Cachekib Swap:0Total0Free0Used.229256avail Mem PID USER PR NI VIRT RES SHR S%CPU%MEM time+COMMAND47706Root -   0 2757980  67764   3432S0.3  6.8   2:45.12Java50860Mongod -   0  974392  34288   3700S0.3  3.4   2:06.16Mongod108658Root -   0 2794276  96332   3644S0.3  9.7   2:24.02Java110060Root -   0 2789936  53864   3964S0.3  5.4   1:29.78Java1Root -   0  125456   3424   2076S0.0  0.3   1:04.40systemd2Root -   0       0      0      0S0.0  0.0   0:00.00Kthreadd3Root -   0       0      0      0S0.0  0.0   0:08.48ksoftirqd/0     5Root0- -       0      0      0S0.0  0.0   0:00.00kworker/0:+6Root -   0       0      0      0S0.0  0.0   0:04.04kworker/u2+7Root RT0       0      0      0S0.0  0.0   0:00.00migration/0     8Root -   0       0      0      0S0.0  0.0   0:00.00RCU_BH9Root -   0       0      0      0S0.0  0.0   0:27.72rcu_schedTenRoot0- -       0      0      0S0.0  0.0   0:00.00lru-add-dr+ OneRoot RT0       0      0      0S0.0  0.0   0:01.90watchdog/0     -Root -   0       0      0      0S0.0  0.0   0:00.00Kdevtmpfs -Root0- -       0      0      0S0.0  0.0   0:00.00Netns theRoot -   0       0      0      0S0.0  0.0   0:00.14Khungtaskd

The first part of the output shows an overview of the system:

The first line shows the current time, the running time of the system, the number of users logged in, and the average load on the system.
The average load has 3 values: The last 1 minutes, the last 5 minutes, and the last 15 minutes of the average load. A larger value indicates a higher load on the system.

Due to the short-term abrupt activity of the process, it is common to have high load values in the last 1 minutes, but if the average load is high in the last 15 minutes, the system may be in trouble.

The second line shows the process profile the output of the--top command refers to a process called a task: How many processes are running, hibernating, stopping, or ossified (a rigid state is when the process is complete, but the parent process is not responding).

The third line shows the CPU's summary information. Top divides CPU utilization into several types of output based on the owner (user or system) of the process and the state of the process (running, idle, or waiting).

The fourth 52 line describes the state of the system memory. The first line is about the physical memory of the system: how much memory is in total, how much is currently used, and how much is free. The latter line is about the same information, but for the state of the system swap space (if assigned).

The last section shows a detailed list of the processes currently running, and some columns are similar to the output of the PS command.

    • PID: ID of the process.
    • USER: The name of the process owner.
    • PR: The priority of the process.
    • NI: The value of the humility of the process.
    • VIRT: The total amount of virtual memory that the process consumes.
    • RES: The total amount of physical memory that the process occupies.
    • SHR: The total amount of memory shared by processes and other processes.
    • S: The state of the process (d stands for interruptible sleep state, R stands in the running state, S is the dormant state, T stands for
    • Trace state or stop state, Z represents a rigid state).
    • %CPU: The percentage of CPU time used by the process.
    • %MEM: The amount of memory used by the process as a percentage of available memory.
    • Time+: The total amount of CPU time since the process started so far.
    • Command: The name of the line that the process corresponds to, that is, the program name that is started.

By default, the top command sorts the process at startup by the%CPU value. You can reorder with multiple interactive commands at the top runtime. Each interactive command is single-character, and you type the behavior that changes top when the top command is run. Type F to allow you to select a field to sort the output, and type D to allow you to modify the polling interval. Type q to exit top. The user has great control over the output of the top command. With this tool you can often find the culprit that consumes most of the system's resources. Of course, once found, the next step is to end these processes. This is the next topic.

Ii. End Process Linux process signal

How to kill a process

Kill ID (PID)

3940-bash:kill: (3940)-Operation not permitted

The above command may not be suitable for all processes.

Force a process to kill
3940 #

The-s parameter supports specifying other signals (with a signal name or signal value), the KILL command will not have any output, and to check if the KILL command is valid, you can run the PS or top command to see if the problem process has stopped.

Killall command

The Killall command is very powerful, and it supports ending a process with a process name rather than a PID. The Killall command also supports wildcard characters, which can be useful when the system becomes slow due to heavy load.

# killall http*#

The command in the previous example ends all processes that begin with HTTP, such as the httpd service of the Apache Web server.

Note: When logging into the system as root, use the Killall command with special care because it is easy to misuse wildcards and end important system processes. This may corrupt the file system.

Real-time monitoring process under Linux system and location kill pending process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.