Add compiled-in MCLBYTES and MSIZE to conf/param.c, as 'mclbytes" and "msize".
Add code to netstat to use libkvm to for kernel variables "mclbytes" and "msize', and if found, use those for netstat -m rather than compiled-in defaults.
This commit is contained in:
parent
9bf924ecc4
commit
f0f7e53290
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: param.c,v 1.20 1997/01/30 10:16:18 tls Exp $ */
|
||||
/* $NetBSD: param.c,v 1.21 1997/02/28 00:14:19 jonathan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1989 Regents of the University of California.
|
||||
@ -197,3 +197,8 @@ int autoniceval = AUTONICEVAL;
|
||||
int autoniceval = 4; /* default + 4 */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Actual network mbuf sizes (read-only), for netstat.
|
||||
*/
|
||||
int msize = MSIZE;
|
||||
int mclbytes = MCLBYTES;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.9 1996/05/07 02:55:02 thorpej Exp $ */
|
||||
/* $NetBSD: main.c,v 1.10 1997/02/28 00:14:21 jonathan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1988, 1993
|
||||
@ -43,7 +43,7 @@ char copyright[] =
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)main.c 8.4 (Berkeley) 3/1/94";
|
||||
#else
|
||||
static char *rcsid = "$NetBSD: main.c,v 1.9 1996/05/07 02:55:02 thorpej Exp $";
|
||||
static char *rcsid = "$NetBSD: main.c,v 1.10 1997/02/28 00:14:21 jonathan Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -132,6 +132,10 @@ struct nlist nl[] = {
|
||||
{ "_mfchash" },
|
||||
#define N_VIFTABLE 31
|
||||
{ "_viftable" },
|
||||
#define N_MSIZE 32
|
||||
{ "_msize" },
|
||||
#define N_MCLBYTES 33
|
||||
{ "_mclbytes" },
|
||||
"",
|
||||
};
|
||||
|
||||
@ -326,7 +330,8 @@ main(argc, argv)
|
||||
exit(1);
|
||||
}
|
||||
if (mflag) {
|
||||
mbpr(nl[N_MBSTAT].n_value);
|
||||
mbpr(nl[N_MBSTAT].n_value, nl[N_MSIZE].n_value,
|
||||
nl[N_MCLBYTES].n_value);
|
||||
exit(0);
|
||||
}
|
||||
if (pflag) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mbuf.c,v 1.9 1996/05/07 02:55:03 thorpej Exp $ */
|
||||
/* $NetBSD: mbuf.c,v 1.10 1997/02/28 00:14:22 jonathan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1988, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)mbuf.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
static char *rcsid = "$NetBSD: mbuf.c,v 1.9 1996/05/07 02:55:03 thorpej Exp $";
|
||||
static char *rcsid = "$NetBSD: mbuf.c,v 1.10 1997/02/28 00:14:22 jonathan Exp $";
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -75,13 +75,16 @@ bool seen[256]; /* "have we seen this type yet?" */
|
||||
* Print mbuf statistics.
|
||||
*/
|
||||
void
|
||||
mbpr(mbaddr)
|
||||
mbpr(mbaddr, msizeaddr, mclbaddr)
|
||||
u_long mbaddr;
|
||||
u_long msizeaddr, mclbaddr;
|
||||
{
|
||||
register int totmem, totfree, totmbufs;
|
||||
register int i;
|
||||
register struct mbtypes *mp;
|
||||
|
||||
int mclbytes, msize;
|
||||
|
||||
if (nmbtypes != 256) {
|
||||
fprintf(stderr,
|
||||
"%s: unexpected change to mbstat; check source\n",
|
||||
@ -93,6 +96,17 @@ mbpr(mbaddr)
|
||||
__progname);
|
||||
return;
|
||||
}
|
||||
/*XXX*/
|
||||
if (msizeaddr != 0)
|
||||
kread(msizeaddr, (char *)&msize, sizeof (msize));
|
||||
else
|
||||
msize = MSIZE;
|
||||
if (mclbaddr != 0)
|
||||
kread(mclbaddr, (char *)&mclbytes, sizeof (mclbytes));
|
||||
else
|
||||
mclbytes = MCLBYTES;
|
||||
/*XXX*/
|
||||
|
||||
if (kread(mbaddr, (char *)&mbstat, sizeof (mbstat)))
|
||||
return;
|
||||
totmbufs = 0;
|
||||
@ -113,8 +127,8 @@ mbpr(mbaddr)
|
||||
}
|
||||
printf("%u/%u mapped pages in use\n",
|
||||
mbstat.m_clusters - mbstat.m_clfree, mbstat.m_clusters);
|
||||
totmem = totmbufs * MSIZE + mbstat.m_clusters * MCLBYTES;
|
||||
totfree = mbstat.m_clfree * MCLBYTES;
|
||||
totmem = totmbufs * msize + mbstat.m_clusters * mclbytes;
|
||||
totfree = mbstat.m_clfree * mclbytes;
|
||||
printf("%u Kbytes allocated to network (%d%% in use)\n",
|
||||
totmem / 1024, (totmem - totfree) * 100 / totmem);
|
||||
printf("%u requests for memory denied\n", mbstat.m_drops);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: netstat.h,v 1.6 1996/05/07 02:55:05 thorpej Exp $ */
|
||||
/* $NetBSD: netstat.h,v 1.7 1997/02/28 00:14:23 jonathan Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -70,7 +70,7 @@ void icmp_stats __P((u_long, char *));
|
||||
void igmp_stats __P((u_long, char *));
|
||||
void protopr __P((u_long, char *));
|
||||
|
||||
void mbpr(u_long);
|
||||
void mbpr(u_long, u_long, u_long);
|
||||
|
||||
void hostpr __P((u_long, u_long));
|
||||
void impstats __P((u_long, u_long));
|
||||
|
Loading…
Reference in New Issue
Block a user