fillin swap

This commit is contained in:
Doug MacEachern 2004-09-06 04:25:29 +00:00
parent 3ba4a01afc
commit 6ecab7bba0
2 changed files with 19 additions and 3 deletions

View File

@ -7,6 +7,8 @@ int sigar_os_open(sigar_t **sigar)
{ {
*sigar = malloc(sizeof(**sigar)); *sigar = malloc(sizeof(**sigar));
(*sigar)->pagesize = getpagesize();
return SIGAR_OK; return SIGAR_OK;
} }
@ -45,9 +47,16 @@ 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)
{ {
swap->total = -1; struct tbl_swapinfo info;
swap->used = -1;
swap->free = -1; table(TBL_SWAPINFO, -1, &info, 1, sizeof(info));
swap->total = info.size;
swap->free = info.free;
swap->total *= sigar->pagesize;
swap->free *= sigar->pagesize;
swap->used = swap->total - swap->free;
return SIGAR_OK; return SIGAR_OK;
} }

View File

@ -1,6 +1,12 @@
#ifndef SIGAR_OS_H #ifndef SIGAR_OS_H
#define SIGAR_OS_H #define SIGAR_OS_H
#include <sys/table.h>
/* "i will *punch* you in the *face*" --will ferrell */
#undef idle
#undef usr
#undef sys
#include <sys/vm.h> #include <sys/vm.h>
#include <mach.h> #include <mach.h>
@ -9,6 +15,7 @@
struct sigar_t { struct sigar_t {
SIGAR_T_BASE; SIGAR_T_BASE;
int pagesize;
}; };
#endif /* SIGAR_OS_H */ #endif /* SIGAR_OS_H */