
I kNow I can get the real-time stats using top but have no IDea what
to do with them
批处理模式可能很有用:
-b : Batch mode operation Starts top in ’Batch mode’,which Could be useful for sending output from top to other programs or to a file. In this mode,top will not accept input and runs until the iterations limit you’ve set with the ’-n’ command-line option or until killed.
例如:
$top -b -n 1 -u <user> | awk 'NR > 7 { sum += } END { print sum }' Ganglia Gmetric可用于为此绘制图形.
cpu_per_user_gmetric.sh
#!/bin/bashUSERS="a b c"for user in $USERS; do /usr/bin/gmetric --name cpu_per_"$user"_user --value `top -b -n 1 -u $user | awk 'NR>7 { sum += ; } END { print sum; }'` --type uint8 --unit Percentdone crontab -l
* * * * * /path/to/cpu_per_user_gmetric.sh
这是结果:
总结以上是内存溢出为你收集整理的在Linux计算机上绘制每用户CPU使用情况的图表全部内容,希望文章能够帮你解决在Linux计算机上绘制每用户CPU使用情况的图表所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)