如何确定Linux中某个用户下运行的进程产生了多少CPU负载? [英] How to determine how much CPU load is produced from processes running under some user in Linux?

查看:55
本文介绍了如何确定Linux中某个用户下运行的进程产生了多少CPU负载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个简单的监视脚本,该脚本将在文本文件中记录用户"abc"产生的CPU负载.

I would like to make a simple monitoring script that will record CPU load produced by user "abc" in a text file.

vmstat,iostat,mpstat和free似乎不具有根据用户名进行过滤的功能.

vmstat, iostat, mpstat and free do not seem to have a capability to filter based on user name.

有可能吗?

编辑:顺便说一句.我正在Red Hat EL 6.0上运行.

EDIT: Btw. I'm running on Red Hat EL 6.0.

推荐答案

一种简单的方法是

top -b -n 1 -u abc | awk 'NR>7 { sum += $9; } END { print sum; }'

如果您对每个用户的CPU时间感兴趣,也可以使用acct.

If you are interested in the cpu time on a per user basis you can also use acct.

accton on
sa -m

这篇关于如何确定Linux中某个用户下运行的进程产生了多少CPU负载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆