File: darkstat.8.in

package info (click to toggle)
darkstat 3.0.718-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 888 kB
  • ctags: 810
  • sloc: ansic: 6,863; sh: 530; makefile: 177; php: 15
file content (474 lines) | stat: -rw-r--r-- 12,339 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
.\"
.\" darkstat 3
.\" Copyright 2001-2014, Emil Mikulic.
.\"
.\" You may use, modify and redistribute this file under the terms of the
.\" GNU General Public License version 2. (see COPYING.GPL)
.\"
.TH darkstat 8 "June 2011" "@PACKAGE_STRING@"
.SH NAME
darkstat \- network statistics gatherer
.\"
.SH SYNOPSIS
.B darkstat
[
.BI \-i " interface"
] [
.BI \-r " file"
] [
.BI \-\-snaplen " bytes"
] [
.BI \-\-pppoe
] [
.BI \-\-syslog
] [
.BI \-\-verbose
] [
.BI \-\-no\-daemon
] [
.BI \-\-no\-promisc
] [
.BI \-\-no\-dns
] [
.BI \-\-no\-macs
] [
.BI \-\-no\-lastseen
] [
.BI \-p " port"
] [
.BI \-b " bindaddr"
] [
.BI \-\-base " path"
] [
.BI \-f " filter"
] [
.BI \-l " network/netmask"
] [
.BI \-\-local\-only
] [
.BI \-\-chroot " dir"
] [
.BI \-\-user " username"
] [
.BI \-\-daylog " filename"
] [
.BI \-\-import " filename"
] [
.BI \-\-export " filename"
] [
.BI \-\-pidfile " filename"
] [
.BI \-\-hosts\-max " count"
] [
.BI \-\-hosts\-keep " count"
] [
.BI \-\-ports\-max " count"
] [
.BI \-\-ports\-keep " count"
] [
.BI \-\-highest\-port " port"
] [
.BI \-\-wait " secs"
] [
.BI \-\-hexdump
]
.\"
.SH DESCRIPTION
.I darkstat
is a packet sniffer that runs as a background process,
gathers all sorts of statistics about network usage,
and serves them over HTTP.

All settings are passed on the commandline.
.\"
.SH OPTIONS
.\"
.TP
.BI \-i " interface"
Capture traffic on the specified network interface.
This is the only mandatory commandline argument.
.\"
.TP
.BI \-r " file"
Instead of capturing live traffic, read it from a
.BR pcap (3)
capture file.
This is only useful for development and benchmarking.
The
.BI \-r
and
.BI \-i
arguments are mutually exclusive.
.\"
.TP
.BI \-\-snaplen " bytes"
How many bytes to capture from the start of each packet.
You should not need to specify this;
\fIdarkstat\fR will calculate it automatically.
.\"
.TP
.BI \-\-pppoe
Don't use this.

Instead, capture on the tunnel interface that your PPPoE software
provides, for example \fBtun0\fR on \fIFreeBSD\fR, \fBpppoe0\fR on
\fIOpenBSD\fR or \fINetBSD\fR.

If you really must, you can capture on an Ethernet interface and pass
this argument to have \fIdarkstat\fR decode PPPoE frames and ignore
everything else.
Make sure you also specify your local address with the \fB\-l\fR
argument!
.\"
.TP
.BI \-\-syslog
Errors, warnings, and verbose messages will go to \fBsyslog\fR (facility
daemon, priority debug) instead of \fBstderr\fR.

On some systems, these messages end up in \fB/var/log/debug\fR
by default.
.\"
.TP
.BI \-\-verbose
Produce more verbose debugging messages.
.\"
.TP
.BI \-\-no\-daemon
Do not detach from the controlling terminal;
stay in the foreground.
.\"
.TP
.BI \-\-no\-promisc
Do not use promiscuous mode to capture.
Note that an interface may already be in promiscuous mode, or may later
enter promiscuous mode, due to circumstances beyond \fIdarkstat\fR's control.
If this is a problem, use \fB\-f\fR to specify an appropriate
.BR bpf (4)
filter.
.\"
.TP
.BI \-\-no\-dns
Do not resolve IPs to host names.
This can significantly reduce memory footprint on small systems
as an extra process is created for DNS resolution.
.\"
.TP
.BI \-\-no\-macs
Do not display MAC addresses in the hosts table.
.\"
.TP
.BI \-\-no\-lastseen
Do not display the last seen time in the hosts table.
.\"
.TP
.BI \-p " port"
Bind the web interface to the specified port.
The default is 667.
.\"
.TP
.BI \-b " bindaddr"
Bind the web interface to the specified address.
The default is to listen on all interfaces.
.\"
.TP
.BI \-\-base " path"
.RS
Specify the path of the base URL.
This can be useful if \fIdarkstat\fR is accessed via a reverse proxy.

For example, if you use Apache's \fImod_proxy\fR and want to avoid a
complicated setup with \fImod_proxy_html\fR (and \fImod_header\fR to unset
the \fIAccept-Encoding\fR header), just set the base path to something like
\fIstats\fR and use a config similar to the following snippet:

.IP
 ProxyPass /stats/ http://localhost:667/stats/
 ProxyPassReverse /stats/ http://localhost:667/stats/
.PP

The default is \fI/\fR (i.e. the root).
.RE
.\"
.TP
.BI \-f " filter"
Use the specified filter expression when capturing traffic.
The filter syntax is beyond the scope of this manual page;
please refer to the
.BR tcpdump (8)
documentation.
.\"
.TP
.BI \-l " network/netmask"
Define a "local network" according to the network and netmask addresses.
All traffic entering or leaving this network will be graphed, as opposed
to the default behaviour of only graphing traffic to and from the local
host.
.RS

The rule is that if \fBip_addr & netmask == network\fR,
then that address is considered local.
See the usage example below.
.RE
.\"
.TP
.BI \-\-local\-only
Make the web interface only display hosts on the "local network."
This is intended to be used together with the \fB\-l\fR argument.
.\"
.TP
.BI \-\-chroot " dir"
Force \fIdarkstat\fR to \fBchroot()\fR into the specified directory.
Without this argument, a default directory will be used, which is
determined at build time.
Usually \fI/var/empty\fR or \fI/var/lib/empty\fR.
.RS

For security reasons, this directory should be empty, and the user that
\fIdarkstat\fR is running as should not have write access to it.

However, if you wish to use \fB\-\-daylog\fR or \fB\-\-export\fR,
\fIdarkstat\fR will need write access to the chroot.
If you are uncomfortable with the security implications, don't
use any functionality that requires write access.
.RE
.\"
.TP
.BI \-\-user " username"
Force \fIdarkstat\fR to drop privileges to the \fBuid\fR and \fBgid\fR of
the specified user.
Without this argument, a default value will be used, which is set at
build time.
Usually \fBnobody\fR.
.RS

For security reasons, this should not be \fBroot\fR.
.RE
.\"
.TP
.BI \-\-daylog " filename"
.RS
Log daily traffic statistics into the named file, relative to the
chroot directory.
If you wish to use \fB\-\-daylog\fR, you must first specify a
\fB\-\-chroot\fR directory, and it must be writeable by the
\fIdarkstat\fR user.
A writeable chroot has security implications; if you are uncomfortable
with this, do not use the \fB\-\-daylog\fR functionality.

If the daylog argument is not specified, no logging is performed.

The daylog format is:

localtime|time_t|bytes_in|bytes_out|pkts_in|pkts_outs

Lines starting with a # are comments stating when logging started and
stopped.
.RE
.\"
.TP
.BI \-\-import " filename"
Upon starting, import a \fIdarkstat\fR database from the named file,
relative to the chroot directory.
If you wish to use \fB\-\-import\fR, you must first specify a
\fB\-\-chroot\fR directory.
If the import is unsuccessful, \fIdarkstat\fR will start with an empty
database.
.\"
.TP
.BI \-\-export " filename"
On shutdown, or upon receiving SIGUSR1 or SIGUSR2,
export the in-memory database
to the named file, relative to the chroot directory.
If you wish to use \fB\-\-export\fR, you must first specify a
\fB\-\-chroot\fR directory, and it must be writeable by the
\fIdarkstat\fR user.
A writeable chroot has security implications - if you are uncomfortable
with this, do not use the \fB\-\-export\fR functionality.
.\"
.TP
.BI \-\-pidfile " filename"
.RS
Creates a file containing the process ID of \fIdarkstat\fR.
This file will be unlinked upon clean shutdown.
As with all pidfiles, if \fIdarkstat\fR dies uncleanly, a stale pidfile
can be left over.

For example, start \fIdarkstat\fR with:
.IP
darkstat \-i fxp0 \-\-chroot /var/run/darkstat \-\-pidfile darkstat.pid
.PP
And stop with:
.IP
kill `cat /var/run/darkstat/darkstat.pid`
.PP
By default,
.BR kill (1)
will send SIGTERM, which will cause \fIdarkstat\fR to shut down cleanly.
.RE
.\"
.TP
.BI \-\-hosts\-max " count"
The maximum number of hosts that will be kept in the hosts table.
This is used to limit how much accounting data will be kept in memory.
The number of
.BI \-\-hosts\-max
must be greater than
.BI \-\-hosts\-keep
.\"
.TP
.BI \-\-hosts\-keep " count"
When the hosts table hits
.BI \-\-hosts\-max
and traffic is seen from a new host, we clean out the hosts table,
keeping only the top
.BI \-\-hosts\-keep
number of hosts, sorted by total traffic.
.\"
.TP
.BI \-\-ports\-max " count"
The maximum number of ports that will be tracked for each host.
This is used to limit how much accounting data will be kept in memory.
The number of
.BI \-\-ports\-max
must be greater than
.BI \-\-ports\-keep
.\"
.TP
.BI \-\-ports\-keep " count"
When a ports table fills up, this many ports are kept and the rest are
discarded.
.\"
.TP
.BI \-\-highest\-port " port"
Ports that are numerically higher than this will not appear in the
per-host ports tables, although their traffic will still be accounted
for.
This can be used to hide ephemeral ports.
By default, all ports are tracked.
.\"
.TP
.BI \-\-wait " secs"
Don't use this.
It's a hack to help victims of \fINetworkManager\fR and similar systems.
.RS

You should start \fIdarkstat\fR after the capture interface has come up.
If you can't, specifying the \fB\-\-wait\fR option will make \fIdarkstat\fR
sleep up to the specified number of seconds for the interface to become ready.
Zero means wait indefinitely.
.RE
.\"
.TP
.BI \-\-hexdump
Show hex dumps of received traffic.
This is only for debugging, and implies \fB\-\-verbose\fR and
\fB\-\-no\-daemon\fR.
.\"
.\" --------------------------------------------------------------------
.SH USAGE EXAMPLES
To gather statistics on the
.I fxp0
interface:
.IP
darkstat \-i fxp0
.PP
.\"
We want to account for traffic on the Internet-facing interface,
but only serve web pages to our private local network where we have the
IP address 192.168.0.1:
.IP
darkstat \-i fxp0 \-b 192.168.0.1
.PP
.\"
We want to serve web pages on the standard HTTP port:
.IP
darkstat \-i fxp0 \-p 80
.PP
.\"
We are on Optus (cable) and don't want to account for the constant ARP
traffic we are receiving:
.IP
darkstat \-i fxp0 \-f "not arp"
.PP
.\"
We only want to account for SSH traffic:
.IP
darkstat \-i fxp0 \-f "port 22"
.PP
.\"
We don't want to account for traffic between internal IPs:
.IP
darkstat \-i fxp0 \-f "not (src net 192.168.0 and dst net 192.168.0)"
.PP
.\"
(For a full reference on filter syntax, refer to the
.BR tcpdump (8)
manpage)
.PP
.\"
We have a network consisting of a gateway server (192.168.1.1) and a few
workstations (192.168.1.2, 192.168.1.3, etc.) and we want to graph all
traffic entering and leaving the local network, not just the gateway
server (which is running \fIdarkstat\fR):
.IP
darkstat \-i fxp0 \-l 192.168.1.0/255.255.255.0
.PP
.\"
On some systems, we can't capture on a "decoded" interface but
only on \fInas0\fR which returns PPPoE encapsulated packets.
Do PPPoE decoding, and override the local IP manually since it
cannot be automatically detected.
Note the /32 netmask:
.IP
darkstat \-i nas0 \-\-pppoe \-l 192.168.1.1/255.255.255.255
.\"
.SH SIGNALS
To shut
.I darkstat
down cleanly, send a SIGTERM or SIGINT signal to the
.I darkstat
parent process.
.PP
Sending the SIGUSR1 signal will cause \fIdarkstat\fR to empty out its
in-memory database.
If an \fB\-\-export\fR file was set, it will first save the database to
file.
Sending SIGUSR2 will save the database without emptying it.
.PP
.\"
.SH FREQUENTLY ASKED QUESTIONS
.SS How many bytes does each bar on the graph represent?
Hover your mouse cursor over a bar and you should get a tooltip
saying exactly how many bytes in and out the bar represents.
.\"
.SS Why aren't there labels / tics / a scale on the graphs?
Because implementing them is hard.
And doing so \fIcorrectly\fR, and in a way that works across all
browsers, looks pretty much impossible.

I might attempt it some day.
In the meantime, patches would be gladly accepted.
.\"
.SS Why are the graphs blank?  All the bars are zero.
The graphs only show traffic in/out of the local host, which is
determined by getting the IP address of the interface you're sniffing
on.

You can use the \fB\-l\fR argument to override the local address for
accounting purposes.
You can also use it to do accounting for a whole subnet by specifying
an appropriate netmask.
.\"
.SH SEE ALSO
.BR tcpdump (8)
.\"
.SH HISTORY
.I darkstat
was written in 2001, largely as a result of a certain Australian
cable Internet provider introducing a 3GB monthly traffic limit.
.\"
.SH AUTHORS
Emil Mikulic and others. (see the AUTHORS file)
.\"
.SH WEBSITE
@PACKAGE_URL@