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 2008" "darkstat 3"
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, and upon receiving SIGUSR1, export the in-memory database
252 to the named file, relative to the chroot directory.
253 If you wish to use \fB\-\-export\fR, you must first specify a
254 \fB\-\-chroot\fR directory, and it must be writeable by the
256 A writeable chroot has security implications - if you are uncomfortable
257 with this, do not use the \fB\-\-export\fR functionality.
260 .BI \-\-pidfile " filename"
262 Creates a file containing the process ID of \fIdarkstat\fR.
263 This file will be unlinked upon clean shutdown.
264 As with all pidfiles, if \fIdarkstat\fR dies uncleanly, a stale pidfile
267 For example, start \fIdarkstat\fR with:
269 darkstat \-i fxp0 \-\-chroot /var/run/darkstat \-\-pidfile darkstat.pid
273 kill `cat /var/run/darkstat/darkstat.pid`
277 will send SIGTERM, which will cause \fIdarkstat\fR to shut down cleanly.
281 .BI \-\-hosts\-max " count"
282 The maximum number of hosts that will be kept in the hosts table.
283 This is used to limit how much accounting data will be kept in memory.
290 .BI \-\-hosts\-keep " count"
291 When the hosts table hits
293 and traffic is seen from a new host, we clean out the hosts table,
296 number of hosts, sorted by total traffic.
299 .BI \-\-ports\-max " count"
300 The maximum number of ports that will be tracked for each host.
301 This is used to limit how much accounting data will be kept in memory.
308 .BI \-\-ports\-keep " count"
309 When a ports table fills up, this many ports are kept and the rest are
313 .BI \-\-highest\-port " port"
314 Ports that are numerically higher than this will not appear in the
315 per-host ports tables, although their traffic will still be accounted
317 This can be used to hide ephemeral ports.
318 By default, all ports are tracked.
323 It's a hack to help victims of \fINetworkManager\fR and similar systems.
326 You should start \fIdarkstat\fR after the capture interface has come up.
327 If you can't, specifying the \fB\-\-wait\fR option will make \fIdarkstat\fR
328 sleep up to the specified number of seconds for the interface to become ready.
329 Zero means wait indefinitely.
334 Show hex dumps of received traffic.
335 This is only for debugging, and implies \fB\-\-verbose\fR and
336 \fB\-\-no\-daemon\fR.
338 .\" --------------------------------------------------------------------
340 To gather statistics on the
347 We want to account for traffic on the Internet-facing interface,
348 but only serve web pages to our private local network where we have the
349 IP address 192.168.0.1:
351 darkstat \-i fxp0 \-b 192.168.0.1
354 We want to serve web pages on the standard HTTP port:
356 darkstat \-i fxp0 \-p 80
359 We are on Optus (cable) and don't want to account for the constant ARP
360 traffic we are receiving:
362 darkstat \-i fxp0 \-f "not arp"
365 We only want to account for SSH traffic:
367 darkstat \-i fxp0 \-f "port 22"
370 We don't want to account for traffic between internal IPs:
372 darkstat \-i fxp0 \-f "not (src net 192.168.0 and dst net 192.168.0)"
375 (For a full reference on filter syntax, refer to the
380 We have a network consisting of a gateway server (192.168.1.1) and a few
381 workstations (192.168.1.2, 192.168.1.3, etc.) and we want to graph all
382 traffic entering and leaving the local network, not just the gateway
383 server (which is running \fIdarkstat\fR):
385 darkstat \-i fxp0 \-l 192.168.1.0/255.255.255.0
388 On some systems, we can't capture on a "decoded" interface but
389 only on \fInas0\fR which returns PPPoE encapsulated packets.
390 Do PPPoE decoding, and override the local IP manually since it
391 cannot be automatically detected.
392 Note the /32 netmask:
394 darkstat \-i nas0 \-\-pppoe \-l 192.168.1.1/255.255.255.255
399 down cleanly, send a SIGTERM or SIGINT signal to the
403 Sending the SIGUSR1 signal will cause \fIdarkstat\fR to empty out its
405 If an \fB\-\-export\fR file was set, it will first save the database to
409 .SH FREQUENTLY ASKED QUESTIONS
410 .SS How many bytes does each bar on the graph represent?
411 Hover your mouse cursor over a bar and you should get a tooltip
412 saying exactly how many bytes in and out the bar represents.
414 .SS Why aren't there labels / tics / a scale on the graphs?
415 Because implementing them is hard.
416 And doing so \fIcorrectly\fR, and in a way that works across all
417 browsers, looks pretty much impossible.
419 I might attempt it some day.
420 In the meantime, patches would be gladly accepted.
422 .SS Why are the graphs blank? All the bars are zero.
423 The graphs only show traffic in/out of the local host, which is
424 determined by getting the IP address of the interface you're sniffing
427 You can use the \fB\-l\fR argument to override the local address for
429 You can also use it to do accounting for a whole subnet by specifying
430 an appropriate netmask.
437 was written in 2001, largely as a result of a certain Australian
438 cable Internet provider introducing a 3GB monthly traffic limit.
441 Emil Mikulic and others. (see the AUTHORS file)
444 http://dmr.ath.cx/net/darkstat/