cmdtab.c revision 1.11 1 /* $NetBSD: cmdtab.c,v 1.11 1999/12/20 03:45:02 jwise 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.11 1999/12/20 03:45:02 jwise 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 vmstat_commands[] = {
86 { "boot", vmstat_boot, "show total vm stats since boot"},
87 { "run", vmstat_run, "show running total vm stats"},
88 { "time", vmstat_time, "show vm stats for each sample time"},
89 { "zero", vmstat_zero, "re-zero running totals"},
90 /* from disks.c */
91 { "add", disks_add, "add a disk to displayed disks"},
92 { "show", disks_add, "add a disk to displayed disks"},
93 { "delete", disks_delete, "remove a disk from displayed disks"},
94 { "ignore", disks_delete, "remove a disk from displayed disks"},
95 { "drives", disks_drives, "list all disks"},
96 { 0 }
97 };
98
99 struct mode modes[] = {
100 /* "pigs" is the default, it must be first. */
101 { "pigs", showpigs, fetchpigs, labelpigs,
102 initpigs, openpigs, closepigs, 0,
103 CF_LOADAV },
104 { "bufcache", showbufcache, fetchbufcache, labelbufcache,
105 initbufcache, openbufcache, closebufcache, 0,
106 CF_LOADAV },
107 { "inet.icmp", showicmp, fetchicmp, labelicmp,
108 initicmp, openicmp, closeicmp, 0,
109 CF_LOADAV },
110 { "inet.ip", showip, fetchip, labelip,
111 initip, openip, closeip, 0,
112 CF_LOADAV },
113 { "inet.tcp", showtcp, fetchtcp, labeltcp,
114 inittcp, opentcp, closetcp, 0,
115 CF_LOADAV },
116 { "inet.tcpsyn",showtcpsyn, fetchtcp, labeltcpsyn,
117 inittcp, opentcp, closetcp, 0,
118 CF_LOADAV },
119 { "iostat", showiostat, fetchiostat, labeliostat,
120 initiostat, openiostat, closeiostat, iostat_commands,
121 CF_LOADAV },
122 { "mbufs", showmbufs, fetchmbufs, labelmbufs,
123 initmbufs, openmbufs, closembufs, 0,
124 CF_LOADAV },
125 { "netstat", shownetstat, fetchnetstat, labelnetstat,
126 initnetstat, opennetstat, closenetstat, netstat_commands,
127 CF_LOADAV },
128 { "ps", showps, fetchpigs, labelps,
129 initpigs, openpigs, closepigs, 0,
130 CF_LOADAV },
131 { "swap", showswap, fetchswap, labelswap,
132 initswap, openswap, closeswap, 0,
133 CF_LOADAV },
134 { "vmstat", showkre, fetchkre, labelkre,
135 initkre, openkre, closekre, vmstat_commands,
136 0 },
137 { 0 }
138 };
139 struct mode *curmode = &modes[0];
140