如何在编程中获取某个进程的cpu占用率和内存占用率,急!

如何在编程中获取某个进程的cpu占用率和内存占用率,急
---------------------------------------------------------------

简单的办法:ps 如何??
---------------------------------------------------------------

sar -r 1 100 可以看内存和交换区的使用请宽
---------------------------------------------------------------

#include

 1<sys time.h="">   
 2#include <sys resource.h="">   
 3#include <unistd.h>   
 4  
 5int getrlimit (int resource, struct rlimit *rlim);   
 6int getrusage (int who, struct rusage *usage);   
 7int setrlimit (int resource, const struct rlimit *rlim);   
 8  
 9\---------------------------------------------------------------   
10  
11hen 很简单啊!   
121、先用命令SAR ,   
132、然后得到屏幕输出,   
143、截出所要的字符,,   
154、然后进行处理!!!   
16具体程序怎么写就看你的了,我写了实现办法而已!!!</unistd.h></sys></sys>
Published At
Categories with 服务器类
Tagged with
comments powered by Disqus