=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/netstat/mbuf.c,v retrieving revision 1.39 retrieving revision 1.40 diff -c -r1.39 -r1.40 *** src/usr.bin/netstat/mbuf.c 2017/02/04 13:17:08 1.39 --- src/usr.bin/netstat/mbuf.c 2017/10/28 15:25:20 1.40 *************** *** 1,4 **** ! /* $OpenBSD: mbuf.c,v 1.39 2017/02/04 13:17:08 jsg Exp $ */ /* $NetBSD: mbuf.c,v 1.9 1996/05/07 02:55:03 thorpej Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: mbuf.c,v 1.40 2017/10/28 15:25:20 mikeb Exp $ */ /* $NetBSD: mbuf.c,v 1.9 1996/05/07 02:55:03 thorpej Exp $ */ /* *************** *** 87,95 **** void mbpr(void) { ! unsigned long totmem, totused, totmbufs; ! int totpct; ! int i, mib[4], npools; struct kinfo_pool pool; struct mbtypes *mp; size_t size; --- 87,94 ---- void mbpr(void) { ! unsigned long totmem, totpeak, totmbufs; ! int i, maxclusters, mib[4], npools; struct kinfo_pool pool; struct mbtypes *mp; size_t size; *************** *** 102,107 **** --- 101,116 ---- } mib[0] = CTL_KERN; + mib[1] = KERN_MAXCLUSTERS; + size = sizeof(maxclusters); + + if (sysctl(mib, 2, &maxclusters, &size, NULL, 0) < 0) { + printf("Can't retrieve value of maxclusters from the " + "kernel: %s\n", strerror(errno)); + return; + } + + mib[0] = CTL_KERN; mib[1] = KERN_MBSTAT; size = sizeof(mbstat); *************** *** 176,198 **** plural(mbstat.m_mtypes[i]), i); } totmem = (mbpool.pr_npages * mbpool.pr_pgsize); ! totused = mbpool.pr_nout * mbpool.pr_size; for (i = 0; i < mclp; i++) { ! printf("%u/%lu/%lu mbuf %d byte clusters in use" ! " (current/peak/max)\n", mclpools[i].pr_nout, (unsigned long) (mclpools[i].pr_hiwat * mclpools[i].pr_itemsperpage), - (unsigned long) - (mclpools[i].pr_maxpages * mclpools[i].pr_itemsperpage), mclpools[i].pr_size); totmem += (mclpools[i].pr_npages * mclpools[i].pr_pgsize); ! totused += mclpools[i].pr_nout * mclpools[i].pr_size; } ! totpct = (totmem == 0) ? 0 : (totused/(totmem / 100)); ! printf("%lu Kbytes allocated to network (%d%% in use)\n", ! totmem / 1024, totpct); printf("%lu requests for memory denied\n", mbstat.m_drops); printf("%lu requests for memory delayed\n", mbstat.m_wait); printf("%lu calls to protocol drain routines\n", mbstat.m_drain); --- 185,205 ---- plural(mbstat.m_mtypes[i]), i); } totmem = (mbpool.pr_npages * mbpool.pr_pgsize); ! totpeak = mbpool.pr_hiwat * mbpool.pr_pgsize; for (i = 0; i < mclp; i++) { ! printf("%u/%lu mbuf %d byte clusters in use" ! " (current/peak)\n", mclpools[i].pr_nout, (unsigned long) (mclpools[i].pr_hiwat * mclpools[i].pr_itemsperpage), mclpools[i].pr_size); totmem += (mclpools[i].pr_npages * mclpools[i].pr_pgsize); ! totpeak += mclpools[i].pr_hiwat * mclpools[i].pr_pgsize; } ! printf("%lu/%lu/%lu Kbytes allocated to network " ! "(current/peak/max)\n", totmem / 1024, totpeak / 1024, ! (unsigned long)(maxclusters * MCLBYTES) / 1024); printf("%lu requests for memory denied\n", mbstat.m_drops); printf("%lu requests for memory delayed\n", mbstat.m_wait); printf("%lu calls to protocol drain routines\n", mbstat.m_drain);