calculate sizeof within perfstat proxy
This commit is contained in:
parent
203a4bbd08
commit
148c562ff6
|
@ -624,7 +624,7 @@ static int sigar_swap_get_perfstat(sigar_t *sigar, sigar_swap_t *swap)
|
|||
SIGAR_ZERO(swap);
|
||||
|
||||
do {
|
||||
if (sigar->perfstat.swap(&id, &ps, sizeof(ps), 1) != 1) {
|
||||
if (sigar->perfstat.swap(&id, &ps, 1) != 1) {
|
||||
if (SIGAR_LOG_IS_DEBUG(sigar)) {
|
||||
sigar_log_printf(sigar, SIGAR_LOG_DEBUG,
|
||||
"[swap] dev=%s query failed: %s",
|
||||
|
@ -675,7 +675,7 @@ int sigar_cpu_get(sigar_t *sigar, sigar_cpu_t *cpu)
|
|||
if (sigar_perfstat_init(sigar) == SIGAR_OK) {
|
||||
sigar_log(sigar, SIGAR_LOG_DEBUG, "[cpu] using libperfstat");
|
||||
|
||||
if (sigar->perfstat.cpu_total(&cpu_data, sizeof(cpu_data)) == 1) {
|
||||
if (sigar->perfstat.cpu_total(&cpu_data) == 1) {
|
||||
cpu->user = SIGAR_TICK2MSEC(cpu_data.user);
|
||||
cpu->nice = SIGAR_FIELD_NOTIMPL; /* N/A */
|
||||
cpu->sys = SIGAR_TICK2MSEC(cpu_data.sys);
|
||||
|
@ -793,7 +793,7 @@ static int sigar_cpu_list_get_pstat(sigar_t *sigar, sigar_cpu_list_t *cpulist)
|
|||
i, id.name);
|
||||
}
|
||||
|
||||
if (sigar->perfstat.cpu(&id, &data, sizeof(data), 1) == 1) {
|
||||
if (sigar->perfstat.cpu(&id, &data, 1) == 1) {
|
||||
cpu->user = SIGAR_TICK2MSEC(data.user);
|
||||
cpu->nice = SIGAR_FIELD_NOTIMPL; /* N/A */
|
||||
cpu->sys = SIGAR_TICK2MSEC(data.sys);
|
||||
|
@ -935,7 +935,7 @@ int sigar_loadavg_get(sigar_t *sigar,
|
|||
sigar_log(sigar, SIGAR_LOG_DEBUG,
|
||||
"[loadavg] using libperfstat");
|
||||
|
||||
if (sigar->perfstat.cpu_total(&cpu_data, sizeof(cpu_data)) == 1) {
|
||||
if (sigar->perfstat.cpu_total(&cpu_data) == 1) {
|
||||
for (i=0; i<3; i++) {
|
||||
loadavg->loadavg[i] = FIXED_TO_DOUBLE(cpu_data.loadavg[i]);
|
||||
}
|
||||
|
@ -1560,7 +1560,7 @@ static int create_diskmap_v5(sigar_t *sigar)
|
|||
return SIGAR_ENOTIMPL;
|
||||
}
|
||||
|
||||
total = sigar->perfstat.disk(NULL, NULL, sizeof(*disk), 0);
|
||||
total = sigar->perfstat.disk(NULL, NULL, 0);
|
||||
if (total < 1) {
|
||||
return ENOENT;
|
||||
}
|
||||
|
@ -1568,7 +1568,7 @@ static int create_diskmap_v5(sigar_t *sigar)
|
|||
disk = malloc(total * sizeof(*disk));
|
||||
id.name[0] = '\0';
|
||||
|
||||
num = sigar->perfstat.disk(&id, disk, sizeof(*disk), total);
|
||||
num = sigar->perfstat.disk(&id, disk, total);
|
||||
if (num < 1) {
|
||||
free(disk);
|
||||
return ENOENT;
|
||||
|
@ -1645,7 +1645,7 @@ static int get_perfstat_disk_metrics(sigar_t *sigar,
|
|||
|
||||
SIGAR_SSTRCPY(id.name, diskio->name);
|
||||
|
||||
if (sigar->perfstat.disk(&id, &disk, sizeof(disk), 1) != 1) {
|
||||
if (sigar->perfstat.disk(&id, &disk, 1) != 1) {
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
|
@ -1823,7 +1823,7 @@ static int sigar_get_cpu_mhz_perfstat(sigar_t *sigar)
|
|||
perfstat_cpu_total_t data;
|
||||
|
||||
if (sigar_perfstat_init(sigar) == SIGAR_OK) {
|
||||
if (sigar->perfstat.cpu_total(&data, sizeof(data)) == 1) {
|
||||
if (sigar->perfstat.cpu_total(&data) == 1) {
|
||||
sigar->cpu_mhz = data.processorHZ / 1000000;
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
|
|
@ -25,40 +25,36 @@
|
|||
* 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, size_t size)
|
||||
int sigar_perfstat_cpu_total(perfstat_cpu_total_t *cpu_total)
|
||||
{
|
||||
return perfstat_cpu_total(NULL, cpu_total, size, 1);
|
||||
return perfstat_cpu_total(NULL, cpu_total, sizeof(*cpu_total), 1);
|
||||
}
|
||||
|
||||
int sigar_perfstat_cpu(perfstat_id_t *id,
|
||||
perfstat_cpu_t *cpu,
|
||||
size_t size, int num)
|
||||
int num)
|
||||
{
|
||||
return perfstat_cpu(id, cpu, size, num);
|
||||
return perfstat_cpu(id, cpu, sizeof(*cpu), num);
|
||||
}
|
||||
|
||||
int sigar_perfstat_pagingspace(perfstat_id_t *id,
|
||||
perfstat_pagingspace_t *pagingspace,
|
||||
size_t size,
|
||||
int num)
|
||||
{
|
||||
return perfstat_pagingspace(id, pagingspace, size, num);
|
||||
return perfstat_pagingspace(id, pagingspace, sizeof(*pagingspace), num);
|
||||
}
|
||||
|
||||
int sigar_perfstat_memory_total(perfstat_id_t *id,
|
||||
perfstat_memory_total_t *memory,
|
||||
size_t size,
|
||||
int num)
|
||||
int sigar_perfstat_memory(perfstat_id_t *id,
|
||||
perfstat_memory_total_t *memory)
|
||||
{
|
||||
return perfstat_memory_total(id, memory, size, num);
|
||||
return perfstat_memory_total(id, memory, sizeof(*memory), 1);
|
||||
}
|
||||
|
||||
int sigar_perfstat_disk(perfstat_id_t *id,
|
||||
perfstat_disk_t *disk,
|
||||
size_t size,
|
||||
int num)
|
||||
{
|
||||
return perfstat_disk(id, disk, size, num);
|
||||
return perfstat_disk(id, disk, sizeof(*disk), num);
|
||||
}
|
||||
|
||||
int sigar_perfstat_diskadapter(perfstat_id_t *id,
|
||||
|
@ -71,10 +67,9 @@ int sigar_perfstat_diskadapter(perfstat_id_t *id,
|
|||
|
||||
int sigar_perfstat_diskpath(perfstat_id_t *id,
|
||||
perfstat_diskpath_t *diskpath,
|
||||
size_t size,
|
||||
int num)
|
||||
{
|
||||
return perfstat_diskpath(id, diskpath, size, num);
|
||||
return perfstat_diskpath(id, diskpath, sizeof(*diskpath), num);
|
||||
}
|
||||
|
||||
int sigar_perfstat_netinterface(perfstat_id_t *id,
|
||||
|
@ -87,18 +82,16 @@ int sigar_perfstat_netinterface(perfstat_id_t *id,
|
|||
|
||||
int sigar_perfstat_netbuffer(perfstat_id_t *id,
|
||||
perfstat_netbuffer_t *netbuffer,
|
||||
size_t size,
|
||||
int num)
|
||||
{
|
||||
return perfstat_netbuffer(id, netbuffer, size, num);
|
||||
return perfstat_netbuffer(id, netbuffer, sizeof(*netbuffer), num);
|
||||
}
|
||||
|
||||
int sigar_perfstat_protocol(perfstat_id_t *id,
|
||||
perfstat_protocol_t *proto,
|
||||
int size,
|
||||
int num)
|
||||
{
|
||||
return perfstat_protocol(id, proto, size, num);
|
||||
return perfstat_protocol(id, proto, sizeof(*proto), num);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -48,19 +48,19 @@ 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 (*perfstat_cpu_total_func_t)(perfstat_cpu_total_t *, size_t);
|
||||
typedef int (*perfstat_cpu_total_func_t)(perfstat_cpu_total_t *);
|
||||
|
||||
typedef int (*perfstat_cpu_func_t)(perfstat_id_t *,
|
||||
perfstat_cpu_t *,
|
||||
size_t, int);
|
||||
int);
|
||||
|
||||
typedef int (*perfstat_swap_func_t)(perfstat_id_t *,
|
||||
perfstat_pagingspace_t *,
|
||||
size_t, int);
|
||||
int);
|
||||
|
||||
typedef int (*perfstat_disk_func_t)(perfstat_id_t *,
|
||||
perfstat_disk_t *,
|
||||
size_t, int);
|
||||
int);
|
||||
|
||||
typedef int (*perfstat_ifstat_func_t)(perfstat_id_t *,
|
||||
perfstat_netinterface_t *);
|
||||
|
|
Loading…
Reference in New Issue