Introduction: This is a unix/linux system Management Automation series, mainly about how to achieve automated monitoring process status and performance and timely notify the system administrator.
Process monitoring is a very important part of unix/linux system management. It can monitor the process status, CPU utilization of the process, and so on, and can send alarm information to the system administrator or make a specific response when the process is found to be abnormal. We can use System process monitoring information for reasonable process scheduling to optimize system performance, or adjust the behavior of the system according to these information.
The commands for different operating system monitoring processes may be slightly different. This article introduces the Unix/linux operating system process management commands and related information, and discusses the automated scripting implementation of process monitoring on the Unix/linux operating system.
Introduction to Unix/linux Process Management related commands
A process is an entity that the operating system uses to control system resources. Unix/linux process Management related commands are mainly the following, in the subsequent implementation of the script will use some of the commands.
Show Process Properties command
PS Command: This command is the most basic and very powerful process view command for reporting process identities, users, CPU time consumption, and other attributes. It can be used to determine which processes are running and running, whether the process is over, if the process is dead, which processes are consuming too many resources, and so on. The PS command monitors the work of the background process, because the background process does not communicate with the standard input/output devices on the on-screen keyboard, and if it needs to be detected, use the PS command.
The list of processes that are seen by using the PS command alone is a process executed at the foreground, but not all processes are performed in the foreground, and many processes are hidden behind the scenes. Use command ps-e to display all processes.
Process Performance Detection commands
Top command: Linux Displays the CPU occupancy rate as the first few processes using the command. This command sorts tasks by CPU usage, memory usage, and execution time, and many of the commands can be set in interactive commands or in personal custom files. The top primary field has the following meanings:
Table 1. Top field meaning
Column Name |
Meaning |
Pid |
Process ID |
USER |
User name of the process owner |
PR |
Task priority |
NI |
Nice value. A smaller number indicates higher precedence, and a larger number indicates a lower priority |
Virt |
Total amount of virtual memory used by the process in kilobytes: KB. Virt=swap+res |
Res |
The amount of physical memory that the process is using, not swapped out, in kilobytes: KB. Res=code+data |
Shr |
Shared memory size, in kilobytes: KB |
S |
Process status. D= an uninterrupted sleep state R= Run S= Sleep t= Tracking/Stopping z= Zombie Process |
%cpu |
Percentage of CPU time that was last updated to now |
time+ |
Total CPU time used by the process, accurate to 1/100 seconds |
COMMAND |
Command name/command line |