- Use -H (instead of -h) to list all hash stats.
- Add '-h hashname' to only list the stats for hashname. - Add -L to list valid hashes - Fix up some whitespace
This commit is contained in:
parent
d5d43c487a
commit
ff1761be8e
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: vmstat.1,v 1.4 2001/11/26 07:52:46 wiz Exp $
|
||||
.\" $NetBSD: vmstat.1,v 1.5 2001/11/26 10:18:08 lukem Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
|
@ -72,7 +72,7 @@
|
|||
.Nd report virtual memory statistics
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl efhilmsUv
|
||||
.Op Fl efHilLmsUv
|
||||
.Bk -words
|
||||
.Op Fl M Ar core
|
||||
.Ek
|
||||
|
@ -83,6 +83,9 @@
|
|||
.Op Fl c Ar count
|
||||
.Ek
|
||||
.Bk -words
|
||||
.Op Fl h Ar hashname
|
||||
.Ek
|
||||
.Bk -words
|
||||
.Op Fl u Ar histname
|
||||
.Ek
|
||||
.Bk -words
|
||||
|
@ -116,12 +119,20 @@ interval is specified, the default is 1 second.
|
|||
Report the values of system event counters.
|
||||
.It Fl f
|
||||
Report fork statistics.
|
||||
.It Fl h
|
||||
Report hash table statistics.
|
||||
.It Fl h Ar hashname
|
||||
Report hash table statistics for
|
||||
.Ar hashname .
|
||||
.It Fl H
|
||||
Report all hash table statistics.
|
||||
.It Fl i
|
||||
Report the values of system interrupt counters.
|
||||
.It Fl l
|
||||
List the UVM histories being maintained by the kernel.
|
||||
.It Fl L
|
||||
List all the hashes supported for
|
||||
.Fl h
|
||||
and
|
||||
.Fl H .
|
||||
.It Fl m
|
||||
Report on the usage of kernel dynamic memory listed first by size of
|
||||
allocation and then by type of usage.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vmstat.c,v 1.87 2001/11/26 07:40:01 lukem Exp $ */
|
||||
/* $NetBSD: vmstat.c,v 1.88 2001/11/26 10:18:08 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2000, 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1986, 1991, 1993\n\
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 3/1/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: vmstat.c,v 1.87 2001/11/26 07:40:01 lukem Exp $");
|
||||
__RCSID("$NetBSD: vmstat.c,v 1.88 2001/11/26 10:18:08 lukem Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -219,12 +219,13 @@ kvm_t *kd;
|
|||
#define HISTLIST 1<<6
|
||||
#define HISTDUMP 1<<7
|
||||
#define HASHSTAT 1<<8
|
||||
#define HASHLIST 1<<9
|
||||
|
||||
void cpustats(void);
|
||||
void deref_kptr(const void *, void *, size_t, const char *);
|
||||
void dkstats(void);
|
||||
void doevcnt(int verbose);
|
||||
void dohashstat(int verbose);
|
||||
void dohashstat(int, int, const char *);
|
||||
void dointr(int verbose);
|
||||
void domem(void);
|
||||
void dopool(void);
|
||||
|
@ -258,12 +259,13 @@ main(int argc, char *argv[])
|
|||
int reps;
|
||||
char errbuf[_POSIX2_LINE_MAX];
|
||||
gid_t egid = getegid();
|
||||
const char *histname = NULL;
|
||||
const char *histname, *hashname;
|
||||
|
||||
histname = hashname = NULL;
|
||||
(void)setegid(getgid());
|
||||
memf = nlistf = NULL;
|
||||
interval = reps = todo = verbose = 0;
|
||||
while ((c = getopt(argc, argv, "c:efhilM:mN:suUvw:")) != -1) {
|
||||
while ((c = getopt(argc, argv, "c:efh:HilLM:mN:suUvw:")) != -1) {
|
||||
switch (c) {
|
||||
case 'c':
|
||||
reps = atoi(optarg);
|
||||
|
@ -275,6 +277,9 @@ main(int argc, char *argv[])
|
|||
todo |= FORKSTAT;
|
||||
break;
|
||||
case 'h':
|
||||
hashname = optarg;
|
||||
/* FALLTHROUGH */
|
||||
case 'H':
|
||||
todo |= HASHSTAT;
|
||||
break;
|
||||
case 'i':
|
||||
|
@ -283,6 +288,9 @@ main(int argc, char *argv[])
|
|||
case 'l':
|
||||
todo |= HISTLIST;
|
||||
break;
|
||||
case 'L':
|
||||
todo |= HASHLIST;
|
||||
break;
|
||||
case 'M':
|
||||
memf = optarg;
|
||||
break;
|
||||
|
@ -392,43 +400,46 @@ main(int argc, char *argv[])
|
|||
*/
|
||||
if ((todo & VMSTAT) == 0) {
|
||||
for (;;) {
|
||||
if (todo & (HISTLIST|HISTDUMP)) {
|
||||
if ((todo & (HISTLIST|HISTDUMP)) ==
|
||||
(HISTLIST|HISTDUMP))
|
||||
errx(1, "you may list or dump, but not both!");
|
||||
hist_traverse(todo, histname);
|
||||
putchar('\n');
|
||||
}
|
||||
if (todo & FORKSTAT) {
|
||||
doforkst();
|
||||
if (todo & (HISTLIST|HISTDUMP)) {
|
||||
if ((todo & (HISTLIST|HISTDUMP)) ==
|
||||
(HISTLIST|HISTDUMP))
|
||||
errx(1, "you may list or dump, but not both!");
|
||||
hist_traverse(todo, histname);
|
||||
putchar('\n');
|
||||
}
|
||||
if (todo & MEMSTAT) {
|
||||
domem();
|
||||
dopool();
|
||||
putchar('\n');
|
||||
}
|
||||
if (todo & SUMSTAT) {
|
||||
dosum();
|
||||
if (todo & FORKSTAT) {
|
||||
doforkst();
|
||||
putchar('\n');
|
||||
}
|
||||
if (todo & INTRSTAT) {
|
||||
dointr(verbose);
|
||||
if (todo & MEMSTAT) {
|
||||
domem();
|
||||
dopool();
|
||||
putchar('\n');
|
||||
}
|
||||
if (todo & EVCNTSTAT) {
|
||||
doevcnt(verbose);
|
||||
if (todo & SUMSTAT) {
|
||||
dosum();
|
||||
putchar('\n');
|
||||
}
|
||||
if (todo & HASHSTAT) {
|
||||
dohashstat(verbose);
|
||||
if (todo & INTRSTAT) {
|
||||
dointr(verbose);
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
if (reps >= 0 && --reps <=0)
|
||||
if (todo & EVCNTSTAT) {
|
||||
doevcnt(verbose);
|
||||
putchar('\n');
|
||||
}
|
||||
if (todo & (HASHLIST|HASHSTAT)) {
|
||||
if ((todo & (HASHLIST|HASHSTAT)) == (HASHLIST|HASHSTAT))
|
||||
errx(1,
|
||||
"you may list or display, but not both!");
|
||||
dohashstat(verbose, todo, hashname);
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
if (reps >= 0 && --reps <=0)
|
||||
break;
|
||||
sleep(interval);
|
||||
}
|
||||
sleep(interval);
|
||||
}
|
||||
} else
|
||||
dovmstat(interval, reps);
|
||||
exit(0);
|
||||
|
@ -1155,7 +1166,7 @@ struct kernel_hash {
|
|||
};
|
||||
|
||||
void
|
||||
dohashstat(int verbose)
|
||||
dohashstat(int verbose, int todo, const char *hashname)
|
||||
{
|
||||
LIST_HEAD(, generic) *hashtbl_list;
|
||||
TAILQ_HEAD(, generic) *hashtbl_tailq;
|
||||
|
@ -1167,12 +1178,40 @@ dohashstat(int verbose)
|
|||
|
||||
hashbuf = NULL;
|
||||
hashbufsize = 0;
|
||||
printf("%-16s %8s %8s %8s %8s %8s %8s\n",
|
||||
"", "total", "used", "util", "num", "average", "maximum");
|
||||
printf("%-16s %8s %8s %8s %8s %8s %8s\n",
|
||||
"hash table", "buckets", "buckets", "%", "items", "chain", "chain");
|
||||
|
||||
if (todo & HASHLIST) {
|
||||
const char *prefix = "";
|
||||
|
||||
printf("Supported hashes:\n\t");
|
||||
for (curhash = khashes; curhash->hashsize != -1; curhash++) {
|
||||
printf("%s%s",
|
||||
prefix, namelist[curhash->hashsize].n_name + 1);
|
||||
prefix = ", ";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (hashname != NULL) {
|
||||
for (curhash = khashes; curhash->hashsize != -1; curhash++) {
|
||||
if (strcmp(namelist[curhash->hashsize].n_name + 1,
|
||||
hashname) == 0)
|
||||
break;
|
||||
}
|
||||
if (curhash->hashsize == -1)
|
||||
errx(1, "%s: no such hash", hashname);
|
||||
}
|
||||
|
||||
printf(
|
||||
"%-16s %8s %8s %8s %8s %8s %8s\n"
|
||||
"%-16s %8s %8s %8s %8s %8s %8s\n",
|
||||
"", "total", "used", "util", "num", "average", "maximum",
|
||||
"hash table", "buckets", "buckets", "%", "items", "chain",
|
||||
"chain");
|
||||
|
||||
for (curhash = khashes; curhash->hashsize != -1; curhash++) {
|
||||
if (hashname != NULL &&
|
||||
strcmp(namelist[curhash->hashsize].n_name + 1, hashname))
|
||||
continue;
|
||||
elemsize = curhash->type == HASH_LIST ?
|
||||
sizeof(*hashtbl_list) : sizeof(*hashtbl_tailq);
|
||||
kread(curhash->hashsize, &hashsize, sizeof(hashsize));
|
||||
|
@ -1404,7 +1443,7 @@ usage(void)
|
|||
{
|
||||
|
||||
(void)fprintf(stderr,
|
||||
"usage: %s [-efhilmsUv] [-u histname] [-c count] [-M core] "
|
||||
"[-N system] [-w wait] [disks]\n", getprogname());
|
||||
"usage: %s [-efHilmsUv] [-h hashname] [-u histname] [-c count]\n"
|
||||
"\t\t[-M core] [-N system] [-w wait] [disks]\n", getprogname());
|
||||
exit(1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue