Accounting
**********

By default GNU Radius supports three types of accounting. Any additional accounting methods can be defined using extension mechanisms.

The accounting methods are applied to a request in a following sequence:

 1. UNIX accounting

 2. Detailed request accounting

 3. sql accounting

 4. Custom accounting

In this sequence, only UNIX accounting is obligatory; all other methods are applied only when enabled.

If any accounting type in this sequence fails, the accounting is deemed to fail and all subsequent methods are not invoked.

UNIX Accounting
===============

This accounting method is always enabled.

Radius keeps files radutmp and radwtmp in its logging directory  and stores the accounting data there. The utilities radwho and radlast can be used to list information about users' sessions.

Detailed Request Accounting
===========================

Radius stores the detailed information about accounting packets it receives in files radacct/NASNAME/detail (see Naming Conventions), where NASNAME is replaced with the short name of the NAS from the raddb/naslist file (see naslist file).

By default, this accounting type is always enabled, provided that radacct directory exists and is writable (see Naming Conventions). To turn the detailed accounting off, use the detail statement in the config file. For more information about it, see acct.

The accounting detail files consist of a record for each accounting request. A record includes the timestamp and detailed dump of attributes from the packet, e.g.:

     Fri Dec 15 18:00:24 2000
             Acct-Session-Id = "2193976896017"
             User-Name = "e2"
             Acct-Status-Type = Start
             Acct-Authentic = RADIUS
             Service-Type = Framed-User
             Framed-Protocol = PPP
             Framed-IP-Address = 11.10.10.125
             Calling-Station-Id = "+15678023561"
             NAS-IP-Address = 11.10.10.11
             NAS-Port-Id = 8
             Acct-Delay-Time = 0
             Timestamp = 976896024
             Request-Authenticator = Unverified

     Fri Dec 15 18:32:09 2000
             Acct-Session-Id = "2193976896017"
             User-Name = "e2"
             Acct-Status-Type = Stop
             Acct-Authentic = RADIUS
             Acct-Output-Octets = 5382
             Acct-Input-Octets = 7761
             Service-Type = Framed-User
             Framed-Protocol = PPP
             Framed-IP-Address = 11.10.10.125
             Acct-Session-Time = 1905
             NAS-IP-Address = 11.10.10.11
             NAS-Port-Id = 8
             Acct-Delay-Time = 0
             Timestamp = 976897929
             Request-Authenticator = Unverified

sql Accounting
==============

The sql accounting method is enabled when Radius is configured with --enable-sql option and the sqlserver file in its configuration directory is properly set up (see sqlserver file).

This version of GNU Radius (VERSION) supports MySQL and PostgreSQL servers. Support for Oracle servers will be added soon.

With this accounting method enabled, radiusd will store the information about accounting requests in the configured sql database. The accounting method is fully configurable: the Radius administrator defines both the types of requests to be accounted and the information to be stored into the database (see sqlserver file).

Defining Custom Accounting Types
================================

If the built-in accounting methods do not meet your requirements, you can implement your own. There are two ways of doing so:

 1. Using a Guile procedure.

 2. Using an external program

To use a Guile procedure for accounting, the name of the procedure must be specified as a value to the Scheme-Acct-Procedure attribute in the RHS list of a hints entry, e.g.:

     DEFAULT NULL Scheme-Acct-Procedure = "my-acct"

For a detailed description of Scheme accounting procedures, see Accounting with Scheme.

Another way of implementing your own accounting method is using an external program. This is less effective than the methods described above, but may be necessary sometimes. To invoke the program, use the following statement in the LHS of the hints entry:

     Acct-Ext-Program = "PROGNAME ARGS"

The PROGNAME must be the full path to the program, and ARGS any arguments it needs. The usual substitutions may be used in ARGS to pass any request attributes to the program (see Macro Substitution).

For a detailed description of Acct-Ext-Program, see Acct-Ext-Program.