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