.如何得到cpu利用率!

keenboy 2005-07-29 10:21:59
想在Redhat ES上得到cpu的利用率,查看/proc/stat文件中第一行有7个数据,而有些版本Redhat是四个数据!请问ES上的七个数据是什么含义如何求解!
...全文
110 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
fytzzh 2005-07-29
  • 打赏
  • 举报
回复
id 不是的
fytzzh 2005-07-29
  • 打赏
  • 举报
回复
id user system nice idle IO-wait x y

typedef struct CPU_t
{
unsigned long u, n, s, i ,w, x, y;
unsigned id;
}CPU_T;
CPU_T *cpus = NULL;
fp =fopen("/proc/stat", "r");
fgets(buf,sizeof(buf), fp);
sscanf(buf, "cpu %lu %lu %lu %lu %lu %lu %lu", &cpus[i].u, &cpus[i].n,... ...);
大概思路是这样的

23,125

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧