simplify cpu_total wrapper

This commit is contained in:
Doug MacEachern 2004-07-19 19:49:32 +00:00
parent 87b502d76a
commit fd0b920b0d
3 changed files with 12 additions and 10 deletions

View File

@ -498,7 +498,7 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu)
if (sigar_perfstat_init(sigar) == SIGAR_OK) { if (sigar_perfstat_init(sigar) == SIGAR_OK) {
sigar_log(sigar, SIGAR_LOG_DEBUG, "[cpu] using libperfstat"); sigar_log(sigar, SIGAR_LOG_DEBUG, "[cpu] using libperfstat");
if (sigar->perfstat.cpu_total(0, &cpu_data, sizeof(cpu_data), 1)) { if (sigar->perfstat.cpu_total(&cpu_data, sizeof(cpu_data))) {
cpu->user = cpu_data.user; cpu->user = cpu_data.user;
cpu->nice = -1; /* N/A */ cpu->nice = -1; /* N/A */
cpu->sys = cpu_data.sys; cpu->sys = cpu_data.sys;
@ -743,7 +743,7 @@ int sigar_loadavg_get(sigar_t *sigar,
sigar_log(sigar, SIGAR_LOG_DEBUG, sigar_log(sigar, SIGAR_LOG_DEBUG,
"[loadavg] using libperfstat"); "[loadavg] using libperfstat");
if (sigar->perfstat.cpu_total(0, &cpu_data, sizeof(cpu_data), 1)) { if (sigar->perfstat.cpu_total(&cpu_data, sizeof(cpu_data))) {
for (i=0; i<3; i++) { for (i=0; i<3; i++) {
loadavg->loadavg[i] = FIXED_TO_DOUBLE(cpu_data.loadavg[i]); loadavg->loadavg[i] = FIXED_TO_DOUBLE(cpu_data.loadavg[i]);
} }
@ -1334,7 +1334,7 @@ static int sigar_get_cpu_mhz_perfstat(sigar_t *sigar)
perfstat_cpu_total_t data; perfstat_cpu_total_t data;
if (sigar_perfstat_init(sigar) == SIGAR_OK) { if (sigar_perfstat_init(sigar) == SIGAR_OK) {
if (sigar->perfstat.cpu_total(0, &data, sizeof(data), 1)) { if (sigar->perfstat.cpu_total(&data, sizeof(data))) {
sigar->cpu_mhz = data.processorHZ / 1000000; sigar->cpu_mhz = data.processorHZ / 1000000;
return SIGAR_OK; return SIGAR_OK;
} }

View File

@ -1,10 +1,14 @@
#include <libperfstat.h> #include <libperfstat.h>
int sigar_perfstat_cpu_total(perfstat_id_t *id, /*
perfstat_cpu_total_t *cpu_total, * ibm docs say:
int size, int num) * "name Must be set to NULL.
* desired_number Must be set to 1."
* so we just hardcode that in our wrapper.
*/
int sigar_perfstat_cpu_total(perfstat_cpu_total_t *cpu_total, int size)
{ {
return perfstat_cpu_total(id, cpu_total, size, num); return perfstat_cpu_total(NULL, cpu_total, size, 1);
} }
int sigar_perfstat_cpu(perfstat_id_t *id, int sigar_perfstat_cpu(perfstat_id_t *id,

View File

@ -27,9 +27,7 @@ typedef int (*vminfo_func_t) (void *, int, int);
typedef int (*proc_fd_func_t) (sigar_t *, sigar_pid_t, sigar_proc_fd_t *); typedef int (*proc_fd_func_t) (sigar_t *, sigar_pid_t, sigar_proc_fd_t *);
typedef int (*perfstat_cpu_total_func_t)(perfstat_id_t *, typedef int (*perfstat_cpu_total_func_t)(perfstat_cpu_total_t *, int);
perfstat_cpu_total_t *,
int, int);
typedef int (*perfstat_cpu_func_t)(perfstat_id_t *, typedef int (*perfstat_cpu_func_t)(perfstat_id_t *,
perfstat_cpu_t *, perfstat_cpu_t *,