OpenBSD vmstat impl
This commit is contained in:
parent
29137cc5ae
commit
717c1df381
|
@ -356,6 +356,18 @@ static int sigar_vmstat(sigar_t *sigar, struct vmmeter *vmstat)
|
||||||
|
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
static int sigar_vmstat(sigar_t *sigar, struct uvmexp *vmstat)
|
||||||
|
{
|
||||||
|
size_t size = sizeof(*vmstat);
|
||||||
|
int mib[] = { CTL_VM, VM_UVMEXP };
|
||||||
|
if (sysctl(mib, NMIB(mib), vmstat, &size, NULL, 0) < 0) {
|
||||||
|
return errno;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return SIGAR_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
|
int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
|
||||||
|
@ -365,7 +377,11 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
|
||||||
uint64_t mem_total;
|
uint64_t mem_total;
|
||||||
#else
|
#else
|
||||||
unsigned long mem_total;
|
unsigned long mem_total;
|
||||||
|
#endif
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
struct vmmeter vmstat;
|
struct vmmeter vmstat;
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
struct uvmexp vmstat;
|
||||||
#endif
|
#endif
|
||||||
int mib[2];
|
int mib[2];
|
||||||
size_t len;
|
size_t len;
|
||||||
|
@ -402,8 +418,11 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
|
||||||
mem->free = vmstat.v_free_count;
|
mem->free = vmstat.v_free_count;
|
||||||
mem->free *= sigar->pagesize;
|
mem->free *= sigar->pagesize;
|
||||||
}
|
}
|
||||||
#else
|
#elif defined(__OpenBSD__)
|
||||||
mem->free = -1; /*XXX OpenBSD*/
|
if ((status = sigar_vmstat(sigar, &vmstat)) != SIGAR_OK) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
mem->free = vmstat.free;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mem->used = mem->total - mem->free;
|
mem->used = mem->total - mem->free;
|
||||||
|
|
Loading…
Reference in New Issue