|
|
1.1 root 1: /*
2: * Copyright (c) 1980 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: */
6:
7: #ifndef lint
8: static char sccsid[] = "@(#)mbufs.c 5.3 (Berkeley) 5/11/89";
9: #endif not lint
10:
11: #include "systat.h"
12: #include <sys/mbuf.h>
13: #include <paths.h>
14:
15: WINDOW *
16: openmbufs()
17: {
18: return (subwin(stdscr, LINES-5-1, 0, 5, 0));
19: }
20:
21: closembufs(w)
22: WINDOW *w;
23: {
24: if (w == NULL)
25: return;
26: wclear(w);
27: wrefresh(w);
28: delwin(w);
29: }
30:
31: struct mbstat *mb;
32:
33: labelmbufs()
34: {
35: wmove(wnd, 0, 0); wclrtoeol(wnd);
36: mvwaddstr(wnd, 0, 10,
37: "/0 /5 /10 /15 /20 /25 /30 /35 /40 /45 /50 /55 /60");
38: }
39:
40: char *mtnames[] = {
41: "free",
42: "data",
43: "headers",
44: "sockets",
45: "pcbs",
46: "routes",
47: "hosts",
48: "arps",
49: "socknames",
50: "zombies",
51: "sockopts",
52: "frags",
53: "rights",
54: "ifaddrs",
55: };
56: #define NNAMES (sizeof (mtnames) / sizeof (mtnames[0]))
57:
58: showmbufs()
59: {
60: register int i, j, max, index;
61: char buf[10];
62:
63: if (mb == 0)
64: return;
65: for (j = 0; j < wnd->_maxy; j++) {
66: max = 0, index = -1;
67: for (i = 0; i < wnd->_maxy; i++)
68: if (mb->m_mtypes[i] > max) {
69: max = mb->m_mtypes[i];
70: index = i;
71: }
72: if (max == 0)
73: break;
74: if (j > NNAMES)
75: mvwprintw(wnd, 1+j, 0, "%10d", index);
76: else
77: mvwprintw(wnd, 1+j, 0, "%-10.10s", mtnames[index]);
78: wmove(wnd, 1 + j, 10);
79: if (max > 60) {
80: sprintf(buf, " %d", max);
81: max = 60;
82: while (max--)
83: waddch(wnd, 'X');
84: waddstr(wnd, buf);
85: } else {
86: while (max--)
87: waddch(wnd, 'X');
88: wclrtoeol(wnd);
89: }
90: mb->m_mtypes[index] = 0;
91: }
92: wmove(wnd, 1+j, 0); wclrtobot(wnd);
93: }
94:
95: static struct nlist nlst[] = {
96: #define X_MBSTAT 0
97: { "_mbstat" },
98: { "" }
99: };
100:
101: initmbufs()
102: {
103: if (nlst[X_MBSTAT].n_type == 0) {
104: nlist(_PATH_UNIX, nlst);
105: if (nlst[X_MBSTAT].n_type == 0) {
106: error("namelist on %s failed", _PATH_UNIX);
107: return(0);
108: }
109: }
110: if (mb == 0)
111: mb = (struct mbstat *)calloc(1, sizeof (*mb));
112: return(1);
113: }
114:
115: fetchmbufs()
116: {
117: if (nlst[X_MBSTAT].n_type == 0)
118: return;
119: lseek(kmem, nlst[X_MBSTAT].n_value, L_SET);
120: read(kmem, mb, sizeof (*mb));
121: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.