cmdtab.c revision 1.12 1 /* $NetBSD: cmdtab.c,v 1.12 1999/12/22 14:46:14 kleink 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.12 1999/12/22 14:46:14 kleink Exp $");
42 #endif /* not lint */
43
44 #include "systat.h"
45 #include "extern.h"
46
47 struct command global_commands[] = {
48 { "help", global_help, "show help"},
49 { "interval", global_interval, "set update interval"},
50 { "load", global_load, "show system load averages"},
51 { "quit", global_quit, "exit systat"},
52 /* until prefix matching works, handle the same special case */
53 { "q", global_quit, "exit systat"},
54 { "start", global_interval, "restart updating display"},
55 { "stop", global_stop, "stop updating display"},
56 { 0 }
57 };
58
59 struct command iostat_commands[] = {
60 { "bars", iostat_bars, "show io stats as a bar graph"},
61 { "numbers", iostat_numbers, "show io stats numerically"},
62 { "secs", iostat_secs, "include time statistics"},
63 /* from disks.c */
64 { "add", disks_add, "add a disk to displayed disks"},
65 { "show", disks_add, "add a disk to displayed disks"},
66 { "delete", disks_delete, "remove a disk from displayed disks"},
67 { "ignore", disks_delete, "remove a disk from displayed disks"},
68 { "drives", disks_drives, "list all disks"},
69 { 0 }
70 };
71
72 struct command netstat_commands[] = {
73 { "all", netstat_all, "include server sockets"},
74 { "display", netstat_display, "show specified hosts or ports"},
75 { "ignore", netstat_ignore, "hide specified hosts or ports"},
76 { "names", netstat_names, "show names instead of addresses"},
77 { "numbers", netstat_numbers, "show addresses instead of names"},
78 { "reset", netstat_reset, "return to default display"},
79 { "show", netstat_show, "show current display/ignore settings"},
80 { "tcp", netstat_tcp, "show only tcp connections"},
81 { "udp", netstat_udp, "show only udp connections"},
82 { 0 }
83 };
84
85 struct command ps_commands[] = {
86 { "user", ps_user, "limit displayed processes to a user"},
87 { 0 }
88 };
89
90 struct command vmstat_commands[] = {
91 { "boot", vmstat_boot, "show total vm stats since boot"},
92 { "run", vmstat_run, "show running total vm stats"},
93 { "time", vmstat_time, "show vm stats for each sample time"},
94 { "zero", vmstat_zero, "re-zero running totals"},
95 /* from disks.c */
96 { "add", disks_add, "add a disk to displayed disks"},
97 { "show", disks_add, "add a disk to displayed disks"},
98 { "delete", disks_delete, "remove a disk from displayed disks"},
99 { "ignore", disks_delete, "remove a disk from displayed disks"},
100 { "drives", disks_drives, "list all disks"},
101 { 0 }
102 };
103
104 struct mode modes[] = {
105 /* "pigs" is the default, it must be first. */
106 { "pigs", showpigs, fetchpigs, labelpigs,
107 initpigs, openpigs, closepigs, 0,
108 CF_LOADAV },
109 { "bufcache", showbufcache, fetchbufcache, labelbufcache,
110 initbufcache, openbufcache, closebufcache, 0,
111 CF_LOADAV },
112 { "inet.icmp", showicmp, fetchicmp, labelicmp,
113 initicmp, openicmp, closeicmp, 0,
114 CF_LOADAV },
115 { "inet.ip", showip, fetchip, labelip,
116 initip, openip, closeip, 0,
117 CF_LOADAV },
118 { "inet.tcp", showtcp, fetchtcp, labeltcp,
119 inittcp, opentcp, closetcp, 0,
120 CF_LOADAV },
121 { "inet.tcpsyn",showtcpsyn, fetchtcp, labeltcpsyn,
122 inittcp, opentcp, closetcp, 0,
123 CF_LOADAV },
124 { "iostat", showiostat, fetchiostat, labeliostat,
125 initiostat, openiostat, closeiostat, iostat_commands,
126 CF_LOADAV },
127 { "mbufs", showmbufs, fetchmbufs, labelmbufs,
128 initmbufs, openmbufs, closembufs, 0,
129 CF_LOADAV },
130 { "netstat", shownetstat, fetchnetstat, labelnetstat,
131 initnetstat, opennetstat, closenetstat, netstat_commands,
132 CF_LOADAV },
133 { "ps", showps, fetchpigs, labelps,
134 initpigs, openpigs, closepigs, ps_commands,
135 CF_LOADAV },
136 { "swap", showswap, fetchswap, labelswap,
137 initswap, openswap, closeswap, 0,
138 CF_LOADAV },
139 { "vmstat", showkre, fetchkre, labelkre,
140 initkre, openkre, closekre, vmstat_commands,
141 0 },
142 { 0 }
143 };
144 struct mode *curmode = &modes[0];
145