Extend "systat vm" output to provide better insight about buffercache and document it. From Greg A. Woods in PR bin/36542diff -r1.28 -r1.29 src/usr.bin/systat/bufcache.c
(sevan)
--- src/usr.bin/systat/bufcache.c 2017/06/09 00:13:29 1.28
+++ src/usr.bin/systat/bufcache.c 2018/12/26 01:47:37 1.29
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: bufcache.c,v 1.28 2017/06/09 00:13:29 chs Exp $ */ | 1 | /* $NetBSD: bufcache.c,v 1.29 2018/12/26 01:47:37 sevan Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1999 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1999 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Simon Burge. | 8 | * by Simon Burge. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -21,27 +21,27 @@ | @@ -21,27 +21,27 @@ | |||
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | #ifndef lint | 33 | #ifndef lint | |
34 | __RCSID("$NetBSD: bufcache.c,v 1.28 2017/06/09 00:13:29 chs Exp $"); | 34 | __RCSID("$NetBSD: bufcache.c,v 1.29 2018/12/26 01:47:37 sevan Exp $"); | |
35 | #endif /* not lint */ | 35 | #endif /* not lint */ | |
36 | 36 | |||
37 | #include <sys/param.h> | 37 | #include <sys/param.h> | |
38 | #include <sys/buf.h> | 38 | #include <sys/buf.h> | |
39 | #define __EXPOSE_MOUNT | 39 | #define __EXPOSE_MOUNT | |
40 | #include <sys/mount.h> | 40 | #include <sys/mount.h> | |
41 | #include <sys/sysctl.h> | 41 | #include <sys/sysctl.h> | |
42 | #include <sys/vnode.h> | 42 | #include <sys/vnode.h> | |
43 | 43 | |||
44 | #include <uvm/uvm_extern.h> | 44 | #include <uvm/uvm_extern.h> | |
45 | 45 | |||
46 | #include <err.h> | 46 | #include <err.h> | |
47 | #include <errno.h> | 47 | #include <errno.h> | |
@@ -107,28 +107,28 @@ closebufcache(WINDOW *w) | @@ -107,28 +107,28 @@ closebufcache(WINDOW *w) | |||
107 | delwin(w); | 107 | delwin(w); | |
108 | ml_init(); /* Clear out mount list */ | 108 | ml_init(); /* Clear out mount list */ | |
109 | } | 109 | } | |
110 | 110 | |||
111 | void | 111 | void | |
112 | labelbufcache(void) | 112 | labelbufcache(void) | |
113 | { | 113 | { | |
114 | int i; | 114 | int i; | |
115 | 115 | |||
116 | for (i = 0; i <= PAGEINFO_ROWS; i++) { | 116 | for (i = 0; i <= PAGEINFO_ROWS; i++) { | |
117 | wmove(wnd, i, 0); | 117 | wmove(wnd, i, 0); | |
118 | wclrtoeol(wnd); | 118 | wclrtoeol(wnd); | |
119 | } | 119 | } | |
120 | mvwaddstr(wnd, PAGEINFO_ROWS + 1, 0, "File System Bufs used" | 120 | mvwaddstr(wnd, PAGEINFO_ROWS + 1, 0, | |
121 | " % kB in use % Bufsize kB % Util %"); | 121 | "File System Bufs used % kB in use % Bufsize kB % Util %"); | |
122 | wclrtoeol(wnd); | 122 | wclrtoeol(wnd); | |
123 | } | 123 | } | |
124 | 124 | |||
125 | void | 125 | void | |
126 | showbufcache(void) | 126 | showbufcache(void) | |
127 | { | 127 | { | |
128 | int tbuf, i, lastrow; | 128 | int tbuf, i, lastrow; | |
129 | double tvalid, tsize; | 129 | double tvalid, tsize; | |
130 | struct ml_entry *ml; | 130 | struct ml_entry *ml; | |
131 | size_t len; | 131 | size_t len; | |
132 | static int mib[] = { -1, 0 }; | 132 | static int mib[] = { -1, 0 }; | |
133 | 133 | |||
134 | if (mib[0] == -1) { | 134 | if (mib[0] == -1) { |
--- src/usr.bin/systat/cmdtab.c 2016/08/02 15:56:09 1.25
+++ src/usr.bin/systat/cmdtab.c 2018/12/26 01:47:37 1.26
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: cmdtab.c,v 1.25 2016/08/02 15:56:09 scole Exp $ */ | 1 | /* $NetBSD: cmdtab.c,v 1.26 2018/12/26 01:47:37 sevan Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1980, 1992, 1993 | 4 | * Copyright (c) 1980, 1992, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -24,44 +24,45 @@ | @@ -24,44 +24,45 @@ | |||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
29 | * SUCH DAMAGE. | 29 | * SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | #ifndef lint | 33 | #ifndef lint | |
34 | #if 0 | 34 | #if 0 | |
35 | static char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93"; | 35 | static char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93"; | |
36 | #endif | 36 | #endif | |
37 | __RCSID("$NetBSD: cmdtab.c,v 1.25 2016/08/02 15:56:09 scole Exp $"); | 37 | __RCSID("$NetBSD: cmdtab.c,v 1.26 2018/12/26 01:47:37 sevan Exp $"); | |
38 | #endif /* not lint */ | 38 | #endif /* not lint */ | |
39 | 39 | |||
40 | #include "systat.h" | 40 | #include "systat.h" | |
41 | #include "extern.h" | 41 | #include "extern.h" | |
42 | 42 | |||
43 | /* | 43 | /* | |
44 | * NOTE: if one command is a substring of another, the shorter string | 44 | * NOTE: if one command is a substring of another, the shorter string | |
45 | * MUST come first, or it will be shadowed by the longer | 45 | * MUST come first, or it will be shadowed by the longer | |
46 | */ | 46 | */ | |
47 | 47 | |||
48 | struct command global_commands[] = { | 48 | struct command global_commands[] = { | |
49 | { "help", global_help, "show help"}, | 49 | { "help", global_help, "show help"}, | |
50 | { "interval", global_interval, "set update interval"}, | 50 | { "interval", global_interval, "set update interval"}, | |
51 | { "load", global_load, "show system load averages"}, | 51 | { "load", global_load, "show system load averages"}, | |
52 | { "quit", global_quit, "exit systat"}, | 52 | { "quit", global_quit, "exit systat"}, | |
53 | { "start", global_interval, "restart updating display"}, | 53 | { "start", global_interval, "restart updating display"}, | |
54 | { "stop", global_stop, "stop updating display"}, | 54 | { "stop", global_stop, "stop updating display"}, | |
55 | { "?", global_help, "show help"}, | |||
55 | { .c_name = NULL } | 56 | { .c_name = NULL } | |
56 | }; | 57 | }; | |
57 | 58 | |||
58 | struct command df_commands[] = { | 59 | struct command df_commands[] = { | |
59 | { "all", df_all, "show all filesystems"}, | 60 | { "all", df_all, "show all filesystems"}, | |
60 | { "some", df_some, "show only some filesystems"}, | 61 | { "some", df_some, "show only some filesystems"}, | |
61 | { .c_name = NULL } | 62 | { .c_name = NULL } | |
62 | }; | 63 | }; | |
63 | 64 | |||
64 | struct command icmp_commands[] = { | 65 | struct command icmp_commands[] = { | |
65 | { "boot", icmp_boot, "show total stats since boot"}, | 66 | { "boot", icmp_boot, "show total stats since boot"}, | |
66 | { "run", icmp_run, "show running total stats"}, | 67 | { "run", icmp_run, "show running total stats"}, | |
67 | { "time", icmp_time, "show stats for each sample time"}, | 68 | { "time", icmp_time, "show stats for each sample time"}, | |
@@ -104,27 +105,27 @@ struct command ip6_commands[] = { | @@ -104,27 +105,27 @@ struct command ip6_commands[] = { | |||
104 | { "time", ip6_time, "show stats for each sample time"}, | 105 | { "time", ip6_time, "show stats for each sample time"}, | |
105 | { "zero", ip6_zero, "re-zero running totals"}, | 106 | { "zero", ip6_zero, "re-zero running totals"}, | |
106 | { .c_name = NULL } | 107 | { .c_name = NULL } | |
107 | }; | 108 | }; | |
108 | #endif | 109 | #endif | |
109 | 110 | |||
110 | struct command netstat_commands[] = { | 111 | struct command netstat_commands[] = { | |
111 | { "all", netstat_all, "include server sockets"}, | 112 | { "all", netstat_all, "include server sockets"}, | |
112 | { "display", netstat_display, "show specified hosts or ports"}, | 113 | { "display", netstat_display, "show specified hosts or ports"}, | |
113 | { "ignore", netstat_ignore, "hide specified hosts or ports"}, | 114 | { "ignore", netstat_ignore, "hide specified hosts or ports"}, | |
114 | { "names", netstat_names, "show names instead of addresses"}, | 115 | { "names", netstat_names, "show names instead of addresses"}, | |
115 | { "numbers", netstat_numbers, "show addresses instead of names"}, | 116 | { "numbers", netstat_numbers, "show addresses instead of names"}, | |
116 | { "reset", netstat_reset, "return to default display"}, | 117 | { "reset", netstat_reset, "return to default display"}, | |
117 | { "show", netstat_show, "show current display/ignore settings"}, | 118 | { "show", netstat_show, "show current display/ignore settings"}, | |
118 | { "tcp", netstat_tcp, "show only tcp connections"}, | 119 | { "tcp", netstat_tcp, "show only tcp connections"}, | |
119 | { "udp", netstat_udp, "show only udp connections"}, | 120 | { "udp", netstat_udp, "show only udp connections"}, | |
120 | { .c_name = NULL } | 121 | { .c_name = NULL } | |
121 | }; | 122 | }; | |
122 | 123 | |||
123 | struct command ps_commands[] = { | 124 | struct command ps_commands[] = { | |
124 | { "user", ps_user, "limit displayed processes to a user"}, | 125 | { "user", ps_user, "limit displayed processes to a user"}, | |
125 | { .c_name = NULL } | 126 | { .c_name = NULL } | |
126 | }; | 127 | }; | |
127 | 128 | |||
128 | struct command tcp_commands[] = { | 129 | struct command tcp_commands[] = { | |
129 | { "boot", tcp_boot, "show total stats since boot"}, | 130 | { "boot", tcp_boot, "show total stats since boot"}, | |
130 | { "run", tcp_run, "show running total stats"}, | 131 | { "run", tcp_run, "show running total stats"}, |
--- src/usr.bin/systat/main.c 2017/11/22 02:52:42 1.53
+++ src/usr.bin/systat/main.c 2018/12/26 01:47:37 1.54
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: main.c,v 1.53 2017/11/22 02:52:42 snj Exp $ */ | 1 | /* $NetBSD: main.c,v 1.54 2018/12/26 01:47:37 sevan Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1980, 1992, 1993 | 4 | * Copyright (c) 1980, 1992, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -26,27 +26,27 @@ | @@ -26,27 +26,27 @@ | |||
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
29 | * SUCH DAMAGE. | 29 | * SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | #ifndef lint | 33 | #ifndef lint | |
34 | __COPYRIGHT("@(#) Copyright (c) 1980, 1992, 1993\ | 34 | __COPYRIGHT("@(#) Copyright (c) 1980, 1992, 1993\ | |
35 | The Regents of the University of California. All rights reserved."); | 35 | The Regents of the University of California. All rights reserved."); | |
36 | #if 0 | 36 | #if 0 | |
37 | static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93"; | 37 | static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93"; | |
38 | #endif | 38 | #endif | |
39 | __RCSID("$NetBSD: main.c,v 1.53 2017/11/22 02:52:42 snj Exp $"); | 39 | __RCSID("$NetBSD: main.c,v 1.54 2018/12/26 01:47:37 sevan Exp $"); | |
40 | #endif /* not lint */ | 40 | #endif /* not lint */ | |
41 | 41 | |||
42 | #include <sys/param.h> | 42 | #include <sys/param.h> | |
43 | #include <sys/sysctl.h> | 43 | #include <sys/sysctl.h> | |
44 | #include <sys/ioctl.h> | 44 | #include <sys/ioctl.h> | |
45 | 45 | |||
46 | #include <ctype.h> | 46 | #include <ctype.h> | |
47 | #include <err.h> | 47 | #include <err.h> | |
48 | #include <errno.h> | 48 | #include <errno.h> | |
49 | #include <limits.h> | 49 | #include <limits.h> | |
50 | #include <signal.h> | 50 | #include <signal.h> | |
51 | #include <stdarg.h> | 51 | #include <stdarg.h> | |
52 | #include <stdio.h> | 52 | #include <stdio.h> | |
@@ -56,27 +56,27 @@ __RCSID("$NetBSD: main.c,v 1.53 2017/11/ | @@ -56,27 +56,27 @@ __RCSID("$NetBSD: main.c,v 1.53 2017/11/ | |||
56 | #include <termios.h> | 56 | #include <termios.h> | |
57 | 57 | |||
58 | #include "systat.h" | 58 | #include "systat.h" | |
59 | #include "extern.h" | 59 | #include "extern.h" | |
60 | 60 | |||
61 | static int dellave; | 61 | static int dellave; | |
62 | 62 | |||
63 | kvm_t *kd; | 63 | kvm_t *kd; | |
64 | char *memf = NULL; | 64 | char *memf = NULL; | |
65 | char *nlistf = NULL; | 65 | char *nlistf = NULL; | |
66 | sig_t sigtstpdfl; | 66 | sig_t sigtstpdfl; | |
67 | double avenrun[3]; | 67 | double avenrun[3]; | |
68 | int col; | 68 | int col; | |
69 | double naptime = 5; | 69 | double naptime = 1; | |
70 | int verbose = 1; /* to report kvm read errs */ | 70 | int verbose = 1; /* to report kvm read errs */ | |
71 | int hz, stathz, maxslp; | 71 | int hz, stathz, maxslp; | |
72 | char c; | 72 | char c; | |
73 | char *namp; | 73 | char *namp; | |
74 | char hostname[MAXHOSTNAMELEN + 1]; | 74 | char hostname[MAXHOSTNAMELEN + 1]; | |
75 | WINDOW *wnd; | 75 | WINDOW *wnd; | |
76 | int CMDLINE; | 76 | int CMDLINE; | |
77 | int turns = 2; /* stay how many refresh-turns in 'all' mode? */ | 77 | int turns = 2; /* stay how many refresh-turns in 'all' mode? */ | |
78 | int allflag; | 78 | int allflag; | |
79 | int allcounter; | 79 | int allcounter; | |
80 | sig_atomic_t needsredraw = 0; | 80 | sig_atomic_t needsredraw = 0; | |
81 | 81 | |||
82 | static WINDOW *wload; /* one line window for load average */ | 82 | static WINDOW *wload; /* one line window for load average */ | |
@@ -163,60 +163,63 @@ main(int argc, char **argv) | @@ -163,60 +163,63 @@ main(int argc, char **argv) | |||
163 | 163 | |||
164 | /* | 164 | /* | |
165 | * Discard setgid privileges. If not the running kernel, we toss | 165 | * Discard setgid privileges. If not the running kernel, we toss | |
166 | * them away totally so that bad guys can't print interesting stuff | 166 | * them away totally so that bad guys can't print interesting stuff | |
167 | * from kernel memory, otherwise switch back to kmem for the | 167 | * from kernel memory, otherwise switch back to kmem for the | |
168 | * duration of the kvm_openfiles() call. | 168 | * duration of the kvm_openfiles() call. | |
169 | */ | 169 | */ | |
170 | if (nlistf != NULL || memf != NULL) | 170 | if (nlistf != NULL || memf != NULL) | |
171 | (void)setgid(getgid()); | 171 | (void)setgid(getgid()); | |
172 | else | 172 | else | |
173 | (void)setegid(egid); | 173 | (void)setegid(egid); | |
174 | 174 | |||
175 | kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf); | 175 | kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf); | |
176 | if (kd == NULL) { | 176 | if (kd == NULL) | |
177 | error("%s", errbuf); | 177 | errx(1, "%s", errbuf); | |
178 | exit(1); | |||
179 | } | |||
180 | 178 | |||
181 | /* Get rid of privs for now. */ | 179 | /* Get rid of privs for now. */ | |
182 | if (nlistf == NULL && memf == NULL) | 180 | if (nlistf == NULL && memf == NULL) | |
183 | (void)setegid(getgid()); | 181 | (void)setegid(getgid()); | |
184 | 182 | |||
185 | signal(SIGINT, die); | 183 | signal(SIGINT, die); | |
186 | signal(SIGQUIT, die); | 184 | signal(SIGQUIT, die); | |
187 | signal(SIGTERM, die); | 185 | signal(SIGTERM, die); | |
188 | sv_stop_handler = signal(SIGTSTP, stop); | 186 | sv_stop_handler = signal(SIGTSTP, stop); | |
189 | 187 | |||
190 | /* | 188 | /* | |
191 | * Initialize display. Load average appears in a one line | 189 | * Initialize display. Load average appears in a one line | |
192 | * window of its own. Current command's display appears in | 190 | * window of its own. Current command's display appears in | |
193 | * an overlapping sub-window of stdscr configured by the display | 191 | * an overlapping sub-window of stdscr configured by the display | |
194 | * routines to minimize update work by curses. | 192 | * routines to minimize update work by curses. | |
195 | */ | 193 | */ | |
196 | if (initscr() == NULL) | 194 | if (initscr() == NULL) | |
197 | { | 195 | errx(1, "couldn't initialize screen"); | |
198 | warnx("couldn't initialize screen"); | |||
199 | exit(0); | |||
200 | } | |||
201 | 196 | |||
202 | CMDLINE = LINES - 1; | 197 | CMDLINE = LINES - 1; | |
203 | wnd = (*curmode->c_open)(); | 198 | wnd = (*curmode->c_open)(); | |
204 | if (wnd == NULL) { | 199 | if (wnd == NULL) { | |
200 | move(CMDLINE, 0); | |||
201 | clrtoeol(); | |||
202 | refresh(); | |||
203 | endwin(); | |||
205 | warnx("couldn't initialize display"); | 204 | warnx("couldn't initialize display"); | |
206 | die(0); | 205 | die(0); | |
207 | } | 206 | } | |
208 | wload = newwin(1, 0, 3, 20); | 207 | wload = newwin(1, 0, 3, 20); | |
209 | if (wload == NULL) { | 208 | if (wload == NULL) { | |
209 | move(CMDLINE, 0); | |||
210 | clrtoeol(); | |||
211 | refresh(); | |||
212 | endwin(); | |||
210 | warnx("couldn't set up load average window"); | 213 | warnx("couldn't set up load average window"); | |
211 | die(0); | 214 | die(0); | |
212 | } | 215 | } | |
213 | gethostname(hostname, sizeof (hostname)); | 216 | gethostname(hostname, sizeof (hostname)); | |
214 | hostname[sizeof(hostname) - 1] = '\0'; | 217 | hostname[sizeof(hostname) - 1] = '\0'; | |
215 | 218 | |||
216 | len = sizeof(clk); | 219 | len = sizeof(clk); | |
217 | if (sysctlbyname("kern.clockrate", &clk, &len, NULL, 0)) | 220 | if (sysctlbyname("kern.clockrate", &clk, &len, NULL, 0)) | |
218 | error("can't get \"kern.clockrate\": %s", strerror(errno)); | 221 | error("can't get \"kern.clockrate\": %s", strerror(errno)); | |
219 | hz = clk.hz; | 222 | hz = clk.hz; | |
220 | stathz = clk.stathz; | 223 | stathz = clk.stathz; | |
221 | 224 | |||
222 | len = sizeof(maxslp); | 225 | len = sizeof(maxslp); | |
@@ -401,17 +404,16 @@ nlisterr(struct nlist name_list[]) | @@ -401,17 +404,16 @@ nlisterr(struct nlist name_list[]) | |||
401 | { | 404 | { | |
402 | int i, n; | 405 | int i, n; | |
403 | 406 | |||
404 | n = 0; | 407 | n = 0; | |
405 | clear(); | 408 | clear(); | |
406 | mvprintw(2, 10, "systat: nlist: can't find following symbols:"); | 409 | mvprintw(2, 10, "systat: nlist: can't find following symbols:"); | |
407 | for (i = 0; | 410 | for (i = 0; | |
408 | name_list[i].n_name != NULL && *name_list[i].n_name != '\0'; i++) | 411 | name_list[i].n_name != NULL && *name_list[i].n_name != '\0'; i++) | |
409 | if (name_list[i].n_value == 0) | 412 | if (name_list[i].n_value == 0) | |
410 | mvprintw(2 + ++n, 10, "%s", name_list[i].n_name); | 413 | mvprintw(2 + ++n, 10, "%s", name_list[i].n_name); | |
411 | move(CMDLINE, 0); | 414 | move(CMDLINE, 0); | |
412 | clrtoeol(); | 415 | clrtoeol(); | |
413 | refresh(); | 416 | refresh(); | |
414 | sleep(5); | |||
415 | endwin(); | 417 | endwin(); | |
416 | exit(1); | 418 | exit(1); | |
417 | } | 419 | } |
--- src/usr.bin/systat/systat.1 2017/07/03 21:34:21 1.48
+++ src/usr.bin/systat/systat.1 2018/12/26 01:47:37 1.49
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | .\" $NetBSD: systat.1,v 1.48 2017/07/03 21:34:21 wiz Exp $ | 1 | .\" $NetBSD: systat.1,v 1.49 2018/12/26 01:47:37 sevan Exp $ | |
2 | .\" | 2 | .\" | |
3 | .\" Copyright (c) 1985, 1990, 1993 | 3 | .\" Copyright (c) 1985, 1990, 1993 | |
4 | .\" The Regents of the University of California. All rights reserved. | 4 | .\" The Regents of the University of California. All rights reserved. | |
5 | .\" | 5 | .\" | |
6 | .\" Redistribution and use in source and binary forms, with or without | 6 | .\" Redistribution and use in source and binary forms, with or without | |
7 | .\" modification, are permitted provided that the following conditions | 7 | .\" modification, are permitted provided that the following conditions | |
8 | .\" are met: | 8 | .\" are met: | |
9 | .\" 1. Redistributions of source code must retain the above copyright | 9 | .\" 1. Redistributions of source code must retain the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer. | 10 | .\" notice, this list of conditions and the following disclaimer. | |
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | 11 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
12 | .\" notice, this list of conditions and the following disclaimer in the | 12 | .\" notice, this list of conditions and the following disclaimer in the | |
13 | .\" documentation and/or other materials provided with the distribution. | 13 | .\" documentation and/or other materials provided with the distribution. | |
14 | .\" 3. Neither the name of the University nor the names of its contributors | 14 | .\" 3. Neither the name of the University nor the names of its contributors | |
@@ -19,27 +19,27 @@ | @@ -19,27 +19,27 @@ | |||
19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
28 | .\" SUCH DAMAGE. | 28 | .\" SUCH DAMAGE. | |
29 | .\" | 29 | .\" | |
30 | .\" @(#)systat.1 8.2 (Berkeley) 12/30/93 | 30 | .\" @(#)systat.1 8.2 (Berkeley) 12/30/93 | |
31 | .\" | 31 | .\" | |
32 | .Dd November 16, 2016 | 32 | .Dd December 26, 2018 | |
33 | .Dt SYSTAT 1 | 33 | .Dt SYSTAT 1 | |
34 | .Os | 34 | .Os | |
35 | .Sh NAME | 35 | .Sh NAME | |
36 | .Nm systat | 36 | .Nm systat | |
37 | .Nd display system statistics in a full-screen view | 37 | .Nd display system statistics in a full-screen view | |
38 | .Sh SYNOPSIS | 38 | .Sh SYNOPSIS | |
39 | .Nm | 39 | .Nm | |
40 | .Op Fl bn | 40 | .Op Fl bn | |
41 | .Op Fl M Ar core | 41 | .Op Fl M Ar core | |
42 | .Op Fl N Ar system | 42 | .Op Fl N Ar system | |
43 | .Op Fl t Ar turns | 43 | .Op Fl t Ar turns | |
44 | .Op Fl w Ar wait | 44 | .Op Fl w Ar wait | |
45 | .Op Ar display | 45 | .Op Ar display | |
@@ -444,40 +444,55 @@ Show the number of times the system call | @@ -444,40 +444,55 @@ Show the number of times the system call | |||
444 | Show the average amount of time (in arbitrary units) spent in a call of | 444 | Show the average amount of time (in arbitrary units) spent in a call of | |
445 | the syscall. | 445 | the syscall. | |
446 | .El | 446 | .El | |
447 | .It Ic vmstat | 447 | .It Ic vmstat | |
448 | Take over the entire display and show a (rather crowded) compendium | 448 | Take over the entire display and show a (rather crowded) compendium | |
449 | of statistics related to virtual memory usage, process scheduling, | 449 | of statistics related to virtual memory usage, process scheduling, | |
450 | device interrupts, system name translation caching, disk | 450 | device interrupts, system name translation caching, disk | |
451 | .Tn I/O | 451 | .Tn I/O | |
452 | etc. | 452 | etc. | |
453 | .Pp | 453 | .Pp | |
454 | The upper left quadrant of the screen shows the number | 454 | The upper left quadrant of the screen shows the number | |
455 | of users logged in and the load average over the last one, five, | 455 | of users logged in and the load average over the last one, five, | |
456 | and fifteen minute intervals. | 456 | and fifteen minute intervals. | |
457 | Below this is a list of the | 457 | Below this are statistics on memory utilization. | |
458 | The first row of the table reports memory usage only among | |||
459 | active processes, that is processes that have run in the previous | |||
460 | twenty seconds. | |||
461 | The second row reports on memory usage of all processes. | |||
462 | The first column reports on the number of physical pages | |||
463 | claimed by processes. | |||
464 | The second column reports the number of physical pages that | |||
465 | are devoted to read only text pages. | |||
466 | The third and fourth columns report the same two figures for | |||
467 | virtual pages, that is the number of pages that would be | |||
468 | needed if all processes had all of their pages. | |||
469 | Finally the last column shows the number of physical pages | |||
470 | on the free list. | |||
471 | .Pp | |||
472 | Below the memory display is a list of the | |||
458 | average number of processes (over the last refresh interval) | 473 | average number of processes (over the last refresh interval) | |
459 | that are runnable (`r'), in page wait (`p'), | 474 | that are runnable (`r'), in page wait (`p'), | |
460 | in disk wait other than paging (`d'), sleeping (`s'). | 475 | in disk wait other than paging (`d'), sleeping (`s'). | |
461 | Below the queue length listing is a numerical listing and | 476 | Below the queue length listing is a numerical listing and | |
462 | a bar graph showing the amount of | 477 | a bar graph showing the amount of | |
463 | system (shown as `='), user (shown as `>'), | 478 | system (shown as `='), user (shown as `>'), | |
464 | nice (shown as `-'), and idle time (shown as ` '). | 479 | nice (shown as `-'), and idle time (shown as ` '). | |
465 | .Pp | 480 | .Pp | |
466 | To the right of the process statistics is a column that | 481 | To the right of the process statistics is a column that | |
467 | lists the average number of context switches (`Csw'), | 482 | lists the average number of context switches (`Csw'), | |
468 | traps (`Trp'; includes page faults), system calls (`Sys'), interrupts (`Int'), | 483 | traps (`Traps'; includes page faults), system calls (`SysCa'), interrupts (`Intr'), | |
469 | network software interrupts (`Sof'), | 484 | network software interrupts (`Soft'), | |
470 | page faults (`Flt'). | 485 | page faults (`Fault'). | |
471 | .Pp | 486 | .Pp | |
472 | Below this are statistics on memory utilization. | 487 | Below this are statistics on memory utilization. | |
473 | The first row of the table reports memory usage only among | 488 | The first row of the table reports memory usage only among | |
474 | active processes, that is processes that have run in the previous | 489 | active processes, that is processes that have run in the previous | |
475 | twenty seconds. | 490 | twenty seconds. | |
476 | The second row reports on memory usage of all processes. | 491 | The second row reports on memory usage of all processes. | |
477 | The first column reports on the number of physical pages | 492 | The first column reports on the number of physical pages | |
478 | claimed by processes. | 493 | claimed by processes. | |
479 | The second column reports the number of pages of memory and swap. | 494 | The second column reports the number of pages of memory and swap. | |
480 | The third column gives the number of pages of free memory and swap. | 495 | The third column gives the number of pages of free memory and swap. | |
481 | .Pp | 496 | .Pp | |
482 | Below the memory display are statistics on name translations. | 497 | Below the memory display are statistics on name translations. | |
483 | It lists the number of names translated in the previous interval, | 498 | It lists the number of names translated in the previous interval, | |
@@ -499,36 +514,95 @@ Under the date in the upper right hand q | @@ -499,36 +514,95 @@ Under the date in the upper right hand q | |||
499 | on paging and swapping activity. | 514 | on paging and swapping activity. | |
500 | The first two columns report the average number of pages | 515 | The first two columns report the average number of pages | |
501 | brought in and out per second over the last refresh interval | 516 | brought in and out per second over the last refresh interval | |
502 | due to page faults and the paging daemon. | 517 | due to page faults and the paging daemon. | |
503 | The third and fourth columns report the average number of pages | 518 | The third and fourth columns report the average number of pages | |
504 | brought in and out per second over the last refresh interval | 519 | brought in and out per second over the last refresh interval | |
505 | due to swap requests initiated by the scheduler. | 520 | due to swap requests initiated by the scheduler. | |
506 | The first row of the display shows the average | 521 | The first row of the display shows the average | |
507 | number of disk transfers per second over the last refresh interval; | 522 | number of disk transfers per second over the last refresh interval; | |
508 | the second row of the display shows the average | 523 | the second row of the display shows the average | |
509 | number of pages transferred per second over the last refresh interval. | 524 | number of pages transferred per second over the last refresh interval. | |
510 | .Pp | 525 | .Pp | |
511 | Below the paging statistics is another columns of paging data. | 526 | Below the paging statistics is another columns of paging data. | |
512 | From top to bottom, these represent average numbers of copy on write faults | 527 | From top to bottom, these represent: | |
513 | (`cow'), object cache lookups (`objlk'), object cache hits (`objht'), | 528 | .Pp | |
514 | pages zero filled on demand (`zfodw'), number zfod's created (`nzfod'), | 529 | .Bl -tag -width Fl -compact | |
515 | percentage of zfod's used (`%zfod'), number of kernel pages (`kern'), | 530 | .It Ic Sq forks | |
516 | number of wired pages (`wire'), number of active pages (`act'), number | 531 | number of fork() calls | |
517 | of inactive pages (`inact'), number of free pages (`free'), pages freed | 532 | .It Ic Sq fkppw | |
518 | by daemon (`daefr'), pages freed by exiting processes (`prcfr'), number | 533 | number of fork() calls where parent waits | |
519 | of pages reactivated from freelist (`react'), scans in page out daemon | 534 | .It Ic Sq fksvm | |
520 | (`scan'), revolutions of the hand (`hdrev'), and in-transit blocking page | 535 | number of fork() calls where vmspace is shared | |
521 | faults (`intrn'), per second over the refresh period. | 536 | .It Ic Sq pwait | |
537 | number of times fault had to wait on a page | |||
538 | .It Ic Sq relck | |||
539 | number of times uvmfault_relock() is called | |||
540 | .It Ic Sq rlkok | |||
541 | number of times uvmfault_relock() is a success | |||
542 | .It Ic Sq noram | |||
543 | number of times fault was out of RAM | |||
544 | .It Ic Sq ndcpy | |||
545 | number of times fault clears ``needs copy'' | |||
546 | .It Ic Sq fltcp | |||
547 | number of times fault promotes with copy (2b) | |||
548 | .It Ic Sq zfod | |||
549 | number of times fault promotes with zerofill (2b) | |||
550 | .It Ic Sq cow | |||
551 | number of times faulted for anonymous for Copy-On-Write (case 1b) | |||
552 | .It Ic Sq fmin | |||
553 | min number of free pages | |||
554 | .It Ic Sq ftarg | |||
555 | target number of free pages | |||
556 | .It Ic Sq itarg | |||
557 | target number of inactive pages | |||
558 | .\".It Ic Sq objlk | |||
559 | .\"object cache lookups | |||
560 | .\".It Ic Sq objht | |||
561 | .\"object cache hits | |||
562 | .\".It Ic Sq zfodw | |||
563 | .\"pages zero filled on demand | |||
564 | .\".It Ic Sq nzfod | |||
565 | .\"number of zfod's created | |||
566 | .\".It Ic Sq %zfod | |||
567 | .\"percentage of zfod's used | |||
568 | .\".It Ic Sq kern | |||
569 | .\"number of kernel pages | |||
570 | .It Ic Sq flnan | |||
571 | number of times fault was out of anonymous pages | |||
572 | .\".It Ic Sq act | |||
573 | .\"number of active pages | |||
574 | .\".It Ic Sq inact | |||
575 | .\"number of inactive pages | |||
576 | .\".It Ic Sq free | |||
577 | .\"number of free pages | |||
578 | .\".It Ic Sq daefr | |||
579 | .\"pages freed by daemon | |||
580 | .\".It Ic Sq prcfr | |||
581 | .\"pages freed by exiting processes | |||
582 | .\".It Ic Sq react | |||
583 | .\"number of pages reactivated from freelist | |||
584 | .\".It Ic Sq scan | |||
585 | .\"scans in page out daemon | |||
586 | .\".It Ic Sq hdrev | |||
587 | .\"revolutions of the hand | |||
588 | .\".It Ic Sq intrn | |||
589 | .\"in-transit blocking page faults per second over the refresh period. | |||
590 | .It Ic Sq pdfre | |||
591 | number of pages daemon freed since boot | |||
592 | .It Ic Sq pdscn | |||
593 | number of pages daemon scaned since boot | |||
594 | .El | |||
595 | .Pp | |||
522 | Note that the `%zfod' percentage is usually less than 100%, | 596 | Note that the `%zfod' percentage is usually less than 100%, | |
523 | however it may exceed 100% if a large number of requests | 597 | however it may exceed 100% if a large number of requests | |
524 | are actually used long after they were set up during a | 598 | are actually used long after they were set up during a | |
525 | period when no new pages are being set up. | 599 | period when no new pages are being set up. | |
526 | Thus this figure is most interesting when observed over | 600 | Thus this figure is most interesting when observed over | |
527 | a long time period, such as from boot time | 601 | a long time period, such as from boot time | |
528 | (see below on getting such a display). | 602 | (see below on getting such a display). | |
529 | .Pp | 603 | .Pp | |
530 | To the left of the column of paging statistics is a breakdown | 604 | To the left of the column of paging statistics is a breakdown | |
531 | of the interrupts being handled by the system. | 605 | of the interrupts being handled by the system. | |
532 | At the top of the list is the total interrupts per second | 606 | At the top of the list is the total interrupts per second | |
533 | over the time interval. | 607 | over the time interval. | |
534 | The rest of the column breaks down the total on a device | 608 | The rest of the column breaks down the total on a device |
--- src/usr.bin/systat/systat.h 2005/02/26 22:12:34 1.11
+++ src/usr.bin/systat/systat.h 2018/12/26 01:47:37 1.12
@@ -51,14 +51,13 @@ struct command { | @@ -51,14 +51,13 @@ struct command { | |||
51 | const char *helptext; | 51 | const char *helptext; | |
52 | }; | 52 | }; | |
53 | 53 | |||
54 | #define CF_INIT 0x1 /* been initialized */ | 54 | #define CF_INIT 0x1 /* been initialized */ | |
55 | #define CF_LOADAV 0x2 /* display w/ load average */ | 55 | #define CF_LOADAV 0x2 /* display w/ load average */ | |
56 | 56 | |||
57 | #define TCP 0x1 | 57 | #define TCP 0x1 | |
58 | #define UDP 0x2 | 58 | #define UDP 0x2 | |
59 | 59 | |||
60 | #define KREAD(addr, buf, len) kvm_ckread((addr), (buf), (len), # addr) | 60 | #define KREAD(addr, buf, len) kvm_ckread((addr), (buf), (len), # addr) | |
61 | #define NVAL(indx) namelist[(indx)].n_value | 61 | #define NVAL(indx) namelist[(indx)].n_value | |
62 | #define NPTR(indx) (void *)NVAL((indx)) | 62 | #define NPTR(indx) (void *)NVAL((indx)) | |
63 | #define NREAD(indx, buf, len) kvm_ckread(NPTR((indx)), (buf), (len), # indx) | 63 | #define NREAD(indx, buf, len) kvm_ckread(NPTR((indx)), (buf), (len), # indx) | |
64 | #define LONG (sizeof (long)) |
--- src/usr.bin/systat/vmstat.c 2017/07/15 08:22:23 1.82
+++ src/usr.bin/systat/vmstat.c 2018/12/26 01:47:37 1.83
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: vmstat.c,v 1.82 2017/07/15 08:22:23 mlelstv Exp $ */ | 1 | /* $NetBSD: vmstat.c,v 1.83 2018/12/26 01:47:37 sevan Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1983, 1989, 1992, 1993 | 4 | * Copyright (c) 1983, 1989, 1992, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
29 | * SUCH DAMAGE. | 29 | * SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | #ifndef lint | 33 | #ifndef lint | |
34 | #if 0 | 34 | #if 0 | |
35 | static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94"; | 35 | static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94"; | |
36 | #endif | 36 | #endif | |
37 | __RCSID("$NetBSD: vmstat.c,v 1.82 2017/07/15 08:22:23 mlelstv Exp $"); | 37 | __RCSID("$NetBSD: vmstat.c,v 1.83 2018/12/26 01:47:37 sevan Exp $"); | |
38 | #endif /* not lint */ | 38 | #endif /* not lint */ | |
39 | 39 | |||
40 | /* | 40 | /* | |
41 | * Cursed vmstat -- from Robert Elz. | 41 | * Cursed vmstat -- from Robert Elz. | |
42 | */ | 42 | */ | |
43 | 43 | |||
44 | #include <sys/param.h> | 44 | #include <sys/param.h> | |
45 | #include <sys/uio.h> | 45 | #include <sys/uio.h> | |
46 | #include <sys/namei.h> | 46 | #include <sys/namei.h> | |
47 | #include <sys/sysctl.h> | 47 | #include <sys/sysctl.h> | |
48 | #include <sys/evcnt.h> | 48 | #include <sys/evcnt.h> | |
49 | 49 | |||
50 | #include <uvm/uvm_extern.h> | 50 | #include <uvm/uvm_extern.h> | |
@@ -77,26 +77,27 @@ static float cputime(int); | @@ -77,26 +77,27 @@ static float cputime(int); | |||
77 | static void dinfo(int, int, int); | 77 | static void dinfo(int, int, int); | |
78 | static void getinfo(struct Info *); | 78 | static void getinfo(struct Info *); | |
79 | static int ucount(void); | 79 | static int ucount(void); | |
80 | 80 | |||
81 | static char buf[26]; | 81 | static char buf[26]; | |
82 | static u_int64_t temp; | 82 | static u_int64_t temp; | |
83 | double etime; | 83 | double etime; | |
84 | static float hertz; | 84 | static float hertz; | |
85 | static int nintr; | 85 | static int nintr; | |
86 | static long *intrloc; | 86 | static long *intrloc; | |
87 | static char **intrname; | 87 | static char **intrname; | |
88 | static int nextintsrow; | 88 | static int nextintsrow; | |
89 | static int disk_horiz = 1; | 89 | static int disk_horiz = 1; | |
90 | static u_int nbuf; | |||
90 | 91 | |||
91 | WINDOW * | 92 | WINDOW * | |
92 | openvmstat(void) | 93 | openvmstat(void) | |
93 | { | 94 | { | |
94 | return (stdscr); | 95 | return (stdscr); | |
95 | } | 96 | } | |
96 | 97 | |||
97 | void | 98 | void | |
98 | closevmstat(WINDOW *w) | 99 | closevmstat(WINDOW *w) | |
99 | { | 100 | { | |
100 | 101 | |||
101 | if (w == NULL) | 102 | if (w == NULL) | |
102 | return; | 103 | return; | |
@@ -114,46 +115,46 @@ static struct nlist namelist[] = { | @@ -114,46 +115,46 @@ static struct nlist namelist[] = { | |||
114 | { .n_name = "_intrcnt" }, | 115 | { .n_name = "_intrcnt" }, | |
115 | #define X_EINTRCNT 3 | 116 | #define X_EINTRCNT 3 | |
116 | { .n_name = "_eintrcnt" }, | 117 | { .n_name = "_eintrcnt" }, | |
117 | #define X_ALLEVENTS 4 | 118 | #define X_ALLEVENTS 4 | |
118 | { .n_name = "_allevents" }, | 119 | { .n_name = "_allevents" }, | |
119 | { .n_name = NULL } | 120 | { .n_name = NULL } | |
120 | }; | 121 | }; | |
121 | 122 | |||
122 | /* | 123 | /* | |
123 | * These constants define where the major pieces are laid out | 124 | * These constants define where the major pieces are laid out | |
124 | */ | 125 | */ | |
125 | #define STATROW 0 /* uses 1 row and 68 cols */ | 126 | #define STATROW 0 /* uses 1 row and 68 cols */ | |
126 | #define STATCOL 2 | 127 | #define STATCOL 2 | |
127 | #define MEMROW 9 /* uses 4 rows and 31 cols */ | 128 | #define MEMROW 9 /* uses 5 rows and 31 cols */ | |
128 | #define MEMCOL 0 | 129 | #define MEMCOL 0 | |
129 | #define PAGEROW 2 /* uses 4 rows and 26 cols */ | 130 | #define PAGEROW 2 /* uses 4 rows and 26 cols */ | |
130 | #define PAGECOL 54 | 131 | #define PAGECOL 54 | |
131 | #define INTSROW 9 /* uses all rows to bottom and 17 cols */ | 132 | #define INTSROW 9 /* uses all rows to bottom and 17 cols */ | |
132 | #define INTSCOL 40 | 133 | #define INTSCOL 40 | |
133 | #define INTSCOLEND (VMSTATCOL - 0) | 134 | #define INTSCOLEND (VMSTATCOL - 0) | |
134 | #define PROCSROW 2 /* uses 2 rows and 20 cols */ | 135 | #define PROCSROW 2 /* uses 2 rows and 20 cols */ | |
135 | #define PROCSCOL 0 | 136 | #define PROCSCOL 0 | |
136 | #define GENSTATROW 2 /* uses 2 rows and 30 cols */ | 137 | #define GENSTATROW 2 /* uses 2 rows and 30 cols */ | |
137 | #define GENSTATCOL 17 | 138 | #define GENSTATCOL 17 | |
138 | #define VMSTATROW 7 /* uses 17 rows and 15 cols */ | 139 | #define VMSTATROW 7 /* uses 17 rows and 15 cols */ | |
139 | #define VMSTATCOL 64 | 140 | #define VMSTATCOL 64 | |
140 | #define GRAPHROW 5 /* uses 3 rows and 51 cols */ | 141 | #define GRAPHROW 5 /* uses 3 rows and 51 cols */ | |
141 | #define GRAPHCOL 0 | 142 | #define GRAPHCOL 0 | |
142 | #define NAMEIROW 14 /* uses 3 rows and 38 cols */ | 143 | #define NAMEIROW 15 /* uses 3 rows and 38 cols (must be MEMROW + 5 + 1) */ | |
143 | #define NAMEICOL 0 | 144 | #define NAMEICOL 0 | |
144 | #define DISKROW 18 /* uses 5 rows and 50 cols (for 9 drives) */ | 145 | #define DISKROW 19 /* uses 5 rows and 50 cols (for 9 drives) */ | |
145 | #define DISKCOL 0 | 146 | #define DISKCOL 0 | |
146 | #define DISKCOLWIDTH 6 | 147 | #define DISKCOLWIDTH 8 | |
147 | #define DISKCOLEND INTSCOL | 148 | #define DISKCOLEND INTSCOL | |
148 | 149 | |||
149 | typedef struct intr_evcnt intr_evcnt_t; | 150 | typedef struct intr_evcnt intr_evcnt_t; | |
150 | struct intr_evcnt { | 151 | struct intr_evcnt { | |
151 | char *ie_group; | 152 | char *ie_group; | |
152 | char *ie_name; | 153 | char *ie_name; | |
153 | u_int64_t *ie_count; /* kernel address... */ | 154 | u_int64_t *ie_count; /* kernel address... */ | |
154 | int ie_loc; /* screen row */ | 155 | int ie_loc; /* screen row */ | |
155 | } *ie_head; | 156 | } *ie_head; | |
156 | int nevcnt; | 157 | int nevcnt; | |
157 | 158 | |||
158 | static void | 159 | static void | |
159 | get_interrupt_events(void) | 160 | get_interrupt_events(void) | |
@@ -308,71 +309,73 @@ print_ie_title(int i) | @@ -308,71 +309,73 @@ print_ie_title(int i) | |||
308 | } | 309 | } | |
309 | if (name_width != 0) | 310 | if (name_width != 0) | |
310 | printw("%-.*s", name_width, ie_head[i].ie_name); | 311 | printw("%-.*s", name_width, ie_head[i].ie_name); | |
311 | } | 312 | } | |
312 | 313 | |||
313 | void | 314 | void | |
314 | labelvmstat_top(void) | 315 | labelvmstat_top(void) | |
315 | { | 316 | { | |
316 | 317 | |||
317 | clear(); | 318 | clear(); | |
318 | 319 | |||
319 | mvprintw(STATROW, STATCOL + 4, "users Load"); | 320 | mvprintw(STATROW, STATCOL + 4, "users Load"); | |
320 | 321 | |||
321 | mvprintw(GENSTATROW, GENSTATCOL, " Csw Trp Sys Int Sof Flt"); | 322 | mvprintw(GENSTATROW, GENSTATCOL, " Csw Traps SysCal Intr Soft Fault"); | |
322 | 323 | |||
323 | mvprintw(GRAPHROW, GRAPHCOL, | 324 | mvprintw(GRAPHROW, GRAPHCOL, | |
324 | " . %% Sy . %% Us . %% Ni . %% In . %% Id"); | 325 | " . %% Sy . %% Us . %% Ni . %% In . %% Id"); | |
325 | mvprintw(PROCSROW, PROCSCOL, "Proc:r d s"); | 326 | mvprintw(PROCSROW, PROCSCOL, "Proc:r d s"); | |
326 | mvprintw(GRAPHROW + 1, GRAPHCOL, | 327 | mvprintw(GRAPHROW + 1, GRAPHCOL, | |
327 | "| | | | | | | | | | |"); | 328 | "| | | | | | | | | | |"); | |
328 | 329 | |||
329 | mvprintw(PAGEROW, PAGECOL + 8, "PAGING SWAPPING "); | 330 | mvprintw(PAGEROW, PAGECOL + 8, "PAGING SWAPPING "); | |
330 | mvprintw(PAGEROW + 1, PAGECOL, " in out in out "); | 331 | mvprintw(PAGEROW + 1, PAGECOL, " in out in out "); | |
331 | mvprintw(PAGEROW + 2, PAGECOL + 2, "ops"); | 332 | mvprintw(PAGEROW + 2, PAGECOL, " ops "); | |
332 | mvprintw(PAGEROW + 3, PAGECOL, "pages"); | 333 | mvprintw(PAGEROW + 3, PAGECOL, "pages "); | |
333 | } | 334 | } | |
334 | 335 | |||
335 | void | 336 | void | |
336 | labelvmstat(void) | 337 | labelvmstat(void) | |
337 | { | 338 | { | |
338 | int i; | 339 | int i; | |
339 | 340 | |||
340 | /* Top few lines first */ | 341 | /* Top few lines first */ | |
341 | 342 | |||
342 | labelvmstat_top(); | 343 | labelvmstat_top(); | |
343 | 344 | |||
344 | /* Left hand column */ | 345 | /* Left hand column */ | |
345 | 346 | |||
346 | mvprintw(MEMROW, MEMCOL, " memory totals (in kB)"); | 347 | mvprintw(MEMROW + 0, MEMCOL, "Anon %% zero "); | |
347 | mvprintw(MEMROW + 1, MEMCOL, " real virtual free"); | 348 | mvprintw(MEMROW + 1, MEMCOL, "Exec %% wired "); | |
348 | mvprintw(MEMROW + 2, MEMCOL, "Active"); | 349 | mvprintw(MEMROW + 2, MEMCOL, "File %% inact "); | |
349 | mvprintw(MEMROW + 3, MEMCOL, "All"); | 350 | mvprintw(MEMROW + 3, MEMCOL, "Meta %% bufs "); | |
351 | mvprintw(MEMROW + 4, MEMCOL, " (kB) real swaponly free"); | |||
352 | mvprintw(MEMROW + 5, MEMCOL, "Active "); | |||
350 | 353 | |||
351 | mvprintw(NAMEIROW, NAMEICOL, "Namei Sys-cache Proc-cache"); | 354 | mvprintw(NAMEIROW, NAMEICOL, "Namei Sys-cache Proc-cache"); | |
352 | mvprintw(NAMEIROW + 1, NAMEICOL, | 355 | mvprintw(NAMEIROW + 1, NAMEICOL, | |
353 | " Calls hits %% hits %%"); | 356 | " Calls hits %% hits %%"); | |
354 | 357 | |||
355 | mvprintw(DISKROW, DISKCOL, "Disks:"); | 358 | mvprintw(DISKROW, DISKCOL, "%*s", DISKCOLWIDTH, "Disks:"); | |
356 | if (disk_horiz) { | 359 | if (disk_horiz) { | |
357 | mvprintw(DISKROW + 1, DISKCOL + 1, "seeks"); | 360 | mvprintw(DISKROW + 1, DISKCOL + 1, "seeks"); | |
358 | mvprintw(DISKROW + 2, DISKCOL + 1, "xfers"); | 361 | mvprintw(DISKROW + 2, DISKCOL + 1, "xfers"); | |
359 | mvprintw(DISKROW + 3, DISKCOL + 1, "bytes"); | 362 | mvprintw(DISKROW + 3, DISKCOL + 1, "bytes"); | |
360 | mvprintw(DISKROW + 4, DISKCOL + 1, "%%busy"); | 363 | mvprintw(DISKROW + 4, DISKCOL + 1, "%%busy"); | |
361 | } else { | 364 | } else { | |
362 | mvprintw(DISKROW, DISKCOL + 1 + 1 * DISKCOLWIDTH, "seeks"); | 365 | mvprintw(DISKROW, DISKCOL + 1 * DISKCOLWIDTH, "%*s", DISKCOLWIDTH, "seeks"); | |
363 | mvprintw(DISKROW, DISKCOL + 1 + 2 * DISKCOLWIDTH, "xfers"); | 366 | mvprintw(DISKROW, DISKCOL + 2 * DISKCOLWIDTH, "%*s", DISKCOLWIDTH, "xfers"); | |
364 | mvprintw(DISKROW, DISKCOL + 1 + 3 * DISKCOLWIDTH, "bytes"); | 367 | mvprintw(DISKROW, DISKCOL + 3 * DISKCOLWIDTH, "%*s", DISKCOLWIDTH, "bytes"); | |
365 | mvprintw(DISKROW, DISKCOL + 1 + 4 * DISKCOLWIDTH, "%%busy"); | 368 | mvprintw(DISKROW, DISKCOL + 4 * DISKCOLWIDTH, "%*s", DISKCOLWIDTH, "%%busy"); | |
366 | } | 369 | } | |
367 | 370 | |||
368 | /* Middle column */ | 371 | /* Middle column */ | |
369 | 372 | |||
370 | mvprintw(INTSROW, INTSCOL + 9, "Interrupts"); | 373 | mvprintw(INTSROW, INTSCOL + 9, "Interrupts"); | |
371 | for (i = 0; i < nintr; i++) { | 374 | for (i = 0; i < nintr; i++) { | |
372 | if (intrloc[i] == 0) | 375 | if (intrloc[i] == 0) | |
373 | continue; | 376 | continue; | |
374 | mvprintw(intrloc[i], INTSCOL + 9, "%-.*s", | 377 | mvprintw(intrloc[i], INTSCOL + 9, "%-.*s", | |
375 | INTSCOLEND - (INTSCOL + 9), intrname[i]); | 378 | INTSCOLEND - (INTSCOL + 9), intrname[i]); | |
376 | } | 379 | } | |
377 | for (i = 0; i < nevcnt; i++) { | 380 | for (i = 0; i < nevcnt; i++) { | |
378 | if (ie_head[i].ie_loc == 0) | 381 | if (ie_head[i].ie_loc == 0) | |
@@ -386,27 +389,27 @@ labelvmstat(void) | @@ -386,27 +389,27 @@ labelvmstat(void) | |||
386 | mvprintw(VMSTATROW + 1, VMSTATCOL + 10, "fkppw"); | 389 | mvprintw(VMSTATROW + 1, VMSTATCOL + 10, "fkppw"); | |
387 | mvprintw(VMSTATROW + 2, VMSTATCOL + 10, "fksvm"); | 390 | mvprintw(VMSTATROW + 2, VMSTATCOL + 10, "fksvm"); | |
388 | mvprintw(VMSTATROW + 3, VMSTATCOL + 10, "pwait"); | 391 | mvprintw(VMSTATROW + 3, VMSTATCOL + 10, "pwait"); | |
389 | mvprintw(VMSTATROW + 4, VMSTATCOL + 10, "relck"); | 392 | mvprintw(VMSTATROW + 4, VMSTATCOL + 10, "relck"); | |
390 | mvprintw(VMSTATROW + 5, VMSTATCOL + 10, "rlkok"); | 393 | mvprintw(VMSTATROW + 5, VMSTATCOL + 10, "rlkok"); | |
391 | mvprintw(VMSTATROW + 6, VMSTATCOL + 10, "noram"); | 394 | mvprintw(VMSTATROW + 6, VMSTATCOL + 10, "noram"); | |
392 | mvprintw(VMSTATROW + 7, VMSTATCOL + 10, "ndcpy"); | 395 | mvprintw(VMSTATROW + 7, VMSTATCOL + 10, "ndcpy"); | |
393 | mvprintw(VMSTATROW + 8, VMSTATCOL + 10, "fltcp"); | 396 | mvprintw(VMSTATROW + 8, VMSTATCOL + 10, "fltcp"); | |
394 | mvprintw(VMSTATROW + 9, VMSTATCOL + 10, "zfod"); | 397 | mvprintw(VMSTATROW + 9, VMSTATCOL + 10, "zfod"); | |
395 | mvprintw(VMSTATROW + 10, VMSTATCOL + 10, "cow"); | 398 | mvprintw(VMSTATROW + 10, VMSTATCOL + 10, "cow"); | |
396 | mvprintw(VMSTATROW + 11, VMSTATCOL + 10, "fmin"); | 399 | mvprintw(VMSTATROW + 11, VMSTATCOL + 10, "fmin"); | |
397 | mvprintw(VMSTATROW + 12, VMSTATCOL + 10, "ftarg"); | 400 | mvprintw(VMSTATROW + 12, VMSTATCOL + 10, "ftarg"); | |
398 | mvprintw(VMSTATROW + 13, VMSTATCOL + 10, "itarg"); | 401 | mvprintw(VMSTATROW + 13, VMSTATCOL + 10, "itarg"); | |
399 | mvprintw(VMSTATROW + 14, VMSTATCOL + 10, "wired"); | 402 | mvprintw(VMSTATROW + 14, VMSTATCOL + 10, "flnan"); | |
400 | mvprintw(VMSTATROW + 15, VMSTATCOL + 10, "pdfre"); | 403 | mvprintw(VMSTATROW + 15, VMSTATCOL + 10, "pdfre"); | |
401 | 404 | |||
402 | if (LINES - 1 > VMSTATROW + 16) | 405 | if (LINES - 1 > VMSTATROW + 16) | |
403 | mvprintw(VMSTATROW + 16, VMSTATCOL + 10, "pdscn"); | 406 | mvprintw(VMSTATROW + 16, VMSTATCOL + 10, "pdscn"); | |
404 | } | 407 | } | |
405 | 408 | |||
406 | #define X(s, s1, fld) {temp = (s).fld[i]; (s).fld[i] -= (s1).fld[i]; \ | 409 | #define X(s, s1, fld) {temp = (s).fld[i]; (s).fld[i] -= (s1).fld[i]; \ | |
407 | if (display_mode == TIME) (s1).fld[i] = temp;} | 410 | if (display_mode == TIME) (s1).fld[i] = temp;} | |
408 | #define Z(s, s1, fld) {temp = (s).nchstats.fld; \ | 411 | #define Z(s, s1, fld) {temp = (s).nchstats.fld; \ | |
409 | (s).nchstats.fld -= (s1).nchstats.fld; \ | 412 | (s).nchstats.fld -= (s1).nchstats.fld; \ | |
410 | if (display_mode == TIME) (s1).nchstats.fld = temp;} | 413 | if (display_mode == TIME) (s1).nchstats.fld = temp;} | |
411 | #define PUTRATE(s, s1, fld, l, c, w) \ | 414 | #define PUTRATE(s, s1, fld, l, c, w) \ | |
412 | {temp = (s).fld; (s).fld -= (s1).fld; \ | 415 | {temp = (s).fld; (s).fld -= (s1).fld; \ | |
@@ -437,26 +440,31 @@ show_vmstat_top(vmtotal_t *Total, uvmexp | @@ -437,26 +440,31 @@ show_vmstat_top(vmtotal_t *Total, uvmexp | |||
437 | mvaddstr(STATROW, STATCOL + 53, buf); | 440 | mvaddstr(STATROW, STATCOL + 53, buf); | |
438 | 441 | |||
439 | putint(Total->t_rq - 1, PROCSROW + 1, PROCSCOL + 3, 3); | 442 | putint(Total->t_rq - 1, PROCSROW + 1, PROCSCOL + 3, 3); | |
440 | putint(Total->t_dw, PROCSROW + 1, PROCSCOL + 6, 3); | 443 | putint(Total->t_dw, PROCSROW + 1, PROCSCOL + 6, 3); | |
441 | putint(Total->t_sl, PROCSROW + 1, PROCSCOL + 9, 3); | 444 | putint(Total->t_sl, PROCSROW + 1, PROCSCOL + 9, 3); | |
442 | 445 | |||
443 | PUTRATE(us, us1, uvmexp->swtch, GENSTATROW + 1, GENSTATCOL - 1, 7); | 446 | PUTRATE(us, us1, uvmexp->swtch, GENSTATROW + 1, GENSTATCOL - 1, 7); | |
444 | PUTRATE(us, us1, uvmexp->traps, GENSTATROW + 1, GENSTATCOL + 7, 6); | 447 | PUTRATE(us, us1, uvmexp->traps, GENSTATROW + 1, GENSTATCOL + 7, 6); | |
445 | PUTRATE(us, us1, uvmexp->syscalls, GENSTATROW + 1, GENSTATCOL + 14, 6); | 448 | PUTRATE(us, us1, uvmexp->syscalls, GENSTATROW + 1, GENSTATCOL + 14, 6); | |
446 | PUTRATE(us, us1, uvmexp->intrs, GENSTATROW + 1, GENSTATCOL + 21, 5); | 449 | PUTRATE(us, us1, uvmexp->intrs, GENSTATROW + 1, GENSTATCOL + 21, 5); | |
447 | PUTRATE(us, us1, uvmexp->softs, GENSTATROW + 1, GENSTATCOL + 27, 6); | 450 | PUTRATE(us, us1, uvmexp->softs, GENSTATROW + 1, GENSTATCOL + 27, 6); | |
448 | PUTRATE(us, us1, uvmexp->faults, GENSTATROW + 1, GENSTATCOL + 34, 6); | 451 | PUTRATE(us, us1, uvmexp->faults, GENSTATROW + 1, GENSTATCOL + 34, 6); | |
449 | 452 | |||
453 | /* | |||
454 | * XXX it sure would be nice if this did what top(1) does and showed | |||
455 | * the utilization of each CPU on a separate line, though perhaps IFF | |||
456 | * the screen is tall enough | |||
457 | */ | |||
450 | /* Last CPU state not calculated yet. */ | 458 | /* Last CPU state not calculated yet. */ | |
451 | for (f2 = 0.0, psiz = 0, c = 0; c < CPUSTATES; c++) { | 459 | for (f2 = 0.0, psiz = 0, c = 0; c < CPUSTATES; c++) { | |
452 | i = cpuorder[c]; | 460 | i = cpuorder[c]; | |
453 | f1 = cputime(i); | 461 | f1 = cputime(i); | |
454 | f2 += f1; | 462 | f2 += f1; | |
455 | l = (int) ((f2 + 1.0) / 2.0) - psiz; | 463 | l = (int) ((f2 + 1.0) / 2.0) - psiz; | |
456 | if (c == 0) | 464 | if (c == 0) | |
457 | putfloat(f1, GRAPHROW, GRAPHCOL + 1, 5, 1, 0); | 465 | putfloat(f1, GRAPHROW, GRAPHCOL + 1, 5, 1, 0); | |
458 | else | 466 | else | |
459 | putfloat(f1, GRAPHROW, GRAPHCOL + 10 * c + 1, 5, 1, 0); | 467 | putfloat(f1, GRAPHROW, GRAPHCOL + 10 * c + 1, 5, 1, 0); | |
460 | mvhline(GRAPHROW + 2, psiz, cpuchar[c], l); | 468 | mvhline(GRAPHROW + 2, psiz, cpuchar[c], l); | |
461 | psiz += l; | 469 | psiz += l; | |
462 | } | 470 | } | |
@@ -466,26 +474,31 @@ show_vmstat_top(vmtotal_t *Total, uvmexp | @@ -466,26 +474,31 @@ show_vmstat_top(vmtotal_t *Total, uvmexp | |||
466 | PUTRATE(us, us1, uvmexp->pgswapin, PAGEROW + 3, PAGECOL + 5, 5); | 474 | PUTRATE(us, us1, uvmexp->pgswapin, PAGEROW + 3, PAGECOL + 5, 5); | |
467 | PUTRATE(us, us1, uvmexp->pgswapout, PAGEROW + 3, PAGECOL + 10, 5); | 475 | PUTRATE(us, us1, uvmexp->pgswapout, PAGEROW + 3, PAGECOL + 10, 5); | |
468 | } | 476 | } | |
469 | 477 | |||
470 | void | 478 | void | |
471 | showvmstat(void) | 479 | showvmstat(void) | |
472 | { | 480 | { | |
473 | int inttotal; | 481 | int inttotal; | |
474 | int i, l, r, c; | 482 | int i, l, r, c; | |
475 | static int failcnt = 0; | 483 | static int failcnt = 0; | |
476 | static int relabel = 0; | 484 | static int relabel = 0; | |
477 | static int last_disks = 0; | 485 | static int last_disks = 0; | |
478 | static char pigs[] = "pigs"; | 486 | static char pigs[] = "pigs"; | |
487 | static u_long bufmem; | |||
488 | struct buf_sysctl *buffers; | |||
489 | int mib[6]; | |||
490 | size_t size; | |||
491 | int extraslop = 0; | |||
479 | 492 | |||
480 | if (relabel) { | 493 | if (relabel) { | |
481 | labelvmstat(); | 494 | labelvmstat(); | |
482 | relabel = 0; | 495 | relabel = 0; | |
483 | } | 496 | } | |
484 | 497 | |||
485 | cpuswap(); | 498 | cpuswap(); | |
486 | if (display_mode == TIME) { | 499 | if (display_mode == TIME) { | |
487 | drvswap(); | 500 | drvswap(); | |
488 | etime = cur.cp_etime; | 501 | etime = cur.cp_etime; | |
489 | /* < 5 ticks - ignore this trash */ | 502 | /* < 5 ticks - ignore this trash */ | |
490 | if ((etime * hertz) < 1.0) { | 503 | if ((etime * hertz) < 1.0) { | |
491 | if (failcnt++ <= MAXFAIL) | 504 | if (failcnt++ <= MAXFAIL) | |
@@ -497,36 +510,94 @@ showvmstat(void) | @@ -497,36 +510,94 @@ showvmstat(void) | |||
497 | refresh(); | 510 | refresh(); | |
498 | failcnt = 0; | 511 | failcnt = 0; | |
499 | sleep(5); | 512 | sleep(5); | |
500 | command(pigs); | 513 | command(pigs); | |
501 | return; | 514 | return; | |
502 | } | 515 | } | |
503 | } else | 516 | } else | |
504 | etime = 1.0; | 517 | etime = 1.0; | |
505 | 518 | |||
506 | show_vmstat_top(&s.Total, &s.uvmexp, &s1.uvmexp); | 519 | show_vmstat_top(&s.Total, &s.uvmexp, &s1.uvmexp); | |
507 | 520 | |||
508 | /* Memory totals */ | 521 | /* Memory totals */ | |
509 | #define pgtokb(pg) ((pg) * (s.uvmexp.pagesize / 1024)) | 522 | #define pgtokb(pg) ((pg) * (s.uvmexp.pagesize / 1024)) | |
510 | putint(pgtokb(s.uvmexp.active), MEMROW + 2, MEMCOL + 6, 9); | 523 | ||
511 | putint(pgtokb(s.uvmexp.active + s.uvmexp.swpginuse), /* XXX */ | 524 | putint(pgtokb(s.uvmexp.anonpages), MEMROW + 0, MEMCOL + 7, 10); | |
512 | MEMROW + 2, MEMCOL + 16, 9); | 525 | putint((s.uvmexp.anonpages * 100 + 0.5) / s.uvmexp.npages, MEMROW + 0, MEMCOL + 17, 4); | |
513 | putint(pgtokb(s.uvmexp.npages - s.uvmexp.free), | 526 | ||
514 | MEMROW + 3, MEMCOL + 6, 9); | 527 | putint(pgtokb(s.uvmexp.zeropages), MEMROW + 0, MEMCOL + 30, 8); | |
515 | putint(pgtokb(s.uvmexp.npages - s.uvmexp.free + s.uvmexp.swpginuse), | 528 | ||
516 | MEMROW + 3, MEMCOL + 16, 9); | 529 | putint(pgtokb(s.uvmexp.execpages), MEMROW + 1, MEMCOL + 7, 10); | |
517 | putint(pgtokb(s.uvmexp.free), MEMROW + 2, MEMCOL + 26, 9); | 530 | putint((s.uvmexp.execpages * 100 + 0.5) / s.uvmexp.npages, MEMROW + 1, MEMCOL + 17, 4); | |
518 | putint(pgtokb(s.uvmexp.free + s.uvmexp.swpages - s.uvmexp.swpginuse), | 531 | ||
519 | MEMROW + 3, MEMCOL + 26, 9); | 532 | putint(pgtokb(s.uvmexp.wired), MEMROW + 1, MEMCOL + 30, 8); | |
533 | ||||
534 | putint(pgtokb(s.uvmexp.filepages), MEMROW + 2, MEMCOL + 7, 10); | |||
535 | putint((s.uvmexp.filepages * 100 + 0.5) / s.uvmexp.npages, MEMROW + 2, MEMCOL + 17, 4); | |||
536 | ||||
537 | putint(pgtokb(s.uvmexp.inactive), MEMROW + 2, MEMCOL + 30, 8); | |||
538 | ||||
539 | /* Get total size of metadata buffers */ | |||
540 | size = sizeof(bufmem); | |||
541 | if (sysctlbyname("vm.bufmem", &bufmem, &size, NULL, 0) < 0) { | |||
542 | error("can't get buffers size: %s\n", strerror(errno)); | |||
543 | return; | |||
544 | } | |||
545 | ||||
546 | /* Get number of metadata buffers */ | |||
547 | size = 0; | |||
548 | buffers = NULL; | |||
549 | mib[0] = CTL_KERN; | |||
550 | mib[1] = KERN_BUF; | |||
551 | mib[2] = KERN_BUF_ALL; | |||
552 | mib[3] = KERN_BUF_ALL; | |||
553 | mib[4] = (int)sizeof(struct buf_sysctl); | |||
554 | mib[5] = INT_MAX; /* we want them all */ | |||
555 | again: | |||
556 | if (sysctl(mib, 6, NULL, &size, NULL, 0) < 0) { | |||
557 | error("can't get buffers size: %s\n", strerror(errno)); | |||
558 | return; | |||
559 | } | |||
560 | if (size == 0) { | |||
561 | error("buffers size is zero: %s\n", strerror(errno)); | |||
562 | return; | |||
563 | } | |||
564 | size += extraslop * sizeof(struct buf_sysctl); | |||
565 | buffers = malloc(size); | |||
566 | if (buffers == NULL) { | |||
567 | error("can't allocate buffers: %s\n", strerror(errno)); | |||
568 | return; | |||
569 | } | |||
570 | if (sysctl(mib, 6, buffers, &size, NULL, 0) < 0) { | |||
571 | free(buffers); | |||
572 | if (extraslop == 0) { | |||
573 | extraslop = 100; | |||
574 | goto again; | |||
575 | } | |||
576 | error("can't get buffers: %s\n", strerror(errno)); | |||
577 | return; | |||
578 | } | |||
579 | free(buffers); /* XXX there must be a better way! */ | |||
580 | nbuf = size / sizeof(struct buf_sysctl); | |||
581 | ||||
582 | putint((int) (bufmem / 1024), MEMROW + 3, MEMCOL + 5, 12); | |||
583 | putint((int) ((bufmem * 100) + 0.5) / s.uvmexp.pagesize / s.uvmexp.npages, | |||
584 | MEMROW + 3, MEMCOL + 17, 4); | |||
585 | putint(nbuf, MEMROW + 3, MEMCOL + 30, 8); | |||
586 | ||||
587 | putint(pgtokb(s.uvmexp.active), MEMROW + 5, MEMCOL + 7, 10); | |||
588 | putint(pgtokb(s.uvmexp.swpgonly), MEMROW + 5, MEMCOL + 18, 10); | |||
589 | putint(pgtokb(s.uvmexp.free), MEMROW + 5, MEMCOL + 28, 10); | |||
590 | ||||
520 | #undef pgtokb | 591 | #undef pgtokb | |
521 | 592 | |||
522 | /* Namei cache */ | 593 | /* Namei cache */ | |
523 | Z(s, s1, ncs_goodhits); Z(s, s1, ncs_badhits); Z(s, s1, ncs_miss); | 594 | Z(s, s1, ncs_goodhits); Z(s, s1, ncs_badhits); Z(s, s1, ncs_miss); | |
524 | Z(s, s1, ncs_long); Z(s, s1, ncs_pass2); Z(s, s1, ncs_2passes); | 595 | Z(s, s1, ncs_long); Z(s, s1, ncs_pass2); Z(s, s1, ncs_2passes); | |
525 | s.nchcount = s.nchstats.ncs_goodhits + s.nchstats.ncs_badhits + | 596 | s.nchcount = s.nchstats.ncs_goodhits + s.nchstats.ncs_badhits + | |
526 | s.nchstats.ncs_miss + s.nchstats.ncs_long + | 597 | s.nchstats.ncs_miss + s.nchstats.ncs_long + | |
527 | s.nchstats.ncs_pass2 + s.nchstats.ncs_2passes; | 598 | s.nchstats.ncs_pass2 + s.nchstats.ncs_2passes; | |
528 | if (display_mode == TIME) | 599 | if (display_mode == TIME) | |
529 | s1.nchcount = s.nchcount; | 600 | s1.nchcount = s.nchcount; | |
530 | 601 | |||
531 | putint(s.nchcount, NAMEIROW + 2, NAMEICOL, 9); | 602 | putint(s.nchcount, NAMEIROW + 2, NAMEICOL, 9); | |
532 | putint(s.nchstats.ncs_goodhits, NAMEIROW + 2, NAMEICOL + 9, 9); | 603 | putint(s.nchstats.ncs_goodhits, NAMEIROW + 2, NAMEICOL + 9, 9); | |
@@ -623,27 +694,27 @@ showvmstat(void) | @@ -623,27 +694,27 @@ showvmstat(void) | |||
623 | PUTRATE(s, s1, uvmexp.forks_ppwait, VMSTATROW + 1, VMSTATCOL + 3, 6); | 694 | PUTRATE(s, s1, uvmexp.forks_ppwait, VMSTATROW + 1, VMSTATCOL + 3, 6); | |
624 | PUTRATE(s, s1, uvmexp.forks_sharevm, VMSTATROW + 2, VMSTATCOL + 3, 6); | 695 | PUTRATE(s, s1, uvmexp.forks_sharevm, VMSTATROW + 2, VMSTATCOL + 3, 6); | |
625 | PUTRATE(s, s1, uvmexp.fltpgwait, VMSTATROW + 3, VMSTATCOL + 4, 5); | 696 | PUTRATE(s, s1, uvmexp.fltpgwait, VMSTATROW + 3, VMSTATCOL + 4, 5); | |
626 | PUTRATE(s, s1, uvmexp.fltrelck, VMSTATROW + 4, VMSTATCOL + 3, 6); | 697 | PUTRATE(s, s1, uvmexp.fltrelck, VMSTATROW + 4, VMSTATCOL + 3, 6); | |
627 | PUTRATE(s, s1, uvmexp.fltrelckok, VMSTATROW + 5, VMSTATCOL + 3, 6); | 698 | PUTRATE(s, s1, uvmexp.fltrelckok, VMSTATROW + 5, VMSTATCOL + 3, 6); | |
628 | PUTRATE(s, s1, uvmexp.fltnoram, VMSTATROW + 6, VMSTATCOL + 3, 6); | 699 | PUTRATE(s, s1, uvmexp.fltnoram, VMSTATROW + 6, VMSTATCOL + 3, 6); | |
629 | PUTRATE(s, s1, uvmexp.fltamcopy, VMSTATROW + 7, VMSTATCOL + 3, 6); | 700 | PUTRATE(s, s1, uvmexp.fltamcopy, VMSTATROW + 7, VMSTATCOL + 3, 6); | |
630 | PUTRATE(s, s1, uvmexp.flt_prcopy, VMSTATROW + 8, VMSTATCOL + 3, 6); | 701 | PUTRATE(s, s1, uvmexp.flt_prcopy, VMSTATROW + 8, VMSTATCOL + 3, 6); | |
631 | PUTRATE(s, s1, uvmexp.flt_przero, VMSTATROW + 9, VMSTATCOL + 3, 6); | 702 | PUTRATE(s, s1, uvmexp.flt_przero, VMSTATROW + 9, VMSTATCOL + 3, 6); | |
632 | PUTRATE(s, s1, uvmexp.flt_acow, VMSTATROW + 10, VMSTATCOL, 9); | 703 | PUTRATE(s, s1, uvmexp.flt_acow, VMSTATROW + 10, VMSTATCOL, 9); | |
633 | putint(s.uvmexp.freemin, VMSTATROW + 11, VMSTATCOL, 9); | 704 | putint(s.uvmexp.freemin, VMSTATROW + 11, VMSTATCOL, 9); | |
634 | putint(s.uvmexp.freetarg, VMSTATROW + 12, VMSTATCOL, 9); | 705 | putint(s.uvmexp.freetarg, VMSTATROW + 12, VMSTATCOL, 9); | |
635 | putint(s.uvmexp.inactarg, VMSTATROW + 13, VMSTATCOL, 9); | 706 | putint(s.uvmexp.inactarg, VMSTATROW + 13, VMSTATCOL, 9); | |
636 | putint(s.uvmexp.wired, VMSTATROW + 14, VMSTATCOL, 9); | 707 | putint(s.uvmexp.fltnoanon, VMSTATROW + 14, VMSTATCOL, 9); | |
637 | PUTRATE(s, s1, uvmexp.pdfreed, VMSTATROW + 15, VMSTATCOL, 9); | 708 | PUTRATE(s, s1, uvmexp.pdfreed, VMSTATROW + 15, VMSTATCOL, 9); | |
638 | if (LINES - 1 > VMSTATROW + 16) | 709 | if (LINES - 1 > VMSTATROW + 16) | |
639 | PUTRATE(s, s1, uvmexp.pdscans, VMSTATROW + 16, VMSTATCOL, 9); | 710 | PUTRATE(s, s1, uvmexp.pdscans, VMSTATROW + 16, VMSTATCOL, 9); | |
640 | 711 | |||
641 | } | 712 | } | |
642 | 713 | |||
643 | void | 714 | void | |
644 | vmstat_boot(char *args) | 715 | vmstat_boot(char *args) | |
645 | { | 716 | { | |
646 | copyinfo(&z, &s1); | 717 | copyinfo(&z, &s1); | |
647 | display_mode = BOOT; | 718 | display_mode = BOOT; | |
648 | } | 719 | } | |
649 | 720 | |||
@@ -766,27 +837,27 @@ getinfo(struct Info *stats) | @@ -766,27 +837,27 @@ getinfo(struct Info *stats) | |||
766 | int mib[2]; | 837 | int mib[2]; | |
767 | size_t size; | 838 | size_t size; | |
768 | int i; | 839 | int i; | |
769 | 840 | |||
770 | cpureadstats(); | 841 | cpureadstats(); | |
771 | drvreadstats(); | 842 | drvreadstats(); | |
772 | size = sizeof(stats->nchstats); | 843 | size = sizeof(stats->nchstats); | |
773 | if (sysctlbyname("vfs.namecache_stats", &stats->nchstats, &size, | 844 | if (sysctlbyname("vfs.namecache_stats", &stats->nchstats, &size, | |
774 | NULL, 0) < 0) { | 845 | NULL, 0) < 0) { | |
775 | error("can't get namecache statistics: %s\n", strerror(errno)); | 846 | error("can't get namecache statistics: %s\n", strerror(errno)); | |
776 | memset(&stats->nchstats, 0, sizeof(stats->nchstats)); | 847 | memset(&stats->nchstats, 0, sizeof(stats->nchstats)); | |
777 | } | 848 | } | |
778 | if (nintr) | 849 | if (nintr) | |
779 | NREAD(X_INTRCNT, stats->intrcnt, nintr * LONG); | 850 | NREAD(X_INTRCNT, stats->intrcnt, nintr * sizeof(long)); | |
780 | for (i = 0; i < nevcnt; i++) | 851 | for (i = 0; i < nevcnt; i++) | |
781 | KREAD(ie_head[i].ie_count, &stats->evcnt[i], | 852 | KREAD(ie_head[i].ie_count, &stats->evcnt[i], | |
782 | sizeof stats->evcnt[i]); | 853 | sizeof stats->evcnt[i]); | |
783 | size = sizeof(stats->uvmexp); | 854 | size = sizeof(stats->uvmexp); | |
784 | mib[0] = CTL_VM; | 855 | mib[0] = CTL_VM; | |
785 | mib[1] = VM_UVMEXP2; | 856 | mib[1] = VM_UVMEXP2; | |
786 | if (sysctl(mib, 2, &stats->uvmexp, &size, NULL, 0) < 0) { | 857 | if (sysctl(mib, 2, &stats->uvmexp, &size, NULL, 0) < 0) { | |
787 | error("can't get uvmexp: %s\n", strerror(errno)); | 858 | error("can't get uvmexp: %s\n", strerror(errno)); | |
788 | memset(&stats->uvmexp, 0, sizeof(stats->uvmexp)); | 859 | memset(&stats->uvmexp, 0, sizeof(stats->uvmexp)); | |
789 | } | 860 | } | |
790 | size = sizeof(stats->Total); | 861 | size = sizeof(stats->Total); | |
791 | mib[0] = CTL_VM; | 862 | mib[0] = CTL_VM; | |
792 | mib[1] = VM_METER; | 863 | mib[1] = VM_METER; |