The NAS generates the MN-FA key, not the AAA
[freeradius.git] / man / man5 / rlm_sql_log.5
1 .\"     # DS - begin display
2 .de DS
3 .RS
4 .nf
5 .sp
6 ..
7 .\"     # DE - end display
8 .de DE
9 .fi
10 .RE
11 .sp
12 ..
13 .TH rlm_sql_log 5 "28 May 2005" "" "FreeRADIUS Module"
14 .SH NAME
15 rlm_sql_log \- FreeRADIUS Module
16 .SH DESCRIPTION
17 The \fBrlm_sql_log\fP module appends the SQL queries in a log file
18 which is read later by the scripts/radsqlrelay Perl program.
19 .PP
20 The purpose of this module is to de-couple the storage of long-term
21 accounting data in SQL from "live" information needed by the RADIUS
22 server as it's running.  If you are not using SQL for simultaneous
23 login restrictions (i.e. "sql" is not listed in the "session" section
24 of "radiusd.conf"), then this module allows you to log SQL queries to
25 a file, and then process them at your leisure.
26 .PP
27 The benefit of this approach is that for a busy server, the overhead
28 of performing SQL qeuries may be significant.  Also, if the SQL
29 databases are large (as is typical for ones storing months of data),
30 the INSERTs and UPDATEs may take a relatively long time.  Rather than
31 slowing down the RADIUS server by having it interact with a database,
32 you can just log the queries to a file, and then run those queries on
33 another machine, or at a time when the RADIUS server is typically
34 lightly loaded.
35 .PP
36 If the "sql" module is listed in the "session" section of
37 "radiusd.conf", then a similar system can still be used.  In that
38 case, one database would be used to maintain "live" session
39 information.  That database would be small, fast, and information
40 would be deleted from it when a user logs out.  A second database
41 would store long-term accounting information, as described above.
42 .SH LIMITATIONS
43 This module only performs the dynamic expansion of the variables found
44 in the SQL statements. No operation is executed on the database server.
45 (this would be done later by an external program) That means the module
46 is useful only with non-"SELECT" statements.
47 .SH CONFIGURATION
48 The main configuration items to be aware of are the path of the log
49 file and the different SQL queries.
50 .IP "path"
51 An entry named "path" sets the full path of the file where the SQL
52 queries are recorded. (this variable is run through dynamic string
53 expansion, and can include FreeRADIUS variables to create a dynamic
54 filename)
55 .IP "Accounting queries"
56 When a accounting record is processed, the module searches a config
57 entry keyed by the Acct-Status-Type attribute present in the
58 packet. For example, the SQL to be run on an accounting start must be
59 named "Start" in the configuration for the module. Other usual values
60 for Acct-Status-Type are "Stop", "Alive", "Accounting-On", etc.  See
61 the VALUEs for Acct-Status-Type in the dictionary.rfc2866 file.
62 .IP "Post-Auth query"
63 An entry named "Post-Auth" sets the query to run during the
64 post-authentication stage.  This query is mainly used to log sessions
65 where there may not be a later accounting packet.
66 .PP
67 .DS
68 modules {
69   ...
70 .br
71   sql_log {
72 .br
73     path = "${radacctdir}/sql-relay"
74 .br
75     acct_table = "radacct"
76 .br
77     postauth_table = "radpostauth"
78 .br
79     sql_user_name = "%{%{User-Name}:-DEFAULT}"
80 .br
81
82 .br
83     Start = "INSERT INTO ${acct_table} ..."
84 .br
85     Stop = "UPDATE ${acct_table} SET ..."
86 .br
87     Alive = "UPDATE ${acct_table} SET ..."
88 .br
89
90 .br
91     Post-Auth = "INSERT INTO ${postauth_table} ..."
92 .br
93   }
94 .br
95   ...
96 .br
97 }
98
99 .br
100 accounting {
101   ...
102 .br
103   sql_log
104   ...
105 .br
106 }
107 .br
108
109 .br
110 post-auth {
111   ...
112 .br
113   sql_log
114   ...
115 .br
116 }
117 .DE
118 .SH SECTIONS
119 .BR accounting,
120 .BR post-auth
121 .SH FILES
122 .I /etc/raddb/radiusd.conf
123 .SH SEE ALSO
124 .BR radsqlrelay (8),
125 .BR radiusd (8),
126 .BR radiusd.conf (5)
127 .SH AUTHOR
128 Nicolas Baradakis <nicolas.baradakis@cegetel.net>