This article mainly introduces the shell script implementation to monitor the running state of the specified process, this article directly gives the script code, the need for friends can refer to the following
In the previous blog, once wrote the implementation of automated test procedures, now developers need to know the process of being tested (this refers to the main process running on Linux) before the abnormal exit of the process state, such as memory usage, CPU usage, and so on.
A shell script is used to implement the running state of the specified process. directly on the code.
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 The |
|
The
Sample implements the state of the process every 10s read, it is then shown to continue monitoring when the discovery process exists and the state is non-Z (not zombie), but when the test program completes or exits unexpectedly, the script exits the monitoring loop, and after exiting the loop, prints out the state of the specified process.