[SIGAR-106] Add cpu irq, soft_irq and steal

This commit is contained in:
Doug MacEachern committed 2008-05-24 15:12:06 +00:00
1 parent e3510e0805
commit 9a1f45cd7b
12 files changed
+118 -9

No files matched your search

+6
View File
@@ -717,6 +717,9 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu)
cpu->sys = SIGAR_TICK2MSEC(cpu_data.sys);
cpu->idle = SIGAR_TICK2MSEC(cpu_data.idle);
cpu->wait = SIGAR_TICK2MSEC(cpu_data.wait);
cpu->irq = 0; /*N/A*/
cpu->soft_irq = 0; /*N/A*/
cpu->steal = 0; /*N/A*/
cpu->total = cpu->user + cpu->sys + cpu->idle + cpu->wait;
return SIGAR_OK;
}
@@ -736,6 +739,9 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu)
cpu->sys = SIGAR_TICK2MSEC(data.cpu[CPU_KERNEL]);
cpu->idle = SIGAR_TICK2MSEC(data.cpu[CPU_IDLE]);
cpu->wait = SIGAR_TICK2MSEC(data.cpu[CPU_WAIT]);
cpu->irq = 0; /*N/A*/
cpu->soft_irq = 0; /*N/A*/
cpu->steal = 0; /*N/A*/
cpu->total = cpu->user + cpu->sys + cpu->idle + cpu->wait;
return SIGAR_OK;
+11 -2
View File
@@ -634,6 +634,9 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu)
cpu->idle = SIGAR_TICK2MSEC(cpuload.cpu_ticks[CPU_STATE_IDLE]);
cpu->nice = SIGAR_TICK2MSEC(cpuload.cpu_ticks[CPU_STATE_NICE]);
cpu->wait = 0; /*N/A*/
cpu->irq = 0; /*N/A*/
cpu->soft_irq = 0; /*N/A*/
cpu->steal = 0; /*N/A*/
cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle;
#elif defined(__FreeBSD__) || (__OpenBSD__) || defined(__NetBSD__)
@@ -663,10 +666,13 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu)
cpu->user = SIGAR_TICK2MSEC(cp_time[CP_USER]);
cpu->nice = SIGAR_TICK2MSEC(cp_time[CP_NICE]);
cpu->sys = SIGAR_TICK2MSEC(cp_time[CP_SYS] + cp_time[CP_INTR]);
cpu->sys = SIGAR_TICK2MSEC(cp_time[CP_SYS]);
cpu->idle = SIGAR_TICK2MSEC(cp_time[CP_IDLE]);
cpu->wait = 0; /*N/A*/
cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle;
cpu->irq = SIGAR_TICK2MSEC(cp_time[CP_INTR]);
cpu->soft_irq = 0; /*N/A*/
cpu->steal = 0; /*N/A*/
cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle + cpu->irq;
#endif
return SIGAR_OK;
@@ -704,6 +710,9 @@ int sigar_cpu_list_get(sigar_t *sigar, sigar_cpu_list_t *cpulist)
cpu->idle = SIGAR_TICK2MSEC(cpuload[i].cpu_ticks[CPU_STATE_IDLE]);
cpu->nice = SIGAR_TICK2MSEC(cpuload[i].cpu_ticks[CPU_STATE_NICE]);
cpu->wait = 0; /*N/A*/
cpu->irq = 0; /*N/A*/
cpu->soft_irq = 0; /*N/A*/
cpu->steal = 0; /*N/A*/
cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle;
}
+6 -3
View File
@@ -128,8 +128,7 @@ static void get_cpu_metrics(sigar_t *sigar,
cpu->user = SIGAR_TICK2MSEC(cpu_time[CP_USER]);
cpu->sys = SIGAR_TICK2MSEC(cpu_time[CP_SYS] +
cpu_time[CP_SSYS] +
cpu_time[CP_INTR]);
cpu_time[CP_SSYS]);
cpu->nice = SIGAR_TICK2MSEC(cpu_time[CP_NICE]);
@@ -139,8 +138,12 @@ static void get_cpu_metrics(sigar_t *sigar,
cpu_time[CP_SWAIT] +
cpu_time[CP_BLOCK]);
cpu->irq = SIGAR_TICK2MSEC(cpu_time[CP_INTR]);
cpu->soft_irq = 0; /*N/A*/
cpu->steal = 0; /*N/A*/
cpu->total =
cpu->user + cpu->sys + cpu->nice + cpu->idle + cpu->wait;
cpu->user + cpu->sys + cpu->nice + cpu->idle + cpu->wait + cpu->irq;
}
int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu)
+9 -1
View File
@@ -411,8 +411,16 @@ static void get_cpu_metrics(sigar_t *sigar, sigar_cpu_t *cpu, char *line)
if (*ptr == ' ') {
/* 2.6+ kernels only */
cpu->wait += SIGAR_TICK2MSEC(sigar_strtoull(ptr));
cpu->irq += SIGAR_TICK2MSEC(sigar_strtoull(ptr));
cpu->soft_irq += SIGAR_TICK2MSEC(sigar_strtoull(ptr));
}
cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle + cpu->wait;
if (*ptr == ' ') {
/* 2.6.11+ kernels only */
cpu->steal += SIGAR_TICK2MSEC(sigar_strtoull(ptr));
}
cpu->total =
cpu->user + cpu->nice + cpu->sys + cpu->idle +
cpu->wait + cpu->irq + cpu->soft_irq + cpu->steal;
}
int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu)
+3
View File
@@ -104,6 +104,9 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu)
cpu->sys = sysinfo.si_sys;
cpu->idle = sysinfo.si_idle;
cpu->wait = 0; /*N/A?*/
cpu->irq = 0; /*N/A*/
cpu->soft_irq = 0; /*N/A*/
cpu->steal = 0; /*N/A*/
cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle + cpu->wait;
return SIGAR_OK;
+16 -2
View File
@@ -610,28 +610,42 @@ SIGAR_DECLARE(int) sigar_cpu_perc_calculate(sigar_cpu_t *prev,
sigar_cpu_t *curr,
sigar_cpu_perc_t *perc)
{
double diff_user, diff_sys, diff_nice, diff_idle, diff_wait, diff_total;
double diff_user, diff_sys, diff_nice, diff_idle;
double diff_wait, diff_irq, diff_soft_irq, diff_steal;
double diff_total;
diff_user = (sigar_int64_t)(curr->user - prev->user);
diff_sys = (sigar_int64_t)(curr->sys - prev->sys);
diff_nice = (sigar_int64_t)(curr->nice - prev->nice);
diff_idle = (sigar_int64_t)(curr->idle - prev->idle);
diff_wait = (sigar_int64_t)(curr->wait - prev->wait);
diff_irq = (sigar_int64_t)(curr->irq - prev->irq);
diff_soft_irq = (sigar_int64_t)(curr->soft_irq - prev->soft_irq);
diff_steal = (sigar_int64_t)(curr->steal - prev->steal);
diff_user = diff_user < 0 ? 0 : diff_user;
diff_sys = diff_sys < 0 ? 0 : diff_sys;
diff_nice = diff_nice < 0 ? 0 : diff_nice;
diff_idle = diff_idle < 0 ? 0 : diff_idle;
diff_wait = diff_wait < 0 ? 0 : diff_wait;
diff_irq = diff_irq < 0 ? 0 : diff_irq;
diff_soft_irq = diff_soft_irq < 0 ? 0 : diff_soft_irq;
diff_steal = diff_steal < 0 ? 0 : diff_steal;
diff_total =
diff_user + diff_sys + diff_nice + diff_idle + diff_wait;
diff_user + diff_sys + diff_nice + diff_idle +
diff_wait + diff_irq + diff_soft_irq +
diff_steal;
perc->user = diff_user / diff_total;
perc->sys = diff_sys / diff_total;
perc->nice = diff_nice / diff_total;
perc->idle = diff_idle / diff_total;
perc->wait = diff_wait / diff_total;
perc->irq = diff_irq / diff_total;
perc->soft_irq = diff_soft_irq / diff_total;
perc->steal = diff_steal / diff_total;
perc->combined =
perc->user + perc->sys + perc->nice + perc->wait;