Imported Upstream version 3.0.715
[darkstat-debian] / darkstat.8.in
1 .\"
2 .\" darkstat 3
3 .\" Copyright 2001-2011, Emil Mikulic.
4 .\"
5 .\" You may use, modify and redistribute this file under the terms of the
6 .\" GNU General Public License version 2. (see COPYING.GPL)
7 .\"
8 .TH darkstat 8 "June 2011" "@PACKAGE_STRING@"
9 .SH NAME
10 darkstat \- network statistics gatherer
11 .\"
12 .SH SYNOPSIS
13 .B darkstat
14 [
15 .BI \-i " interface"
16 ] [
17 .BI \-r " file"
18 ] [
19 .BI \-\-snaplen " bytes"
20 ] [
21 .BI \-\-pppoe
22 ] [
23 .BI \-\-syslog
24 ] [
25 .BI \-\-verbose
26 ] [
27 .BI \-\-no\-daemon
28 ] [
29 .BI \-\-no\-promisc
30 ] [
31 .BI \-\-no\-dns
32 ] [
33 .BI \-\-no\-macs
34 ] [
35 .BI \-\-no\-lastseen
36 ] [
37 .BI \-p " port"
38 ] [
39 .BI \-b " bindaddr"
40 ] [
41 .BI \-f " filter"
42 ] [
43 .BI \-l " network/netmask"
44 ] [
45 .BI \-\-local\-only
46 ] [
47 .BI \-\-chroot " dir"
48 ] [
49 .BI \-\-user " username"
50 ] [
51 .BI \-\-daylog " filename"
52 ] [
53 .BI \-\-import " filename"
54 ] [
55 .BI \-\-export " filename"
56 ] [
57 .BI \-\-pidfile " filename"
58 ] [
59 .BI \-\-hosts\-max " count"
60 ] [
61 .BI \-\-hosts\-keep " count"
62 ] [
63 .BI \-\-ports\-max " count"
64 ] [
65 .BI \-\-ports\-keep " count"
66 ] [
67 .BI \-\-highest\-port " port"
68 ] [
69 .BI \-\-wait " secs"
70 ] [
71 .BI \-\-hexdump
72 ]
73 .\"
74 .SH DESCRIPTION
75 .I darkstat
76 is a packet sniffer that runs as a background process,
77 gathers all sorts of statistics about network usage,
78 and serves them over HTTP.
79
80 All settings are passed on the commandline.
81 .\"
82 .SH OPTIONS
83 .\"
84 .TP
85 .BI \-i " interface"
86 Capture traffic on the specified network interface.
87 This is the only mandatory commandline argument.
88 .\"
89 .TP
90 .BI \-r " file"
91 Instead of capturing live traffic, read it from a
92 .BR pcap (3)
93 capture file.
94 This is only useful for development and benchmarking.
95 The
96 .BI \-r
97 and
98 .BI \-i
99 arguments are mutually exclusive.
100 .\"
101 .TP
102 .BI \-\-snaplen " bytes"
103 How many bytes to capture from the start of each packet.
104 You should not need to specify this;
105 \fIdarkstat\fR will calculate it automatically.
106 .\"
107 .TP
108 .BI \-\-pppoe
109 Don't use this.
110
111 Instead, capture on the tunnel interface that your PPPoE software
112 provides, for example \fBtun0\fR on \fIFreeBSD\fR, \fBpppoe0\fR on
113 \fIOpenBSD\fR or \fINetBSD\fR.
114
115 If you really must, you can capture on an Ethernet interface and pass
116 this argument to have \fIdarkstat\fR decode PPPoE frames and ignore
117 everything else.
118 Make sure you also specify your local address with the \fB\-l\fR
119 argument!
120 .\"
121 .TP
122 .BI \-\-syslog
123 Errors, warnings, and verbose messages will go to \fBsyslog\fR (facility
124 daemon, priority debug) instead of \fBstderr\fR.
125
126 On some systems, these messages end up in \fB/var/log/debug\fR
127 by default.
128 .\"
129 .TP
130 .BI \-\-verbose
131 Produce more verbose debugging messages.
132 .\"
133 .TP
134 .BI \-\-no\-daemon
135 Do not detach from the controlling terminal;
136 stay in the foreground.
137 .\"
138 .TP
139 .BI \-\-no\-promisc
140 Do not use promiscuous mode to capture.
141 Note that an interface may already be in promiscuous mode, or may later
142 enter promiscuous mode, due to circumstances beyond \fIdarkstat\fR's control.
143 If this is a problem, use \fB\-f\fR to specify an appropriate
144 .BR bpf (4)
145 filter.
146 .\"
147 .TP
148 .BI \-\-no\-dns
149 Do not resolve IPs to host names.
150 This can significantly reduce memory footprint on small systems
151 as an extra process is created for DNS resolution.
152 .\"
153 .TP
154 .BI \-\-no\-macs
155 Do not display MAC addresses in the hosts table.
156 .\"
157 .TP
158 .BI \-\-no\-lastseen
159 Do not display the last seen time in the hosts table.
160 .\"
161 .TP
162 .BI \-p " port"
163 Bind the web interface to the specified port.
164 The default is 667.
165 .\"
166 .TP
167 .BI \-b " bindaddr"
168 Bind the web interface to the specified address.
169 The default is to listen on all interfaces.
170 .\"
171 .TP
172 .BI \-f " filter"
173 Use the specified filter expression when capturing traffic.
174 The filter syntax is beyond the scope of this manual page;
175 please refer to the
176 .BR tcpdump (1)
177 documentation.
178 .\"
179 .TP
180 .BI \-l " network/netmask"
181 Define a "local network" according to the network and netmask addresses.
182 All traffic entering or leaving this network will be graphed, as opposed
183 to the default behaviour of only graphing traffic to and from the local
184 host.
185 .RS
186
187 The rule is that if \fBip_addr & netmask == network\fR,
188 then that address is considered local.
189 See the usage example below.
190 .RE
191 .\"
192 .TP
193 .BI \-\-local\-only
194 Make the web interface only display hosts on the "local network."
195 This is intended to be used together with the \fB\-l\fR argument.
196 .\"
197 .TP
198 .BI \-\-chroot " dir"
199 Force \fIdarkstat\fR to \fBchroot()\fR into the specified directory.
200 Without this argument, a default directory will be used, which is
201 determined at build time.
202 Usually \fI/var/empty\fR or \fI/var/lib/empty\fR.
203 .RS
204
205 For security reasons, this directory should be empty, and the user that
206 \fIdarkstat\fR is running as should not have write access to it.
207
208 However, if you wish to use \fB\-\-daylog\fR or \fB\-\-export\fR,
209 \fIdarkstat\fR will need write access to the chroot.
210 If you are uncomfortable with the security implications, don't
211 use any functionality that requires write access.
212 .RE
213 .\"
214 .TP
215 .BI \-\-user " username"
216 Force \fIdarkstat\fR to drop privileges to the \fBuid\fR and \fBgid\fR of
217 the specified user.
218 Without this argument, a default value will be used, which is set at
219 build time.
220 Usually \fBnobody\fR.
221 .RS
222
223 For security reasons, this should not be \fBroot\fR.
224 .RE
225 .\"
226 .TP
227 .BI \-\-daylog " filename"
228 .RS
229 Log daily traffic statistics into the named file, relative to the
230 chroot directory.
231 If you wish to use \fB\-\-daylog\fR, you must first specify a
232 \fB\-\-chroot\fR directory, and it must be writeable by the
233 \fIdarkstat\fR user.
234 A writeable chroot has security implications; if you are uncomfortable
235 with this, do not use the \fB\-\-daylog\fR functionality.
236
237 If the daylog argument is not specified, no logging is performed.
238
239 The daylog format is:
240
241 localtime|time_t|bytes_in|bytes_out|pkts_in|pkts_outs
242
243 Lines starting with a # are comments stating when logging started and
244 stopped.
245 .RE
246 .\"
247 .TP
248 .BI \-\-import " filename"
249 Upon starting, import a \fIdarkstat\fR database from the named file,
250 relative to the chroot directory.
251 If you wish to use \fB\-\-import\fR, you must first specify a
252 \fB\-\-chroot\fR directory.
253 If the import is unsuccessful, \fIdarkstat\fR will start with an empty
254 database.
255 .\"
256 .TP
257 .BI \-\-export " filename"
258 On shutdown, or upon receiving SIGUSR1 or SIGUSR2,
259 export the in-memory database
260 to the named file, relative to the chroot directory.
261 If you wish to use \fB\-\-export\fR, you must first specify a
262 \fB\-\-chroot\fR directory, and it must be writeable by the
263 \fIdarkstat\fR user.
264 A writeable chroot has security implications - if you are uncomfortable
265 with this, do not use the \fB\-\-export\fR functionality.
266 .\"
267 .TP
268 .BI \-\-pidfile " filename"
269 .RS
270 Creates a file containing the process ID of \fIdarkstat\fR.
271 This file will be unlinked upon clean shutdown.
272 As with all pidfiles, if \fIdarkstat\fR dies uncleanly, a stale pidfile
273 can be left over.
274
275 For example, start \fIdarkstat\fR with:
276 .IP
277 darkstat \-i fxp0 \-\-chroot /var/run/darkstat \-\-pidfile darkstat.pid
278 .PP
279 And stop with:
280 .IP
281 kill `cat /var/run/darkstat/darkstat.pid`
282 .PP
283 By default,
284 .BR kill (1)
285 will send SIGTERM, which will cause \fIdarkstat\fR to shut down cleanly.
286 .RE
287 .\"
288 .TP
289 .BI \-\-hosts\-max " count"
290 The maximum number of hosts that will be kept in the hosts table.
291 This is used to limit how much accounting data will be kept in memory.
292 The number of
293 .BI \-\-hosts\-max
294 must be greater than
295 .BI \-\-hosts\-keep
296 .\"
297 .TP
298 .BI \-\-hosts\-keep " count"
299 When the hosts table hits
300 .BI \-\-hosts\-max
301 and traffic is seen from a new host, we clean out the hosts table,
302 keeping only the top
303 .BI \-\-hosts\-keep
304 number of hosts, sorted by total traffic.
305 .\"
306 .TP
307 .BI \-\-ports\-max " count"
308 The maximum number of ports that will be tracked for each host.
309 This is used to limit how much accounting data will be kept in memory.
310 The number of
311 .BI \-\-ports\-max
312 must be greater than
313 .BI \-\-ports\-keep
314 .\"
315 .TP
316 .BI \-\-ports\-keep " count"
317 When a ports table fills up, this many ports are kept and the rest are
318 discarded.
319 .\"
320 .TP
321 .BI \-\-highest\-port " port"
322 Ports that are numerically higher than this will not appear in the
323 per-host ports tables, although their traffic will still be accounted
324 for.
325 This can be used to hide ephemeral ports.
326 By default, all ports are tracked.
327 .\"
328 .TP
329 .BI \-\-wait " secs"
330 Don't use this.
331 It's a hack to help victims of \fINetworkManager\fR and similar systems.
332 .RS
333
334 You should start \fIdarkstat\fR after the capture interface has come up.
335 If you can't, specifying the \fB\-\-wait\fR option will make \fIdarkstat\fR
336 sleep up to the specified number of seconds for the interface to become ready.
337 Zero means wait indefinitely.
338 .RE
339 .\"
340 .TP
341 .BI \-\-hexdump
342 Show hex dumps of received traffic.
343 This is only for debugging, and implies \fB\-\-verbose\fR and
344 \fB\-\-no\-daemon\fR.
345 .\"
346 .\" --------------------------------------------------------------------
347 .SH USAGE EXAMPLES
348 To gather statistics on the
349 .I fxp0
350 interface:
351 .IP
352 darkstat \-i fxp0
353 .PP
354 .\"
355 We want to account for traffic on the Internet-facing interface,
356 but only serve web pages to our private local network where we have the
357 IP address 192.168.0.1:
358 .IP
359 darkstat \-i fxp0 \-b 192.168.0.1
360 .PP
361 .\"
362 We want to serve web pages on the standard HTTP port:
363 .IP
364 darkstat \-i fxp0 \-p 80
365 .PP
366 .\"
367 We are on Optus (cable) and don't want to account for the constant ARP
368 traffic we are receiving:
369 .IP
370 darkstat \-i fxp0 \-f "not arp"
371 .PP
372 .\"
373 We only want to account for SSH traffic:
374 .IP
375 darkstat \-i fxp0 \-f "port 22"
376 .PP
377 .\"
378 We don't want to account for traffic between internal IPs:
379 .IP
380 darkstat \-i fxp0 \-f "not (src net 192.168.0 and dst net 192.168.0)"
381 .PP
382 .\"
383 (For a full reference on filter syntax, refer to the
384 .BR tcpdump (1)
385 manpage)
386 .PP
387 .\"
388 We have a network consisting of a gateway server (192.168.1.1) and a few
389 workstations (192.168.1.2, 192.168.1.3, etc.) and we want to graph all
390 traffic entering and leaving the local network, not just the gateway
391 server (which is running \fIdarkstat\fR):
392 .IP
393 darkstat \-i fxp0 \-l 192.168.1.0/255.255.255.0
394 .PP
395 .\"
396 On some systems, we can't capture on a "decoded" interface but
397 only on \fInas0\fR which returns PPPoE encapsulated packets.
398 Do PPPoE decoding, and override the local IP manually since it
399 cannot be automatically detected.
400 Note the /32 netmask:
401 .IP
402 darkstat \-i nas0 \-\-pppoe \-l 192.168.1.1/255.255.255.255
403 .\"
404 .SH SIGNALS
405 To shut
406 .I darkstat
407 down cleanly, send a SIGTERM or SIGINT signal to the
408 .I darkstat
409 parent process.
410 .PP
411 Sending the SIGUSR1 signal will cause \fIdarkstat\fR to empty out its
412 in-memory database.
413 If an \fB\-\-export\fR file was set, it will first save the database to
414 file.
415 Sending SIGUSR2 will save the database without emptying it.
416 .PP
417 .\"
418 .SH FREQUENTLY ASKED QUESTIONS
419 .SS How many bytes does each bar on the graph represent?
420 Hover your mouse cursor over a bar and you should get a tooltip
421 saying exactly how many bytes in and out the bar represents.
422 .\"
423 .SS Why aren't there labels / tics / a scale on the graphs?
424 Because implementing them is hard.
425 And doing so \fIcorrectly\fR, and in a way that works across all
426 browsers, looks pretty much impossible.
427
428 I might attempt it some day.
429 In the meantime, patches would be gladly accepted.
430 .\"
431 .SS Why are the graphs blank?  All the bars are zero.
432 The graphs only show traffic in/out of the local host, which is
433 determined by getting the IP address of the interface you're sniffing
434 on.
435
436 You can use the \fB\-l\fR argument to override the local address for
437 accounting purposes.
438 You can also use it to do accounting for a whole subnet by specifying
439 an appropriate netmask.
440 .\"
441 .SH SEE ALSO
442 .BR tcpdump (1)
443 .\"
444 .SH HISTORY
445 .I darkstat
446 was written in 2001, largely as a result of a certain Australian
447 cable Internet provider introducing a 3GB monthly traffic limit.
448 .\"
449 .SH AUTHORS
450 Emil Mikulic and others. (see the AUTHORS file)
451 .\"
452 .SH WEBSITE
453 @PACKAGE_URL@