3 .\" Copyright 2001-2011, 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 "June 2011" "@PACKAGE_STRING@"
10 darkstat \- network statistics gatherer
19 .BI \-\-snaplen " bytes"
43 .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.
173 Use the specified filter expression when capturing traffic.
174 The filter syntax is beyond the scope of this manual page;
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
187 The rule is that if \fBip_addr & netmask == network\fR,
188 then that address is considered local.
189 See the usage example below.
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.
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.
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.
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.
215 .BI \-\-user " username"
216 Force \fIdarkstat\fR to drop privileges to the \fBuid\fR and \fBgid\fR of
218 Without this argument, a default value will be used, which is set at
220 Usually \fBnobody\fR.
223 For security reasons, this should not be \fBroot\fR.
227 .BI \-\-daylog " filename"
229 Log daily traffic statistics into the named file, relative to the
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
234 A writeable chroot has security implications; if you are uncomfortable
235 with this, do not use the \fB\-\-daylog\fR functionality.
237 If the daylog argument is not specified, no logging is performed.
239 The daylog format is:
241 localtime|time_t|bytes_in|bytes_out|pkts_in|pkts_outs
243 Lines starting with a # are comments stating when logging started and
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
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
264 A writeable chroot has security implications - if you are uncomfortable
265 with this, do not use the \fB\-\-export\fR functionality.
268 .BI \-\-pidfile " filename"
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
275 For example, start \fIdarkstat\fR with:
277 darkstat \-i fxp0 \-\-chroot /var/run/darkstat \-\-pidfile darkstat.pid
281 kill `cat /var/run/darkstat/darkstat.pid`
285 will send SIGTERM, which will cause \fIdarkstat\fR to shut down cleanly.
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.
298 .BI \-\-hosts\-keep " count"
299 When the hosts table hits
301 and traffic is seen from a new host, we clean out the hosts table,
304 number of hosts, sorted by total traffic.
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.
316 .BI \-\-ports\-keep " count"
317 When a ports table fills up, this many ports are kept and the rest are
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
325 This can be used to hide ephemeral ports.
326 By default, all ports are tracked.
331 It's a hack to help victims of \fINetworkManager\fR and similar systems.
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.
342 Show hex dumps of received traffic.
343 This is only for debugging, and implies \fB\-\-verbose\fR and
344 \fB\-\-no\-daemon\fR.
346 .\" --------------------------------------------------------------------
348 To gather statistics on the
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:
359 darkstat \-i fxp0 \-b 192.168.0.1
362 We want to serve web pages on the standard HTTP port:
364 darkstat \-i fxp0 \-p 80
367 We are on Optus (cable) and don't want to account for the constant ARP
368 traffic we are receiving:
370 darkstat \-i fxp0 \-f "not arp"
373 We only want to account for SSH traffic:
375 darkstat \-i fxp0 \-f "port 22"
378 We don't want to account for traffic between internal IPs:
380 darkstat \-i fxp0 \-f "not (src net 192.168.0 and dst net 192.168.0)"
383 (For a full reference on filter syntax, refer to the
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):
393 darkstat \-i fxp0 \-l 192.168.1.0/255.255.255.0
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:
402 darkstat \-i nas0 \-\-pppoe \-l 192.168.1.1/255.255.255.255
407 down cleanly, send a SIGTERM or SIGINT signal to the
411 Sending the SIGUSR1 signal will cause \fIdarkstat\fR to empty out its
413 If an \fB\-\-export\fR file was set, it will first save the database to
415 Sending SIGUSR2 will save the database without emptying it.
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.
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.
428 I might attempt it some day.
429 In the meantime, patches would be gladly accepted.
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
436 You can use the \fB\-l\fR argument to override the local address for
438 You can also use it to do accounting for a whole subnet by specifying
439 an appropriate netmask.
446 was written in 2001, largely as a result of a certain Australian
447 cable Internet provider introducing a 3GB monthly traffic limit.
450 Emil Mikulic and others. (see the AUTHORS file)