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