date and time created 90/06/25 13:56:22 by bostic
[unix-history] / usr / src / usr.bin / vmstat / vmstat.c
index 3c4f0c3..b3cba17 100644 (file)
@@ -2,17 +2,7 @@
  * Copyright (c) 1980 The Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1980 The Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * %sccs.include.redist.c%
  */
 
 #ifndef lint
  */
 
 #ifndef lint
@@ -22,7 +12,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)vmstat.c   5.14 (Berkeley) %G%";
+static char sccsid[] = "@(#)vmstat.c   5.21 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -30,8 +20,6 @@ static char sccsid[] = "@(#)vmstat.c  5.14 (Berkeley) %G%";
 #include <sys/vm.h>
 #include <sys/dkstat.h>
 #include <sys/buf.h>
 #include <sys/vm.h>
 #include <sys/dkstat.h>
 #include <sys/buf.h>
-#include <sys/dir.h>
-#include <sys/inode.h>
 #include <sys/namei.h>
 #include <sys/text.h>
 #include <sys/malloc.h>
 #include <sys/namei.h>
 #include <sys/text.h>
 #include <sys/malloc.h>
@@ -87,19 +75,24 @@ struct nlist nl[] = {
        { "_kmemstats" },
 #define        X_KMEMBUCKETS   22
        { "_bucket" },
        { "_kmemstats" },
 #define        X_KMEMBUCKETS   22
        { "_bucket" },
+#define X_END          22
 #ifdef vax
 #ifdef vax
-#define X_MBDINIT      (X_XSTATS+1)
+#define X_MBDINIT      (X_END+1)
        { "_mbdinit" },
        { "_mbdinit" },
-#define X_UBDINIT      (X_XSTATS+2)
+#define X_UBDINIT      (X_END+2)
        { "_ubdinit" },
 #endif
 #ifdef tahoe
        { "_ubdinit" },
 #endif
 #ifdef tahoe
-#define        X_VBDINIT       (X_XSTATS+1)
+#define        X_VBDINIT       (X_END+1)
        { "_vbdinit" },
        { "_vbdinit" },
-#define        X_CKEYSTATS     (X_XSTATS+2)
+#define        X_CKEYSTATS     (X_END+2)
        { "_ckeystats" },
        { "_ckeystats" },
-#define        X_DKEYSTATS     (X_XSTATS+3)
+#define        X_DKEYSTATS     (X_END+3)
        { "_dkeystats" },
        { "_dkeystats" },
+#endif
+#ifdef hp300
+#define        X_HPDINIT       (X_END+1)
+       { "_hp_dinit" },
 #endif
        { "" },
 };
 #endif
        { "" },
 };
@@ -111,8 +104,12 @@ int        ndrives = 0;
 #ifdef vax
 char   *defdrives[] = { "hp0", "hp1", "hp2",  0 };
 #else
 #ifdef vax
 char   *defdrives[] = { "hp0", "hp1", "hp2",  0 };
 #else
+#ifdef hp300
+char   *defdrives[] = { "rd0", "rd1", "rd2",  0 };
+#else
 char   *defdrives[] = { 0 };
 #endif
 char   *defdrives[] = { 0 };
 #endif
+#endif
 double stat1();
 int    firstfree, maxfree;
 int    hz;
 double stat1();
 int    firstfree, maxfree;
 int    hz;
@@ -440,14 +437,18 @@ dosum()
        printf("%9d system calls\n", sum.v_syscall);
        lseek(mf, (long)nl[X_NCHSTATS].n_value, 0);
        read(mf, &nchstats, sizeof nchstats);
        printf("%9d system calls\n", sum.v_syscall);
        lseek(mf, (long)nl[X_NCHSTATS].n_value, 0);
        read(mf, &nchstats, sizeof nchstats);
-       nchtotal = nchstats.ncs_goodhits + nchstats.ncs_badhits +
-           nchstats.ncs_falsehits + nchstats.ncs_miss + nchstats.ncs_long;
-       printf("%9d total name lookups", nchtotal);
-       printf(" (cache hits %d%% system %d%% per-process)\n",
-           pct(nchstats.ncs_goodhits, nchtotal),
+       nchtotal = nchstats.ncs_goodhits + nchstats.ncs_neghits +
+           nchstats.ncs_badhits + nchstats.ncs_falsehits +
+           nchstats.ncs_miss + nchstats.ncs_long;
+       printf("%9d total name lookups\n", nchtotal);
+       printf("%9s cache hits (%d%% pos + %d%% neg) system %d%% per-process\n",
+           "", pct(nchstats.ncs_goodhits, nchtotal),
+           pct(nchstats.ncs_neghits, nchtotal),
            pct(nchstats.ncs_pass2, nchtotal));
            pct(nchstats.ncs_pass2, nchtotal));
-       printf("%9s badhits %d, falsehits %d, toolong %d\n", "",
-           nchstats.ncs_badhits, nchstats.ncs_falsehits, nchstats.ncs_long);
+       printf("%9s deletions %d%%, falsehits %d%%, toolong %d%%\n", "",
+           pct(nchstats.ncs_badhits, nchtotal),
+           pct(nchstats.ncs_falsehits, nchtotal),
+           pct(nchstats.ncs_long, nchtotal));
        lseek(mf, (long)nl[X_XSTATS].n_value, 0);
        read(mf, &xstats, sizeof xstats);
        printf("%9d total calls to xalloc (cache hits %d%%)\n",
        lseek(mf, (long)nl[X_XSTATS].n_value, 0);
        read(mf, &xstats, sizeof xstats);
        printf("%9d total calls to xalloc (cache hits %d%%)\n",
@@ -581,8 +582,13 @@ char *kmemnames[] = {
        "fhandle",      /* 21 M_FHANDLE */
        "NFS req",      /* 22 M_NFSREQ */
        "NFS mount",    /* 23 M_NFSMNT */
        "fhandle",      /* 21 M_FHANDLE */
        "NFS req",      /* 22 M_NFSREQ */
        "NFS mount",    /* 23 M_NFSMNT */
-       0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0,
+       "vnodes",       /* 24 M_VNODE */
+       "namecache",    /* 25 M_CACHE */
+       "UFS quota",    /* 26 M_DQUOT */
+       "UFS mount",    /* 27 M_UFSMNT */
+       "mapmem",       /* 28 M_MAPMEM */
+       "shm",          /* 29 M_SHM */
+       0, 0, 0, 0,
        0, 0, 0, 0, 0,
        0, 0, 0, 0, 0,
        0, 0, 0, 0, 0,
        0, 0, 0, 0, 0,
        0, 0, 0, 0, 0,
        0, 0, 0, 0, 0,
@@ -708,3 +714,41 @@ read_names()
        }
 }
 #endif
        }
 }
 #endif
+
+#ifdef hp300
+#include <hpdev/device.h>
+
+#define validdisk(cp)  ((cp)[1] == 'd' && ((cp)[0] == 'r' || (cp)[0] == 's'))
+
+read_names()
+{
+       struct hp_device hdev;
+       register struct hp_device *hp;
+       struct driver hdrv;
+       short two_char;
+       char *cp = (char *) &two_char;
+       register char *dp;
+
+       hp = (struct hp_device *) nl[X_HPDINIT].n_value;
+       if (hp == 0) {
+               fprintf(stderr, "vmstat: Disk init info not in namelist\n");
+               exit(1);
+       }
+       for (;;) {
+               steal(hp++, hdev);
+               if (hdev.hp_driver == 0)
+                       break;
+               steal(hdev.hp_driver, hdrv);
+               steal(hdrv.d_name, two_char);
+               /*
+                * hp_dk is meaningless if the device isn't a disk
+                * (d_name not valid) or the disk was not found when
+                * booting (hp_alive == 0).
+                */
+               if (!validdisk(cp) || hdev.hp_alive == 0)
+                       continue;
+               dp = dr_name[hdev.hp_dk];
+               sprintf(dp, "%c%c%d", cp[0], cp[1], hdev.hp_unit);
+       }
+}
+#endif