make sigar_swap compatible with 2.6 kernel

This commit is contained in:
Doug MacEachern 2004-10-05 20:46:57 +00:00
parent e6d5124d9d
commit 314ddb41bf
1 changed files with 3 additions and 7 deletions

View File

@ -259,7 +259,6 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
int sigar_swap_get(sigar_t *sigar, sigar_swap_t *swap) int sigar_swap_get(sigar_t *sigar, sigar_swap_t *swap)
{ {
char buffer[BUFSIZ]; char buffer[BUFSIZ];
char *ptr;
/* XXX: we open/parse the same file here as sigar_mem_get */ /* XXX: we open/parse the same file here as sigar_mem_get */
int status = sigar_file2str(PROC_MEMINFO, int status = sigar_file2str(PROC_MEMINFO,
@ -269,13 +268,10 @@ int sigar_swap_get(sigar_t *sigar, sigar_swap_t *swap)
return status; return status;
} }
ptr = sigar_skip_line(buffer, sizeof(buffer)); swap->total = sigar_meminfo(buffer, MEMINFO_PARAM("SwapTotal"));
ptr = sigar_skip_line(ptr, 0); swap->free = sigar_meminfo(buffer, MEMINFO_PARAM("SwapFree"));
ptr = sigar_skip_token(ptr); /* "Swap:" */ swap->used = swap->total - swap->free;
swap->total = sigar_strtoul(ptr);
swap->used = sigar_strtoul(ptr);
swap->free = sigar_strtoul(ptr);
return SIGAR_OK; return SIGAR_OK;
} }