1 /******************************************************************************
2 * bwm-ng online help *
3 * *
4 * Copyright (C) 2004 Volker Gropp (vgropp@pefra.de) *
5 * *
6 * for more info read README. *
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
21 * *
22 *****************************************************************************/
23
24 #include "global_vars.h"
25 #include "help.h"
26
print_help_line(char * short_c,char * long_c,char * descr)27 inline void print_help_line(char *short_c,char * long_c,char *descr) {
28 #ifdef LONG_OPTIONS
29 printf(" %-23s",long_c);
30 #else
31 printf(" %-23s",short_c);
32 #endif
33 printf(" %s\n",descr);
34 }
35
36 /* prints a helpscreen and exists */
37 inline void cmdln_printhelp(void) FUNCATTR_NORETURN;
cmdln_printhelp()38 inline void cmdln_printhelp() {
39 print_version;
40 printf("USAGE: bwm-ng [OPTION] ...");
41 #if CONFIG_FILE
42 printf(" [CONFIGFILE]\n");
43 #else
44 printf("\n");
45 #endif
46 printf("displays current ethernet interfaces stats\n\n");
47 printf("Options:\n");
48 print_help_line("-t <msec>","-t, --timeout <msec>","displays stats every <msec> (1msec = 1/1000sec)");
49 print_help_line("","","default: 500");
50 print_help_line("-d","-d, --dynamic [value]","show values dynamicly (Byte KB or MB)");
51 print_help_line("-a [mode]","-a, --allif [mode]","where mode is one of:");
52 print_help_line("","","0=show only up (and selected) interfaces");
53 print_help_line("","","1=show all up interfaces (default)");
54 print_help_line("","","2=show all and down interfaces");
55 print_help_line("-I <list>","-I, --interfaces <list>","show only interfaces in <list> (comma seperated), or");
56 print_help_line("","","if list is prefaced with % show all but interfaces");
57 print_help_line("","","in list");
58 print_help_line("-S","-S, --sumhidden [value]","count hidden interfaces for total");
59 #if EXTENDED_STATS
60 print_help_line("-A","-A, --avglength <sec>","sets the span of average stats (Default 30s)");
61 #endif
62 print_help_line("-D","-D, --daemon [value]","fork into background and daemonize");
63 print_help_line("-h","-h, --help","displays this help");
64 print_help_line("-V","-V, --version","print version info");
65 printf("\nInput:\n");
66 print_help_line("-i <method>","-i, --input <method>","input method, one of:" INPUT_METHODS);
67 #ifdef PROC_NET_DEV
68 print_help_line("-f <file>","-f, --procfile <file>","filename to read raw data from. (" PROC_NET_DEV ")");
69 #endif
70 #ifdef PROC_DISKSTATS
71 print_help_line(""," --diskstatsfile <file>","filename to read diskstats (Linux 2.6+) from. (" PROC_DISKSTATS ")");
72 print_help_line(""," --partitionsfile <file>","filename to read diskstats (Linux 2.4) from. (" PROC_PARTITIONS ")");
73 #endif
74 #if ALLOW_NETSTATPATH
75 #ifdef NETSTAT
76 print_help_line("-n <path>","-n, --netstat <path>","use <path> as netstat binary");
77 #endif
78 #endif
79 printf("\nOutput:\n");
80 print_help_line("-o <method>","-o, --output <method>","output method, one of: ");
81 print_help_line("","",OUTPUT_METHODS);
82 print_help_line("-u","-u, --unit <value>","unit to show. one of bytes, bits, packets, errors");
83 #if EXTENDED_STATS
84 print_help_line("-T","-T, --type <value>","type of stats. one of rate, max, sum, avg");
85 #endif
86 #ifdef CSV
87 print_help_line("-C <char>","-C, --csvchar <char>","delimiter for csv");
88 #endif
89 #if CSV || HTML
90 print_help_line("-F <file>","-F, --outfile <file>","output file for csv and html (default stdout)");
91 #endif
92 #ifdef HTML
93 print_help_line("-R <num>","-R, --htmlrefresh <num>","meta refresh for html output");
94 print_help_line("-H","-H, --htmlheader","show <html> and <meta> frame for html output");
95 #endif
96 print_help_line("-c <num>","-c, --count <num>","number of query/output for plain & csv");
97 print_help_line("-N","-N, --ansiout","disable ansi codes for plain output");
98 print_help_line("","","(ie 1 for one single output)");
99 printf("\n");
100 exit(EXIT_SUCCESS);
101 }
102
103 #ifdef HAVE_CURSES
print_online_help()104 void print_online_help() {
105 WINDOW *helpwin;
106 helpwin=newwin(15,76,0,1);
107 box(helpwin,ACS_VLINE, ACS_HLINE);
108 mvwprintw(helpwin,0,2,"bwm-ng v" VERSION " - Keybindings:");
109 mvwprintw(helpwin,2,2,"'h' show this help");
110 mvwprintw(helpwin,3,2,"'q' exit");
111 mvwprintw(helpwin,4,2,"'+' increases timeout by 100ms");
112 mvwprintw(helpwin,5,2,"'-' decreases timeout by 100ms");
113 if (output_method==CURSES_OUT)
114 mvwprintw(helpwin,6,2,"'d' switch KB and auto assign Byte/KB/MB/GB");
115 else
116 mvwprintw(helpwin,6,2,"'d' cycle: show interfaces step by step");
117 mvwprintw(helpwin,7,2,"'a' cycle: show all interfaces, only those which are up,");
118 mvwprintw(helpwin,8,2," only up and not hidden");
119 mvwprintw(helpwin,9,2,"'s' sum hidden ifaces to total aswell or not");
120 mvwprintw(helpwin,10,2,"'n' cycle: input methods");
121 if (output_method==CURSES_OUT) { mvwprintw(helpwin,11,2,"'u' cycle: bytes,bits,packets,errors");
122 #if EXTENDED_STATS
123 mvwprintw(helpwin,12,2,"'t' cycle: current rate, max, sum since start, average for last 30s");
124 #endif
125 }
126 else {
127 #if EXTENDED_STATS
128 mvwprintw(helpwin,11,2,"'t' cycle: current rate, max, sum since start, average for last 30s");
129 #endif
130 };
131 mvwprintw(helpwin,14,2," press any key to continue... ");
132 wrefresh(helpwin);
133 timeout(-1);
134 getch();
135 timeout(delay);
136 delwin(helpwin);
137 }
138 #endif
139