cmdtab.c revision 1.16 1 /* $NetBSD: cmdtab.c,v 1.16 2000/07/05 11:03:21 ad Exp $ */
2
3 /*-
4 * Copyright (c) 1980, 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36 #include <sys/cdefs.h>
37 #ifndef lint
38 #if 0
39 static char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93";
40 #endif
41 __RCSID("$NetBSD: cmdtab.c,v 1.16 2000/07/05 11:03:21 ad Exp $");
42 #endif /* not lint */
43
44 #include "systat.h"
45 #include "extern.h"
46
47 /*
48 * NOTE: if one command is a substring of another, the shorter string
49 * MUST come first, or it will be shadowed by the longer
50 */
51
52 struct command global_commands[] = {
53 { "help", global_help, "show help"},
54 { "interval", global_interval, "set update interval"},
55 { "load", global_load, "show system load averages"},
56 { "quit", global_quit, "exit systat"},
57 { "start", global_interval, "restart updating display"},
58 { "stop", global_stop, "stop updating display"},
59 { 0 }
60 };
61
62 struct command icmp_commands[] = {
63 { "boot", icmp_boot, "show total stats since boot"},
64 { "run", icmp_run, "show running total stats"},
65 { "time", icmp_time, "show stats for each sample time"},
66 { "zero", icmp_zero, "re-zero running totals"},
67 { 0 }
68 };
69
70 struct command iostat_commands[] = {
71 { "bars", iostat_bars, "show io stats as a bar graph"},
72 { "numbers", iostat_numbers, "show io stats numerically"},
73 { "secs", iostat_secs, "include time statistics"},
74 /* from disks.c */
75 { "add", disks_add, "add a disk to displayed disks"},
76 { "show", disks_add, "add a disk to displayed disks"},
77 { "delete", disks_delete, "remove a disk from displayed disks"},
78 { "ignore", disks_delete, "remove a disk from displayed disks"},
79 { "drives", disks_drives, "list all disks"},
80 { 0 }
81 };
82
83 struct command ip_commands[] = {
84 { "boot", ip_boot, "show total stats since boot"},
85 { "run", ip_run, "show running total stats"},
86 { "time", ip_time, "show stats for each sample time"},
87 { "zero", ip_zero, "re-zero running totals"},
88 { 0 }
89 };
90
91 #ifdef INET6
92 struct command ip6_commands[] = {
93 { "boot", ip6_boot, "show total stats since boot"},
94 { "run", ip6_run, "show running total stats"},
95 { "time", ip6_time, "show stats for each sample time"},
96 { "zero", ip6_zero, "re-zero running totals"},
97 { 0 }
98 };
99 #endif
100
101 #ifdef IPSEC
102 struct command ipsec_commands[] = {
103 { "boot", ipsec_boot, "show total stats since boot"},
104 { "run", ipsec_run, "show running total stats"},
105 { "time", ipsec_time, "show stats for each sample time"},
106 { "zero", ipsec_zero, "re-zero running totals"},
107 { NULL, NULL, NULL },
108 };
109 #endif
110
111 struct command netstat_commands[] = {
112 { "all", netstat_all, "include server sockets"},
113 { "display", netstat_display, "show specified hosts or ports"},
114 { "ignore", netstat_ignore, "hide specified hosts or ports"},
115 { "names", netstat_names, "show names instead of addresses"},
116 { "numbers", netstat_numbers, "show addresses instead of names"},
117 { "reset", netstat_reset, "return to default display"},
118 { "show", netstat_show, "show current display/ignore settings"},
119 { "tcp", netstat_tcp, "show only tcp connections"},
120 { "udp", netstat_udp, "show only udp connections"},
121 { 0 }
122 };
123
124 struct command ps_commands[] = {
125 { "user", ps_user, "limit displayed processes to a user"},
126 { 0 }
127 };
128
129 struct command tcp_commands[] = {
130 { "boot", tcp_boot, "show total stats since boot"},
131 { "run", tcp_run, "show running total stats"},
132 { "time", tcp_time, "show stats for each sample time"},
133 { "zero", tcp_zero, "re-zero running totals"},
134 { NULL, NULL, NULL },
135 };
136
137 struct command vmstat_commands[] = {
138 { "boot", vmstat_boot, "show total vm stats since boot"},
139 { "run", vmstat_run, "show running total vm stats"},
140 { "time", vmstat_time, "show vm stats for each sample time"},
141 { "zero", vmstat_zero, "re-zero running totals"},
142 /* from disks.c */
143 { "add", disks_add, "add a disk to displayed disks"},
144 { "show", disks_add, "add a disk to displayed disks"},
145 { "delete", disks_delete, "remove a disk from displayed disks"},
146 { "ignore", disks_delete, "remove a disk from displayed disks"},
147 { "drives", disks_drives, "list all disks"},
148 { 0 }
149 };
150
151 struct mode modes[] = {
152 /* "pigs" is the default, it must be first. */
153 { "pigs", showpigs, fetchpigs, labelpigs,
154 initpigs, openpigs, closepigs, 0,
155 CF_LOADAV },
156 { "bufcache", showbufcache, fetchbufcache, labelbufcache,
157 initbufcache, openbufcache, closebufcache, 0,
158 CF_LOADAV },
159 { "inet.icmp", showicmp, fetchicmp, labelicmp,
160 initicmp, openicmp, closeicmp, icmp_commands,
161 CF_LOADAV },
162 { "inet.ip", showip, fetchip, labelip,
163 initip, openip, closeip, ip_commands,
164 CF_LOADAV },
165 { "inet.tcp", showtcp, fetchtcp, labeltcp,
166 inittcp, opentcp, closetcp, tcp_commands,
167 CF_LOADAV },
168 { "inet.tcpsyn",showtcpsyn, fetchtcp, labeltcpsyn,
169 inittcp, opentcp, closetcp, tcp_commands,
170 CF_LOADAV },
171 #ifdef INET6
172 { "inet6.ip6", showip6, fetchip6, labelip6,
173 initip6, openip6, closeip6, ip6_commands,
174 CF_LOADAV },
175 #endif
176 #ifdef IPSEC
177 { "ipsec", showipsec, fetchipsec, labelipsec,
178 initipsec, openipsec, closeipsec, ipsec_commands,
179 CF_LOADAV },
180 #endif
181 { "iostat", showiostat, fetchiostat, labeliostat,
182 initiostat, openiostat, closeiostat, iostat_commands,
183 CF_LOADAV },
184 { "mbufs", showmbufs, fetchmbufs, labelmbufs,
185 initmbufs, openmbufs, closembufs, 0,
186 CF_LOADAV },
187 { "netstat", shownetstat, fetchnetstat, labelnetstat,
188 initnetstat, opennetstat, closenetstat, netstat_commands,
189 CF_LOADAV },
190 { "ps", showps, fetchpigs, labelps,
191 initpigs, openpigs, closepigs, ps_commands,
192 CF_LOADAV },
193 { "swap", showswap, fetchswap, labelswap,
194 initswap, openswap, closeswap, 0,
195 CF_LOADAV },
196 { "vmstat", showvmstat, fetchvmstat, labelvmstat,
197 initvmstat, openvmstat, closevmstat, vmstat_commands,
198 0 },
199 { 0 }
200 };
201 struct mode *curmode = &modes[0];
202