This manual is for ulog-acctd, version 0.4
Copyright © 2002 Hilko Bengen
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
ulog-acctd is a userspace network accounting daemon which generates log files of network traffic for accounting purposes.
ulog-acctd collects headers of IP packets fhat travel through the Linux 2.4+ Netfilter framework. It writes accounting information to a log which can include
The log file format is configurable. For instance, it should be possible to directly generate files that contain SQL statements so that the raw accounting data can be fed into a DBMS.
ulog-acctd only collects, aggregates, and logs the all data it is fed by netfilter. If only traffic for specific networks needs to be collected, selection for this should be done in the netfilter rulesets, as ulog-acctd has no way to ignore some packets and log others.
ulog-acctd does not analyze them nor paint pretty pictures for traffic visualization. In the "one tool for one job" spirit of UNIX, Other tools should be used for these tasks.
net--acct (http://exorsus.net/projects/net–acct/) was developed by Ulrich Callmeier. The Mekafile hints that it can be used on Solaris (using libpcap). The Linux version uses the now obsolete packet interface at protocol level. (see ip(7)).
Information for net–acct is available at http://www.exorsus.net/net–acct/.
I had tried to implement support for the newer packet interface at device level (supported since Linux kernel versions 2.2, see packet(7)), but I found that it lost packets in high load situations. Patches against net--acct are available on request.
ulog-acctd is based on net--acct and still shares some portions of the code. net--acct does not seem to be actively maintained any longer.
ipcad stands for IP Cisco Accounting Daemon. It runs in background and listens traffic on the specified interfaces. Statistics are available through a Cisco–compatible rsh interface. ipcad can use the BPF interface or libpcap, which on Linux probably leads to packet less under high load, as described above.
ipcad is available from http://sourceforge.net/projects/ipcad.
It is certainly possible to set up a similar scenario with ulog-acctd with a small rsh daemon (or maybe just a shell script) which would emulate the relevant parts of Cisco command line syntax.
traff (http://sourceforge.net/projects/traff/) is a program that attaches itself to one or more network interfaces, sniffs all IP-packages passing at it and accounts each packets size. The collected information can be dumped to an SQL database (PostgreSQL or MySQL), syslog or a file.
Like ipcad, it uses libpcap.
ipac--ng regularly reads byte and packet counters associated with the Linux kernel's packet filter rules and stores those numbers in a database. This works well for a small number of IP addresses / ports, but it does not scale well since one rule in the packet filter is needed for each possible entry.
As the name suggests, ulogd uses the same approach for collecting IP packets as ulog-acctd does. ulogd can be extended through binary plugins for adding packet interpreters and output-targets (e.g. for logging into databases, user defined filetypes, etc.). It can be downloaded from http://www.gnumonks.org/projects/ulogd.
ulog-acctd relies on the kernel (more specific: Netfilter) to pipe the packet headers to user space. This has to be enabled by adding rules with the ULOG target to packet filtering tables.
The following example causes all packets that successfully pass the FORWARD table to be logged to ulog-acctd.
iptables --append FORWARD -j ULOG --ulog-nlgroup 1 --ulog-cprange 48 --ulog-qthreshold 50 --ulog-prefix "FORWARD"
Explaination:
If the copy range is too small to even hold the IP address, an additional error message "copy range is too short to even capture IP headers. ALL IP PACKETS WILL BE DROPPED!" is logged.
For further information, see iptables(8).
Per default, configuration is done via the file /etc/ulog-acctd.conf. The following keywords are recognized:
This has changed in version 0.4.2
Example:
multicast groups=1 accounting file = /var/log/ulog-acctd/account.log dump file = /var/log/ulog-acctd/dump debug file = /var/log/ulog-acctd/debug.log debug = error accounting format = "%h\t%x\t%t\t%p\t%s\t%S\t%d\t%D\t%P\t%b\t\"%i\"\t\"%o\"\t\"%f\"\n" flush = 30 fdelay = 30
The supplied accounting format string generates output records in the following form (all in one line, with a linefeed at the end):
judith 1032521450 1032521454 6 192.168.42.11 110 192.168.215.71 1546 12 250113 "eth0" "eth1" "prefix"
The following format string will generate cisco "ip accounting output-packets"-style output lines:
accounting format = "%s %d %P %b\n"
The lines will look like this:
192.168.42.11 192.168.215.71 12 250113
When not all types of information are collected, ulog-acctd will have to do fewer comparisions for each packet while collecting data. Records are smaller and likely fewer records will be written out. This will be the case especially if port information are not collected.
ulog-acctd recognizes the following command-line parameters:
The following signals are recognized by ulog-acctd:
To cleanly rotate accounting log files, send SIGTSTP to the daemon, then move the logfiles out of the way, and finally send a SIGCONT to re-enable logging accounting data.
Be sure not to compress the log files immediately after rotating. When the accounting log file is written to, the writing process will create a hard link to the accounting file and gzip and bzip2 will not compress files with more than 1 link.
This message in the debug log means that the kernel is delivering packets faster than ulog-acctd can process them. This happens most likely when ulog-acctd writes its accounting log to disk.
There are a few steps that can be taken both in kernel space and in ulog-acctd.
The fdelay configuration parameter can be used to reduce log file size where ulog-acctd is used to account many long-lasting connections and where it is not strictly necessary that the time values are absolutely correct.
When fdelay is set to a non-zero value, ulog-acctd writes an additional dump file every time it writes to the accounting log. This dump file contains those records that have been kept in memory. If ulog-acctd crashes before writing to the accounting log file, these entries can still be recovered by the system administrator.
ulog-acctd was written by Hilko Bengen. Source tarballs and public CVS are accessible through http://alioth.debian.org/projects/pkg-ulog-acctd.
Initial work (up to version 0.4.1) on this program was funded by toplink–plannet GmbH, Karlsruhe, Germany http://www.toplink-plannet.de/.