[英]Monitoring system performance in Linux server with the top command
I'm trying to pull in system performance information ( PID, User, CPU, MEM and Time) into an excel file. 我试图将系统性能信息(PID,用户,CPU,MEM和时间)提取到excel文件中。 I will be doing this via a shell script.
我将通过shell脚本执行此操作。 I tried the top command.
我尝试了最高命令。 It has all the information, however it has all the child process information as well.
它具有所有信息,但是也具有所有子进程信息。 Is there a way to aggregate all the child processes with the parent process so that I can look at one process and say it took so long to complete.
有没有一种方法可以将所有子进程与父进程聚合在一起,这样我就可以查看一个进程并说花了很长时间才能完成。 Also, is there a way to display and pull PPID information with the top command?.
另外,有没有一种方法可以使用top命令显示和提取PPID信息? If there are other ways to do this, I would be open to that as well.
如果还有其他方法可以做到这一点,我也会对此持开放态度。 I want to aggregate all the child processes with the parent processes and look at system performance for different users.
我想将所有子进程与父进程聚合在一起,并查看不同用户的系统性能。 This is the code that I tried in a shell script.
这是我在Shell脚本中尝试过的代码。
top -n1 -b \
|awk '{if (($1 ~ /^[0-9]/) || ($0 ~ /PID/ )) {
print $1","$2","$4","$5","$6","$7","$8","$9","$10","$11","$12","$13","$14","$15; }
}' > file.csv
I am using red hat linux. 我正在使用Red Hat Linux。 Help will be appreciated.
帮助将不胜感激。
You should be able to achieve what you are asking by directly reading from /proc. 您应该能够通过直接从/ proc中读取来实现您的要求。 This is essentially how top, free etc. get their data.
本质上,这就是top,free等如何获取其数据的方式。
See eg http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-proc.html or man proc 参见例如http://www.centos.org/docs/5/html/Deployment_Guide-zh-CN/ch-proc.html或man proc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.