3 .\" Copyright 2001-2010, Emil Mikulic.
5 .\" You may use, modify and redistribute this file under the terms of the
6 .\" GNU General Public License version 2. (see COPYING.GPL)
8 .TH darkstat 8 "September 2010" "@PACKAGE_STRING@"
10 darkstat \- network statistics gatherer
19 .BI \-\-snaplen " bytes"
43 .BI \-l " network/netmask"
47 .BI \-\-user " username"
49 .BI \-\-daylog " filename"
51 .BI \-\-import " filename"
53 .BI \-\-export " filename"
55 .BI \-\-pidfile " filename"
57 .BI \-\-hosts\-max " count"
59 .BI \-\-hosts\-keep " count"
61 .BI \-\-ports\-max " count"
63 .BI \-\-ports\-keep " count"
65 .BI \-\-highest\-port " port"
74 is a packet sniffer that runs as a background process,
75 gathers all sorts of statistics about network usage,
76 and serves them over HTTP.
78 All settings are passed on the commandline.
84 Capture traffic on the specified network interface.
85 This is the only mandatory commandline argument.
89 Instead of capturing live traffic, read it from a
92 This is only useful for development and benchmarking.
97 arguments are mutually exclusive.
100 .BI \-\-snaplen " bytes"
101 How many bytes to capture from the start of each packet.
102 You should not need to specify this;
103 \fIdarkstat\fR will calculate it automatically.
109 Instead, capture on the tunnel interface that your PPPoE software
110 provides, for example \fBtun0\fR on \fIFreeBSD\fR, \fBpppoe0\fR on
111 \fIOpenBSD\fR or \fINetBSD\fR.
113 If you really must, you can capture on an Ethernet interface and pass
114 this argument to have \fIdarkstat\fR decode PPPoE frames and ignore
116 Make sure you also specify your local address with the \fB\-l\fR
121 Errors, warnings, and verbose messages will go to \fBsyslog\fR (facility
122 daemon, priority debug) instead of \fBstderr\fR.
124 On some systems, these messages end up in \fB/var/log/debug\fR
129 Produce more verbose debugging messages.
133 Do not detach from the controlling terminal;
134 stay in the foreground.
138 Do not use promiscuous mode to capture.
139 Note that an interface may already be in promiscuous mode, or may later
140 enter promiscuous mode, due to circumstances beyond \fIdarkstat\fR's control.
141 If this is a problem, use \fB\-f\fR to specify an appropriate
147 Do not resolve IPs to host names.
148 This can significantly reduce memory footprint on small systems
149 as an extra process is created for DNS resolution.
153 Do not display MAC addresses in the hosts table.
157 Do not display the last seen time in the hosts table.
161 Bind the web interface to the specified port.
166 Bind the web interface to the specified address.
167 The default is to listen on all interfaces.
171 Use the specified filter expression when capturing traffic.
172 The filter syntax is beyond the scope of this manual page;
178 .BI \-l " network/netmask"
179 Define a "local network" according to the network and netmask addresses.
180 All traffic entering or leaving this network will be graphed, as opposed
181 to the default behaviour of only graphing traffic to and from the local
185 The rule is that if \fBip_addr & netmask == network\fR,
186 then that address is considered local.
187 See the usage example below.
191 .BI \-\-chroot " dir"
192 Force \fIdarkstat\fR to \fBchroot()\fR into the specified directory.
193 Without this argument, a default directory will be used, which is
194 determined at build time.
195 Usually \fI/var/empty\fR or \fI/var/lib/empty\fR.
198 For security reasons, this directory should be empty, and the user that
199 \fIdarkstat\fR is running as should not have write access to it.
201 However, if you wish to use \fB\-\-daylog\fR or \fB\-\-export\fR,
202 \fIdarkstat\fR will need write access to the chroot.
203 If you are uncomfortable with the security implications, don't
204 use any functionality that requires write access.
208 .BI \-\-user " username"
209 Force \fIdarkstat\fR to drop privileges to the \fBuid\fR and \fBgid\fR of
211 Without this argument, a default value will be used, which is set at
213 Usually \fBnobody\fR.
216 For security reasons, this should not be \fBroot\fR.
220 .BI \-\-daylog " filename"
222 Log daily traffic statistics into the named file, relative to the
224 If you wish to use \fB\-\-daylog\fR, you must first specify a
225 \fB\-\-chroot\fR directory, and it must be writeable by the
227 A writeable chroot has security implications; if you are uncomfortable
228 with this, do not use the \fB\-\-daylog\fR functionality.
230 If the daylog argument is not specified, no logging is performed.
232 The daylog format is:
234 localtime|time_t|bytes_in|bytes_out|pkts_in|pkts_outs
236 Lines starting with a # are comments stating when logging started and
241 .BI \-\-import " filename"
242 Upon starting, import a \fIdarkstat\fR database from the named file,
243 relative to the chroot directory.
244 If you wish to use \fB\-\-import\fR, you must first specify a
245 \fB\-\-chroot\fR directory.
246 If the import is unsuccessful, \fIdarkstat\fR will start with an empty
250 .BI \-\-export " filename"
251 On shutdown, or upon receiving SIGUSR1 or SIGUSR2,
252 export the in-memory database
253 to the named file, relative to the chroot directory.
254 If you wish to use \fB\-\-export\fR, you must first specify a
255 \fB\-\-chroot\fR directory, and it must be writeable by the
257 A writeable chroot has security implications - if you are uncomfortable
258 with this, do not use the \fB\-\-export\fR functionality.
261 .BI \-\-pidfile " filename"
263 Creates a file containing the process ID of \fIdarkstat\fR.
264 This file will be unlinked upon clean shutdown.
265 As with all pidfiles, if \fIdarkstat\fR dies uncleanly, a stale pidfile
268 For example, start \fIdarkstat\fR with:
270 darkstat \-i fxp0 \-\-chroot /var/run/darkstat \-\-pidfile darkstat.pid
274 kill `cat /var/run/darkstat/darkstat.pid`
278 will send SIGTERM, which will cause \fIdarkstat\fR to shut down cleanly.
282 .BI \-\-hosts\-max " count"
283 The maximum number of hosts that will be kept in the hosts table.
284 This is used to limit how much accounting data will be kept in memory.
291 .BI \-\-hosts\-keep " count"
292 When the hosts table hits
294 and traffic is seen from a new host, we clean out the hosts table,
297 number of hosts, sorted by total traffic.
300 .BI \-\-ports\-max " count"
301 The maximum number of ports that will be tracked for each host.
302 This is used to limit how much accounting data will be kept in memory.
309 .BI \-\-ports\-keep " count"
310 When a ports table fills up, this many ports are kept and the rest are
314 .BI \-\-highest\-port " port"
315 Ports that are numerically higher than this will not appear in the
316 per-host ports tables, although their traffic will still be accounted
318 This can be used to hide ephemeral ports.
319 By default, all ports are tracked.
324 It's a hack to help victims of \fINetworkManager\fR and similar systems.
327 You should start \fIdarkstat\fR after the capture interface has come up.
328 If you can't, specifying the \fB\-\-wait\fR option will make \fIdarkstat\fR
329 sleep up to the specified number of seconds for the interface to become ready.
330 Zero means wait indefinitely.
335 Show hex dumps of received traffic.
336 This is only for debugging, and implies \fB\-\-verbose\fR and
337 \fB\-\-no\-daemon\fR.
339 .\" --------------------------------------------------------------------
341 To gather statistics on the
348 We want to account for traffic on the Internet-facing interface,
349 but only serve web pages to our private local network where we have the
350 IP address 192.168.0.1:
352 darkstat \-i fxp0 \-b 192.168.0.1
355 We want to serve web pages on the standard HTTP port:
357 darkstat \-i fxp0 \-p 80
360 We are on Optus (cable) and don't want to account for the constant ARP
361 traffic we are receiving:
363 darkstat \-i fxp0 \-f "not arp"
366 We only want to account for SSH traffic:
368 darkstat \-i fxp0 \-f "port 22"
371 We don't want to account for traffic between internal IPs:
373 darkstat \-i fxp0 \-f "not (src net 192.168.0 and dst net 192.168.0)"
376 (For a full reference on filter syntax, refer to the
381 We have a network consisting of a gateway server (192.168.1.1) and a few
382 workstations (192.168.1.2, 192.168.1.3, etc.) and we want to graph all
383 traffic entering and leaving the local network, not just the gateway
384 server (which is running \fIdarkstat\fR):
386 darkstat \-i fxp0 \-l 192.168.1.0/255.255.255.0
389 On some systems, we can't capture on a "decoded" interface but
390 only on \fInas0\fR which returns PPPoE encapsulated packets.
391 Do PPPoE decoding, and override the local IP manually since it
392 cannot be automatically detected.
393 Note the /32 netmask:
395 darkstat \-i nas0 \-\-pppoe \-l 192.168.1.1/255.255.255.255
400 down cleanly, send a SIGTERM or SIGINT signal to the
404 Sending the SIGUSR1 signal will cause \fIdarkstat\fR to empty out its
406 If an \fB\-\-export\fR file was set, it will first save the database to
408 Sending SIGUSR2 will save the database without emptying it.
411 .SH FREQUENTLY ASKED QUESTIONS
412 .SS How many bytes does each bar on the graph represent?
413 Hover your mouse cursor over a bar and you should get a tooltip
414 saying exactly how many bytes in and out the bar represents.
416 .SS Why aren't there labels / tics / a scale on the graphs?
417 Because implementing them is hard.
418 And doing so \fIcorrectly\fR, and in a way that works across all
419 browsers, looks pretty much impossible.
421 I might attempt it some day.
422 In the meantime, patches would be gladly accepted.
424 .SS Why are the graphs blank? All the bars are zero.
425 The graphs only show traffic in/out of the local host, which is
426 determined by getting the IP address of the interface you're sniffing
429 You can use the \fB\-l\fR argument to override the local address for
431 You can also use it to do accounting for a whole subnet by specifying
432 an appropriate netmask.
439 was written in 2001, largely as a result of a certain Australian
440 cable Internet provider introducing a 3GB monthly traffic limit.
443 Emil Mikulic and others. (see the AUTHORS file)