3 .\" Copyright 2001-2009, 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"
72 is a packet sniffer that runs as a background process on
73 a cable/DSL router, gathers all sorts of statistics about network usage,
74 and serves them over HTTP.
76 All settings are passed on the commandline.
82 Capture traffic on the specified network interface.
83 This is the only mandatory commandline argument.
87 Instead of capturing live traffic, read it from a
90 This is only useful for development and benchmarking.
95 arguments are mutually exclusive.
98 .BI \-\-snaplen " bytes"
99 How many bytes to capture of the start of each packet.
100 You should not need to specify this;
101 \fIdarkstat\fR will calculate it automatically.
108 Instead, capture on the tunnel interface that your PPPoE software
109 provides, for example \fBtun0\fR on \fIFreeBSD\fR, \fBpppoe0\fR on
110 \fIOpenBSD\fR or \fINetBSD\fR.
112 If you really must, you can capture on an Ethernet interface and pass
113 this argument to have \fIdarkstat\fR decode PPPoE frames and ignore
115 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 or
125 \fBdebug.log\fR by default.
129 Output 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.
140 If this is a problem, use an appropriate
146 Do not resolve IPs to host names.
147 This can significantly reduce memory footprint on small systems
148 as an extra process is created for DNS resolving.
152 Do not display MAC addresses in the hosts table.
156 Do not display the last seen time in the hosts table.
160 Bind the web interface to the specified port.
165 Bind the web interface to the specified address.
166 The default is to listen on all interfaces.
170 Use the specified filter expression when capturing traffic.
171 The filter syntax is beyond the scope of this manual page;
177 .BI \-l " network/netmask"
178 Define a "local network" according to the network and netmask addresses.
179 All traffic entering or leaving this network will be graphed, as opposed
180 to the default behaviour of only graphing traffic to and from the local
184 The rule is that if \fBip_addr & netmask == network\fR,
185 then that address is considered local.
186 See the usage example below.
190 .BI \-\-chroot " dir"
191 Force \fIdarkstat\fR to \fBchroot()\fR into the specified directory.
192 Without this argument, a default directory will be used, which is
193 determined at build time.
194 Usually \fI/var/empty\fR or \fI/var/lib/empty\fR.
197 For security reasons, this directory should be empty, and the user that
198 \fIdarkstat\fR is running as should not have write access to it.
200 However, if you wish to use \fB\-\-daylog\fR or \fB\-\-export\fR,
201 \fIdarkstat\fR will need write access to the chroot.
202 If you are uncomfortable with the security implications, don't
203 use any functionality that requires write access.
207 .BI \-\-user " username"
208 Force \fIdarkstat\fR to drop privileges to the \fBuid\fR and \fBgid\fR of
210 Without this argument, a default value will be used, which is set at
212 Usually \fBnobody\fR.
215 For security reasons, this should not be \fBroot\fR.
219 .BI \-\-daylog " filename"
221 Log daily traffic statistics into the named file, relative to the
223 If you wish to use \fB\-\-daylog\fR, you must first specify a
224 \fB\-\-chroot\fR directory, and it must be writeable by the
226 A writeable chroot has security implications; if you are uncomfortable
227 with this, do not use the \fB\-\-daylog\fR functionality.
229 If the daylog argument is not specified, no logging is performed.
231 The daylog format is:
233 localtime|time_t|bytes_in|bytes_out|pkts_in|pkts_outs
235 Lines starting with a # are comments stating when logging started and
240 .BI \-\-import " filename"
241 Upon starting, import a \fIdarkstat\fR database from the named file,
242 relative to the chroot directory.
243 If you wish to use \fB\-\-import\fR, you must first specify a
244 \fB\-\-chroot\fR directory.
245 If the import is unsuccessful, \fIdarkstat\fR will start with an empty
249 .BI \-\-export " filename"
250 On shutdown, and upon receiving SIGUSR1, export the in-memory database
251 to the named file, relative to the chroot directory.
252 If you wish to use \fB\-\-export\fR, you must first specify a
253 \fB\-\-chroot\fR directory, and it must be writeable by the
255 A writeable chroot has security implications - if you are uncomfortable
256 with this, do not use the \fB\-\-export\fR functionality.
259 .BI \-\-pidfile " filename"
261 Creates a file containing the process ID of \fIdarkstat\fR.
262 This file will be unlinked upon clean shutdown.
263 As with all pidfiles, if \fIdarkstat\fR dies uncleanly, a stale pidfile
266 For example, start \fIdarkstat\fR with:
268 darkstat \-i fxp0 \-\-chroot /var/run/darkstat \-\-pidfile darkstat.pid
272 kill `cat /var/run/darkstat/darkstat.pid`
276 will send SIGTERM, which will cause \fIdarkstat\fR to shut down cleanly.
280 .BI \-\-hosts\-max " count"
281 The maximum number of hosts that will be kept in the hosts table.
282 This is used to limit how much accounting data will be kept in memory.
289 .BI \-\-hosts\-keep " count"
290 When the hosts table hits
292 and traffic is seen from a new host, we clean out the hosts table,
295 number of hosts, sorted by total traffic.
298 .BI \-\-ports\-max " count"
299 The maximum number of ports that will be tracked for each host.
300 This is used to limit how much accounting data will be kept in memory.
307 .BI \-\-ports\-keep " count"
308 When a ports table fills up, this many ports are kept and the rest are
312 .BI \-\-highest\-port " port"
313 Ports that are numerically higher than this will not appear in the
314 per-host ports tables, although their traffic will still be accounted
316 This can be used to hide ephemeral ports.
317 By default, all ports are tracked.
321 Show hex dumps of received traffic.
322 This is only for debugging, and implies \-\-verbose and \-\-no\-daemon.
324 .\" --------------------------------------------------------------------
326 To gather statistics on the
333 We want to account for traffic on the Internet-facing interface,
334 but only serve web pages to our private local network where we have the
335 IP address 192.168.0.1:
337 darkstat \-i fxp0 \-b 192.168.0.1
340 We want to serve web pages on the standard HTTP port:
342 darkstat \-i fxp0 \-p 80
345 We are on Optus (cable) and don't want to account for the constant ARP
346 traffic we are receiving:
348 darkstat \-i fxp0 \-f "not arp"
351 We only want to account for SSH traffic:
353 darkstat \-i fxp0 \-f "port 22"
356 We don't want to account for network internal traffic:
358 darkstat \-i fxp0 \-f "not (src net 192.168.0 and dst net 192.168.0)"
361 (For a full reference on filter syntax, refer to the
366 We have a network consisting of a gateway server (192.168.1.1) and a few
367 workstations (192.168.1.2, 192.168.1.3, etc.) and we want to graph all
368 traffic entering and leaving the local network, not just the gateway
369 server (which is running \fIdarkstat\fR):
371 darkstat \-i fxp0 \-l 192.168.1.0/255.255.255.0
374 On some systems, we can't capture on a "decoded" interface but
375 only on \fInas0\fR which returns PPPoE encapsulated packets.
376 Do PPPoE decoding, and override the local IP manually since it
377 cannot be automatically detected.
378 Note the /32 netmask:
380 darkstat \-i nas0 \-\-pppoe \-l 192.168.1.1/255.255.255.255
385 down cleanly, send a SIGTERM or SIGINT signal to the
389 Sending the SIGUSR1 signal will cause \fIdarkstat\fR to empty out its
391 If an \fB\-\-export\fR file was set, it will first save the database to
395 .SH FREQUENTLY ASKED QUESTIONS
396 .SS How many bytes does each bar on the graph represent?
397 Hover your mouse cursor over a bar and you should get a tooltip
398 saying exactly how many bytes in and out the bar represents.
400 .SS Why aren't there labels / tics / a scale on the graphs?
401 Because implementing them is hard.
402 And doing so \fIcorrectly\fR, and in a way that works across all
403 browsers, looks pretty much impossible.
405 I might attempt it some day.
406 In the meantime, patches would be gladly accepted.
408 .SS Why are the graphs blank? All the bars are zero.
409 The graphs only show traffic in/out of the local host, which is
410 determined by getting the IP address of the interface you're sniffing
413 You can use the \fB\-l\fR argument to override the local address for
415 You can also use it to do accounting for a whole subnet by specifying
416 an appropriate netmask.
423 was written in 2001, largely as a result of a certain Australian
424 cable Internet provider introducing a 3GB monthly traffic limit.
427 Emil Mikulic and others. (see the AUTHORS and THANKS files)
430 http://dmr.ath.cx/net/darkstat/