summaryrefslogtreecommitdiff
path: root/usr.bin/vmstat
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/vmstat')
-rw-r--r--usr.bin/vmstat/Makefile3
-rw-r--r--usr.bin/vmstat/vmstat.c44
2 files changed, 37 insertions, 10 deletions
diff --git a/usr.bin/vmstat/Makefile b/usr.bin/vmstat/Makefile
index 6ee77cedea3..2f5ce1caca2 100644
--- a/usr.bin/vmstat/Makefile
+++ b/usr.bin/vmstat/Makefile
@@ -1,7 +1,8 @@
-# $OpenBSD: Makefile,v 1.8 2007/12/15 03:43:41 deraadt Exp $
+# $OpenBSD: Makefile,v 1.9 2014/07/02 00:12:34 dlg Exp $
PROG= vmstat
+CPPFLAGS+= -D_LIBKVM
SRCS= dkstats.c vmstat.c
MAN= vmstat.8
DPADD= ${LIBKVM}
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c
index 9b798eb7998..d72aae4b373 100644
--- a/usr.bin/vmstat/vmstat.c
+++ b/usr.bin/vmstat/vmstat.c
@@ -1,5 +1,5 @@
/* $NetBSD: vmstat.c,v 1.29.4.1 1996/06/05 00:21:05 cgd Exp $ */
-/* $OpenBSD: vmstat.c,v 1.128 2014/04/08 14:04:11 mpi Exp $ */
+/* $OpenBSD: vmstat.c,v 1.129 2014/07/02 00:12:34 dlg Exp $ */
/*
* Copyright (c) 1980, 1986, 1991, 1993
@@ -887,7 +887,7 @@ domem(void)
}
static void
-print_pool(struct pool *pp, char *name)
+print_pool(struct kinfo_pool *pp, char *name)
{
static int first = 1;
char maxp[32];
@@ -968,7 +968,7 @@ dopool_sysctl(void)
{
int mib[4], npools, i;
long total = 0, inuse = 0;
- struct pool pool;
+ struct kinfo_pool pool;
size_t size;
mib[0] = CTL_KERN;
@@ -987,7 +987,7 @@ dopool_sysctl(void)
mib[1] = KERN_POOL;
mib[2] = KERN_POOL_POOL;
mib[3] = i;
- size = sizeof(struct pool);
+ size = sizeof(pool);
if (sysctl(mib, 4, &pool, &size, NULL, 0) < 0) {
if (errno == ENOENT)
continue;
@@ -1004,7 +1004,7 @@ dopool_sysctl(void)
print_pool(&pool, name);
inuse += (pool.pr_nget - pool.pr_nput) * pool.pr_size;
- total += pool.pr_npages * getpagesize(); /* XXX */
+ total += pool.pr_npages * pool.pr_pgsize;
}
inuse /= 1024;
@@ -1018,6 +1018,8 @@ dopool_kvm(void)
{
SIMPLEQ_HEAD(,pool) pool_head;
struct pool pool, *pp = &pool;
+ struct pool_allocator palloc;
+ struct kinfo_pool pi;
long total = 0, inuse = 0;
u_long addr;
@@ -1039,13 +1041,37 @@ dopool_kvm(void)
kvm_geterr(kd));
exit(1);
}
+ if (kvm_read(kd, (u_long)pp->pr_alloc,
+ &palloc, sizeof(palloc)) < 0) {
+ (void)fprintf(stderr,
+ "vmstat: pool allocator trashed: %s\n",
+ kvm_geterr(kd));
+ exit(1);
+ }
name[31] = '\0';
- print_pool(pp, name);
-
- inuse += (pp->pr_nget - pp->pr_nput) * pp->pr_size;
- total += pp->pr_npages * getpagesize(); /* XXX */
+ memset(&pi, 0, sizeof(pi));
+ pi.pr_size = pp->pr_size;
+ pi.pr_pgsize = palloc.pa_pagesz;
+ pi.pr_itemsperpage = pp->pr_itemsperpage;
+ pi.pr_minpages = pp->pr_minpages;
+ pi.pr_maxpages = pp->pr_maxpages;
+ pi.pr_hardlimit = pp->pr_hardlimit;
+ pi.pr_nout = pp->pr_nout;
+ pi.pr_nitems = pp->pr_nitems;
+ pi.pr_nget = pp->pr_nget;
+ pi.pr_nput = pp->pr_nput;
+ pi.pr_nfail = pp->pr_nfail;
+ pi.pr_npagealloc = pp->pr_npagealloc;
+ pi.pr_npagefree = pp->pr_npagefree;
+ pi.pr_hiwat = pp->pr_hiwat;
+ pi.pr_nidle = pp->pr_nidle;
+
+ print_pool(&pi, name);
+
+ inuse += (pi.pr_nget - pi.pr_nput) * pi.pr_size;
+ total += pi.pr_npages * pi.pr_pgsize;
addr = (u_long)SIMPLEQ_NEXT(pp, pr_poollist);
}