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"
45 .BI \-l " network/netmask"
49 .BI \-\-user " username"
51 .BI \-\-daylog " filename"
53 .BI \-\-import " filename"
55 .BI \-\-export " filename"
57 .BI \-\-pidfile " filename"
59 .BI \-\-hosts\-max " count"
61 .BI \-\-hosts\-keep " count"
63 .BI \-\-ports\-max " count"
65 .BI \-\-ports\-keep " count"
67 .BI \-\-highest\-port " port"
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.
80 All settings are passed on the commandline.
86 Capture traffic on the specified network interface.
87 This is the only mandatory commandline argument.
91 Instead of capturing live traffic, read it from a
94 This is only useful for development and benchmarking.
99 arguments are mutually exclusive.
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.
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.
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
118 Make sure you also specify your local address with the \fB\-l\fR
123 Errors, warnings, and verbose messages will go to \fBsyslog\fR (facility
124 daemon, priority debug) instead of \fBstderr\fR.
126 On some systems, these messages end up in \fB/var/log/debug\fR
131 Produce more verbose debugging messages.
135 Do not detach from the controlling terminal;
136 stay in the foreground.
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
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.
155 Do not display MAC addresses in the hosts table.
159 Do not display the last seen time in the hosts table.
163 Bind the web interface to the specified port.
168 Bind the web interface to the specified address.
169 The default is to listen on all interfaces.
174 Specify the path of the base URL.
175 This can be useful if \fIdarkstat\fR is accessed via a reverse proxy.
177 For example, if you use Apache's \fImod_proxy\fR and want to avoid a
178 complicated setup with \fImod_proxy_html\fR (and \fImod_header\fR to unset
179 the \fIAccept-Encoding\fR header), just set the base path to something like
180 \fIstats\fR and use a config similar to the following snippet:
183 ProxyPass /stats/ http://localhost:667/stats/
184 ProxyPassReverse /stats/ http://localhost:667/stats/
187 The default is \fI/\fR (ie. the root).
192 Use the specified filter expression when capturing traffic.
193 The filter syntax is beyond the scope of this manual page;
199 .BI \-l " network/netmask"
200 Define a "local network" according to the network and netmask addresses.
201 All traffic entering or leaving this network will be graphed, as opposed
202 to the default behaviour of only graphing traffic to and from the local
206 The rule is that if \fBip_addr & netmask == network\fR,
207 then that address is considered local.
208 See the usage example below.
212 .BI \-\-chroot " dir"
213 Force \fIdarkstat\fR to \fBchroot()\fR into the specified directory.
214 Without this argument, a default directory will be used, which is
215 determined at build time.
216 Usually \fI/var/empty\fR or \fI/var/lib/empty\fR.
219 For security reasons, this directory should be empty, and the user that
220 \fIdarkstat\fR is running as should not have write access to it.
222 However, if you wish to use \fB\-\-daylog\fR or \fB\-\-export\fR,
223 \fIdarkstat\fR will need write access to the chroot.
224 If you are uncomfortable with the security implications, don't
225 use any functionality that requires write access.
229 .BI \-\-user " username"
230 Force \fIdarkstat\fR to drop privileges to the \fBuid\fR and \fBgid\fR of
232 Without this argument, a default value will be used, which is set at
234 Usually \fBnobody\fR.
237 For security reasons, this should not be \fBroot\fR.
241 .BI \-\-daylog " filename"
243 Log daily traffic statistics into the named file, relative to the
245 If you wish to use \fB\-\-daylog\fR, you must first specify a
246 \fB\-\-chroot\fR directory, and it must be writeable by the
248 A writeable chroot has security implications; if you are uncomfortable
249 with this, do not use the \fB\-\-daylog\fR functionality.
251 If the daylog argument is not specified, no logging is performed.
253 The daylog format is:
255 localtime|time_t|bytes_in|bytes_out|pkts_in|pkts_outs
257 Lines starting with a # are comments stating when logging started and
262 .BI \-\-import " filename"
263 Upon starting, import a \fIdarkstat\fR database from the named file,
264 relative to the chroot directory.
265 If you wish to use \fB\-\-import\fR, you must first specify a
266 \fB\-\-chroot\fR directory.
267 If the import is unsuccessful, \fIdarkstat\fR will start with an empty
271 .BI \-\-export " filename"
272 On shutdown, or upon receiving SIGUSR1 or SIGUSR2,
273 export the in-memory database
274 to the named file, relative to the chroot directory.
275 If you wish to use \fB\-\-export\fR, you must first specify a
276 \fB\-\-chroot\fR directory, and it must be writeable by the
278 A writeable chroot has security implications - if you are uncomfortable
279 with this, do not use the \fB\-\-export\fR functionality.
282 .BI \-\-pidfile " filename"
284 Creates a file containing the process ID of \fIdarkstat\fR.
285 This file will be unlinked upon clean shutdown.
286 As with all pidfiles, if \fIdarkstat\fR dies uncleanly, a stale pidfile
289 For example, start \fIdarkstat\fR with:
291 darkstat \-i fxp0 \-\-chroot /var/run/darkstat \-\-pidfile darkstat.pid
295 kill `cat /var/run/darkstat/darkstat.pid`
299 will send SIGTERM, which will cause \fIdarkstat\fR to shut down cleanly.
303 .BI \-\-hosts\-max " count"
304 The maximum number of hosts that will be kept in the hosts table.
305 This is used to limit how much accounting data will be kept in memory.
312 .BI \-\-hosts\-keep " count"
313 When the hosts table hits
315 and traffic is seen from a new host, we clean out the hosts table,
318 number of hosts, sorted by total traffic.
321 .BI \-\-ports\-max " count"
322 The maximum number of ports that will be tracked for each host.
323 This is used to limit how much accounting data will be kept in memory.
330 .BI \-\-ports\-keep " count"
331 When a ports table fills up, this many ports are kept and the rest are
335 .BI \-\-highest\-port " port"
336 Ports that are numerically higher than this will not appear in the
337 per-host ports tables, although their traffic will still be accounted
339 This can be used to hide ephemeral ports.
340 By default, all ports are tracked.
345 It's a hack to help victims of \fINetworkManager\fR and similar systems.
348 You should start \fIdarkstat\fR after the capture interface has come up.
349 If you can't, specifying the \fB\-\-wait\fR option will make \fIdarkstat\fR
350 sleep up to the specified number of seconds for the interface to become ready.
351 Zero means wait indefinitely.
356 Show hex dumps of received traffic.
357 This is only for debugging, and implies \fB\-\-verbose\fR and
358 \fB\-\-no\-daemon\fR.
360 .\" --------------------------------------------------------------------
362 To gather statistics on the
369 We want to account for traffic on the Internet-facing interface,
370 but only serve web pages to our private local network where we have the
371 IP address 192.168.0.1:
373 darkstat \-i fxp0 \-b 192.168.0.1
376 We want to serve web pages on the standard HTTP port:
378 darkstat \-i fxp0 \-p 80
381 We are on Optus (cable) and don't want to account for the constant ARP
382 traffic we are receiving:
384 darkstat \-i fxp0 \-f "not arp"
387 We only want to account for SSH traffic:
389 darkstat \-i fxp0 \-f "port 22"
392 We don't want to account for traffic between internal IPs:
394 darkstat \-i fxp0 \-f "not (src net 192.168.0 and dst net 192.168.0)"
397 (For a full reference on filter syntax, refer to the
402 We have a network consisting of a gateway server (192.168.1.1) and a few
403 workstations (192.168.1.2, 192.168.1.3, etc.) and we want to graph all
404 traffic entering and leaving the local network, not just the gateway
405 server (which is running \fIdarkstat\fR):
407 darkstat \-i fxp0 \-l 192.168.1.0/255.255.255.0
410 On some systems, we can't capture on a "decoded" interface but
411 only on \fInas0\fR which returns PPPoE encapsulated packets.
412 Do PPPoE decoding, and override the local IP manually since it
413 cannot be automatically detected.
414 Note the /32 netmask:
416 darkstat \-i nas0 \-\-pppoe \-l 192.168.1.1/255.255.255.255
421 down cleanly, send a SIGTERM or SIGINT signal to the
425 Sending the SIGUSR1 signal will cause \fIdarkstat\fR to empty out its
427 If an \fB\-\-export\fR file was set, it will first save the database to
429 Sending SIGUSR2 will save the database without emptying it.
432 .SH FREQUENTLY ASKED QUESTIONS
433 .SS How many bytes does each bar on the graph represent?
434 Hover your mouse cursor over a bar and you should get a tooltip
435 saying exactly how many bytes in and out the bar represents.
437 .SS Why aren't there labels / tics / a scale on the graphs?
438 Because implementing them is hard.
439 And doing so \fIcorrectly\fR, and in a way that works across all
440 browsers, looks pretty much impossible.
442 I might attempt it some day.
443 In the meantime, patches would be gladly accepted.
445 .SS Why are the graphs blank? All the bars are zero.
446 The graphs only show traffic in/out of the local host, which is
447 determined by getting the IP address of the interface you're sniffing
450 You can use the \fB\-l\fR argument to override the local address for
452 You can also use it to do accounting for a whole subnet by specifying
453 an appropriate netmask.
460 was written in 2001, largely as a result of a certain Australian
461 cable Internet provider introducing a 3GB monthly traffic limit.
464 Emil Mikulic and others. (see the AUTHORS file)
467 http://dmr.ath.cx/net/darkstat/