本文主要是介绍newlisp 监控Linux进程 四,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
用ps命令查看进程使用的cpu和内存
在前面用newlisp监控进程的时候,其实只是判断进程是否存活,如果不是,则重新启动。现在还要实现另一个功能,监控进程的cpu和memory占用情况。
如果用man ps查看ps命令,你会看到下面的参数:
CODE HEADER DESCRIPTION%cpu %CPU cpu utilization of the process in "##.#" format. Currently, it is the CPU time used divided by the time the processhas been running (cputime/realtime ratio), expressed as a percentage. It will not add up to 100% unless you arelucky. (alias pcpu).%mem %MEM ratio of the process's resident set size to the physical memory on the machine, expressed as a percentage.(alias pmem).args COMMAND command with all its arguments as a string. Modifications to the arguments may be shown. The output in this columnmay contain spaces. A process marked <defunct>
这篇关于newlisp 监控Linux进程 四的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!