version 1.26, 2007/12/19 01:47:00 |
version 1.27, 2008/12/04 05:59:57 |
|
|
#include <sys/mbuf.h> |
#include <sys/mbuf.h> |
#include <sys/pool.h> |
#include <sys/pool.h> |
#include <sys/sysctl.h> |
#include <sys/sysctl.h> |
|
#include <net/if.h> |
|
|
#include <errno.h> |
#include <errno.h> |
#include <kvm.h> |
#include <kvm.h> |
|
|
typedef int bool; |
typedef int bool; |
|
|
struct mbstat mbstat; |
struct mbstat mbstat; |
struct pool mbpool, mclpool; |
struct pool mbpool, mclpools[MCLPOOLS]; |
|
int mclp; |
|
char *mclnames[] = { |
|
"mcl2k", "mcl4k", "mcl8k", "mcl9k", "mcl12k", "mcl16k", "mcl64k" |
|
}; |
|
char **mclnamep = mclnames; |
|
|
extern kvm_t *kvmd; |
extern kvm_t *kvmd; |
|
|
|
|
mbpr(void) |
mbpr(void) |
{ |
{ |
int totmem, totused, totmbufs, totpct; |
int totmem, totused, totmbufs, totpct; |
int i, mib[4], npools, flag = 0; |
int i, mib[4], npools; |
struct pool pool; |
struct pool pool; |
struct mbtypes *mp; |
struct mbtypes *mp; |
size_t size; |
size_t size; |
|
|
return; |
return; |
} |
} |
|
|
if (!strncmp(name, "mbpl", strlen("mbpl"))) { |
if (!strncmp(name, "mbpl", strlen("mbpl"))) |
bcopy(&pool, &mbpool, sizeof(struct pool)); |
bcopy(&pool, &mbpool, sizeof(struct pool)); |
flag++; |
else if (mclp < nitems(mclpools) && |
} else { |
!strncmp(name, *mclnamep, strlen(*mclnamep))) { |
if (!strncmp(name, "mclpl", strlen("mclpl"))) { |
printf("%s\n", name); |
bcopy(&pool, &mclpool, |
bcopy(&pool, &mclpools[mclp++], |
sizeof(struct pool)); |
sizeof(struct pool)); |
flag++; |
mclnamep++; |
} |
|
} |
} |
|
|
if (flag == 2) |
|
break; |
|
} |
} |
|
|
totmbufs = 0; |
totmbufs = 0; |
|
|
mbstat.m_mtypes[i], |
mbstat.m_mtypes[i], |
plural((int)mbstat.m_mtypes[i]), i); |
plural((int)mbstat.m_mtypes[i]), i); |
} |
} |
printf("%lu/%lu/%lu mbuf clusters in use (current/peak/max)\n", |
totmem = (mbpool.pr_npages * page_size); |
(u_long)(mclpool.pr_nout), |
totused = mbpool.pr_nout * mbpool.pr_size; |
(u_long)(mclpool.pr_hiwat * mclpool.pr_itemsperpage), |
for (i = 0; i < mclp; i++) { |
(u_long)(mclpool.pr_maxpages * mclpool.pr_itemsperpage)); |
printf("%lu/%lu/%lu mbuf %d byte clusters in use (current/peak/max)\n", |
totmem = (mbpool.pr_npages * page_size) + |
(u_long)(mclpools[i].pr_nout), |
(mclpool.pr_npages * page_size); |
(u_long)(mclpools[i].pr_hiwat * mclpools[i].pr_itemsperpage), |
totused = mbpool.pr_nout * mbpool.pr_size + |
(u_long)(mclpools[i].pr_maxpages * mclpools[i].pr_itemsperpage), |
mclpool.pr_nout * mclpool.pr_size; |
mclpools[i].pr_size); |
|
totmem += (mclpools[i].pr_npages * page_size); |
|
totused += mclpools[i].pr_nout * mclpools[i].pr_size; |
|
} |
|
|
totpct = (totmem == 0)? 0 : ((totused * 100)/totmem); |
totpct = (totmem == 0)? 0 : ((totused * 100)/totmem); |
printf("%u Kbytes allocated to network (%d%% in use)\n", |
printf("%u Kbytes allocated to network (%d%% in use)\n", |
totmem / 1024, totpct); |
totmem / 1024, totpct); |