use SIGAR_TICK2SEC macro

This commit is contained in:
Doug MacEachern 2005-05-12 03:20:13 +00:00
parent 08906a3a9b
commit 22316abc31
1 changed files with 6 additions and 7 deletions

View File

@ -304,7 +304,6 @@ int sigar_swap_get(sigar_t *sigar, sigar_swap_t *swap)
swap->free = sigar_meminfo(buffer, MEMINFO_PARAM("SwapFree")); swap->free = sigar_meminfo(buffer, MEMINFO_PARAM("SwapFree"));
swap->used = swap->total - swap->free; swap->used = swap->total - swap->free;
return SIGAR_OK; return SIGAR_OK;
} }
@ -312,13 +311,13 @@ static void get_cpu_metrics(sigar_t *sigar, sigar_cpu_t *cpu, char *line)
{ {
char *ptr = sigar_skip_token(line); /* "cpu%d" */ char *ptr = sigar_skip_token(line); /* "cpu%d" */
cpu->user += sigar_strtoul(ptr) / sigar->ticks; cpu->user += SIGAR_TICK2SEC(sigar_strtoul(ptr));
cpu->nice += sigar_strtoul(ptr) / sigar->ticks; cpu->nice += SIGAR_TICK2SEC(sigar_strtoul(ptr));
cpu->sys += sigar_strtoul(ptr) / sigar->ticks; cpu->sys += SIGAR_TICK2SEC(sigar_strtoul(ptr));
cpu->idle += sigar_strtoul(ptr) / sigar->ticks; cpu->idle += SIGAR_TICK2SEC(sigar_strtoul(ptr));
if (*ptr == ' ') { if (*ptr == ' ') {
/* 2.6+ kernels only */ /* 2.6+ kernels only */
cpu->wait += sigar_strtoul(ptr) / sigar->ticks; cpu->wait += SIGAR_TICK2SEC(sigar_strtoul(ptr));
} }
cpu->total += cpu->user + cpu->nice + cpu->sys + cpu->idle + cpu->wait; cpu->total += cpu->user + cpu->nice + cpu->sys + cpu->idle + cpu->wait;
} }
@ -876,7 +875,7 @@ int sigar_proc_modules_get(sigar_t *sigar, sigar_pid_t pid,
} }
#define TIME_NSEC(t) \ #define TIME_NSEC(t) \
SIGAR_SEC2NANO(((sigar_uint64_t)(t) / sigar->ticks)) SIGAR_SEC2NANO(SIGAR_TICK2SEC(((sigar_uint64_t)(t))))
int sigar_thread_cpu_get(sigar_t *sigar, int sigar_thread_cpu_get(sigar_t *sigar,
sigar_uint64_t id, sigar_uint64_t id,