1 /* $NetBSD: cmdtab.c,v 1.17 2002/11/01 12:47:57 mrg 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.17 2002/11/01 12:47:57 mrg 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 { "rw", iostat_rw, "show read/write disk stats"}, 75 { "all", iostat_all, "show combiend disk stats"}, 76 /* from disks.c */ 77 { "add", disks_add, "add a disk to displayed disks"}, 78 { "show", disks_add, "add a disk to displayed disks"}, 79 { "delete", disks_delete, "remove a disk from displayed disks"}, 80 { "ignore", disks_delete, "remove a disk from displayed disks"}, 81 { "drives", disks_drives, "list all disks"}, 82 { 0 } 83 }; 84 85 struct command ip_commands[] = { 86 { "boot", ip_boot, "show total stats since boot"}, 87 { "run", ip_run, "show running total stats"}, 88 { "time", ip_time, "show stats for each sample time"}, 89 { "zero", ip_zero, "re-zero running totals"}, 90 { 0 } 91 }; 92 93 #ifdef INET6 94 struct command ip6_commands[] = { 95 { "boot", ip6_boot, "show total stats since boot"}, 96 { "run", ip6_run, "show running total stats"}, 97 { "time", ip6_time, "show stats for each sample time"}, 98 { "zero", ip6_zero, "re-zero running totals"}, 99 { 0 } 100 }; 101 #endif 102 103 #ifdef IPSEC 104 struct command ipsec_commands[] = { 105 { "boot", ipsec_boot, "show total stats since boot"}, 106 { "run", ipsec_run, "show running total stats"}, 107 { "time", ipsec_time, "show stats for each sample time"}, 108 { "zero", ipsec_zero, "re-zero running totals"}, 109 { NULL, NULL, NULL }, 110 }; 111 #endif 112 113 struct command netstat_commands[] = { 114 { "all", netstat_all, "include server sockets"}, 115 { "display", netstat_display, "show specified hosts or ports"}, 116 { "ignore", netstat_ignore, "hide specified hosts or ports"}, 117 { "names", netstat_names, "show names instead of addresses"}, 118 { "numbers", netstat_numbers, "show addresses instead of names"}, 119 { "reset", netstat_reset, "return to default display"}, 120 { "show", netstat_show, "show current display/ignore settings"}, 121 { "tcp", netstat_tcp, "show only tcp connections"}, 122 { "udp", netstat_udp, "show only udp connections"}, 123 { 0 } 124 }; 125 126 struct command ps_commands[] = { 127 { "user", ps_user, "limit displayed processes to a user"}, 128 { 0 } 129 }; 130 131 struct command tcp_commands[] = { 132 { "boot", tcp_boot, "show total stats since boot"}, 133 { "run", tcp_run, "show running total stats"}, 134 { "time", tcp_time, "show stats for each sample time"}, 135 { "zero", tcp_zero, "re-zero running totals"}, 136 { NULL, NULL, NULL }, 137 }; 138 139 struct command vmstat_commands[] = { 140 { "boot", vmstat_boot, "show total vm stats since boot"}, 141 { "run", vmstat_run, "show running total vm stats"}, 142 { "time", vmstat_time, "show vm stats for each sample time"}, 143 { "zero", vmstat_zero, "re-zero running totals"}, 144 /* from disks.c */ 145 { "add", disks_add, "add a disk to displayed disks"}, 146 { "show", disks_add, "add a disk to displayed disks"}, 147 { "delete", disks_delete, "remove a disk from displayed disks"}, 148 { "ignore", disks_delete, "remove a disk from displayed disks"}, 149 { "drives", disks_drives, "list all disks"}, 150 { 0 } 151 }; 152 153 struct mode modes[] = { 154 /* "pigs" is the default, it must be first. */ 155 { "pigs", showpigs, fetchpigs, labelpigs, 156 initpigs, openpigs, closepigs, 0, 157 CF_LOADAV }, 158 { "bufcache", showbufcache, fetchbufcache, labelbufcache, 159 initbufcache, openbufcache, closebufcache, 0, 160 CF_LOADAV }, 161 { "inet.icmp", showicmp, fetchicmp, labelicmp, 162 initicmp, openicmp, closeicmp, icmp_commands, 163 CF_LOADAV }, 164 { "inet.ip", showip, fetchip, labelip, 165 initip, openip, closeip, ip_commands, 166 CF_LOADAV }, 167 { "inet.tcp", showtcp, fetchtcp, labeltcp, 168 inittcp, opentcp, closetcp, tcp_commands, 169 CF_LOADAV }, 170 { "inet.tcpsyn",showtcpsyn, fetchtcp, labeltcpsyn, 171 inittcp, opentcp, closetcp, tcp_commands, 172 CF_LOADAV }, 173 #ifdef INET6 174 { "inet6.ip6", showip6, fetchip6, labelip6, 175 initip6, openip6, closeip6, ip6_commands, 176 CF_LOADAV }, 177 #endif 178 #ifdef IPSEC 179 { "ipsec", showipsec, fetchipsec, labelipsec, 180 initipsec, openipsec, closeipsec, ipsec_commands, 181 CF_LOADAV }, 182 #endif 183 { "iostat", showiostat, fetchiostat, labeliostat, 184 initiostat, openiostat, closeiostat, iostat_commands, 185 CF_LOADAV }, 186 { "mbufs", showmbufs, fetchmbufs, labelmbufs, 187 initmbufs, openmbufs, closembufs, 0, 188 CF_LOADAV }, 189 { "netstat", shownetstat, fetchnetstat, labelnetstat, 190 initnetstat, opennetstat, closenetstat, netstat_commands, 191 CF_LOADAV }, 192 { "ps", showps, fetchpigs, labelps, 193 initpigs, openpigs, closepigs, ps_commands, 194 CF_LOADAV }, 195 { "swap", showswap, fetchswap, labelswap, 196 initswap, openswap, closeswap, 0, 197 CF_LOADAV }, 198 { "vmstat", showvmstat, fetchvmstat, labelvmstat, 199 initvmstat, openvmstat, closevmstat, vmstat_commands, 200 0 }, 201 { 0 } 202 }; 203 struct mode *curmode = &modes[0]; 204