make more interesting
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Mon, 6 Dec 1982 15:51:08 +0000 (07:51 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Mon, 6 Dec 1982 15:51:08 +0000 (07:51 -0800)
SCCS-vsn: usr.bin/netstat/mbuf.c 4.2

usr/src/usr.bin/netstat/mbuf.c

index a13a52a..ee430bc 100644 (file)
@@ -1,8 +1,8 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)mbuf.c     4.1 82/08/25";
+static char sccsid[] = "@(#)mbuf.c     4.2 82/12/05";
 #endif
 
 #endif
 
-#include <sys/types.h>
+#include <sys/param.h>
 #include <sys/mbuf.h>
 
 struct mbstat mbstat;
 #include <sys/mbuf.h>
 
 struct mbstat mbstat;
@@ -14,15 +14,26 @@ extern      int kmem;
 mbpr(mbaddr)
        off_t mbaddr;
 {
 mbpr(mbaddr)
        off_t mbaddr;
 {
+       register int totmem, totfree;
+
        if (mbaddr == 0) {
                printf("mbstat: symbol not in namelist\n");
                return;
        }
        if (mbaddr == 0) {
                printf("mbstat: symbol not in namelist\n");
                return;
        }
-       printf("mbufs:");
+       printf("memory utilization:\n");
        klseek(kmem, mbaddr, 0);
        klseek(kmem, mbaddr, 0);
-       if (read(kmem, &mbstat, sizeof (mbstat)) == sizeof (mbstat))
-               printf(
-       " mbufs %d mbfree %d clusters %d clfree %d drops %d\n",
-               mbstat.m_mbufs, mbstat.m_mbfree,
-               mbstat.m_clusters, mbstat.m_clfree, mbstat.m_drops);
+       if (read(kmem, &mbstat, sizeof (mbstat)) != sizeof (mbstat)) {
+               printf("mbstat: bad read\n");
+               return;
+       }
+       printf("\t%d/%d mbufs in use\n", mbstat.m_mbufs - mbstat.m_mbfree,
+               mbstat.m_mbufs);
+       printf("\t%d/%d mapped pages in use\n",
+               mbstat.m_clusters - mbstat.m_clfree, mbstat.m_clusters);
+       printf("\t%d requests for memory denied\n", mbstat.m_drops);
+       totmem = mbstat.m_mbufs * MSIZE + mbstat.m_clusters * CLBYTES;
+       totfree = mbstat.m_mbfree * MSIZE + mbstat.m_clusters * CLBYTES;
+       printf("\t%dKbytes allocated to network (%d%% in use)\n",
+               totmem / 1024,
+               (totmem - totfree + totmem - 1) / totmem);
 }
 }