implement sigar_cpu

This commit is contained in:
Doug MacEachern 2004-09-06 16:39:54 +00:00
parent a0314e1254
commit faeef9e568
1 changed files with 10 additions and 4 deletions

View File

@ -64,10 +64,16 @@ int sigar_swap_get(sigar_t *sigar, sigar_swap_t *swap)
int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu)
{
cpu->user = -1;
cpu->nice = -1;
cpu->sys = -1;
cpu->idle = -1;
struct tbl_sysinfo sysinfo;
if (table(TBL_SYSINFO, 0, &sysinfo, 1, sizeof(sysinfo)) != 1) {
return errno;
}
cpu->user = sysinfo.si_user;
cpu->nice = sysinfo.si_nice;
cpu->sys = sysinfo.si_sys;
cpu->idle = sysinfo.si_idle;
cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle;