2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer,
11 * without modification.
12 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
13 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
14 * redistribution must be conditioned upon including a substantially
15 * similar Disclaimer requirement for further binary redistribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
21 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
23 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
26 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGES.
34 * Simple Atheros-specific tool to inspect and monitor software queue
35 * and aggregate statistics.
37 * athaggrstats [-i interface] [-bz] [-l] [-o fmtstring] [interval]
39 * (default interface is ath0). If interval is specified a rolling output
40 * a la netstat -i is displayed every interval seconds. The format of
41 * the rolling display can be controlled a la ps. The -l option will
42 * print a list of all possible statistics for use with the -o option.
45 #include <sys/param.h>
54 #include "athaggrstats.h"
61 "singlepkt,nonbawpkt,aggrpkt,bawclosedpkt,lhsinglepkt,schednopkt,rtsaggrlimit"
66 getfmt(const char *tag)
69 for (i = 0; i < nitems(tags); i++)
70 if (strcasecmp(tags[i].tag, tag) == 0)
78 catchalarm(int signo __unused)
84 main(int argc, char *argv[])
86 struct athaggrstatfoo *wf;
90 ifname = getenv("ATH");
93 wf = athaggrstats_new(ifname, getfmt("default"));
94 while ((c = getopt(argc, argv, "bi:lo:z")) != -1) {
100 wf->setifname(wf, optarg);
103 wf->print_fields(wf, stdout);
106 wf->setfmt(wf, getfmt(optarg));
112 errx(-1, "usage: %s [-a] [-i ifname] [-l] [-o fmt] [-z] [interval]\n", argv[0]);
120 u_long interval = strtoul(argv[0], NULL, 0);
125 signal(SIGALRM, catchalarm);
130 wf->print_header(wf, stdout);
135 wf->print_current(wf, stdout);
139 wf->print_total(wf, stdout);
142 omask = sigblock(sigmask(SIGALRM));
149 if (line == 21) /* XXX tty line count */
156 wf->print_verbose(wf, stdout);