More documentation
[freeradius.git] / raddb / modules / sql_log
1 # -*- text -*-
2 #
3 #  $Id$
4
5 #
6 #  The rlm_sql_log module appends the SQL queries in a log
7 #  file which is read later by the radsqlrelay program.
8 #
9 #  This module only performs the dynamic expansion of the
10 #  variables found in the SQL statements. No operation is
11 #  executed on the database server. (this could be done
12 #  later by an external program) That means the module is
13 #  useful only with non-"SELECT" statements.
14 #
15 #  See rlm_sql_log(5) manpage.
16 #
17 #  This same functionality could also be implemented by logging
18 #  to a "detail" file, reading that, and then writing to SQL.
19 #  See raddb/sites-available/buffered-sql for an example.
20 #
21 sql_log {
22         path = "${radacctdir}/sql-relay"
23         acct_table = "radacct"
24         postauth_table = "radpostauth"
25         sql_user_name = "%{%{User-Name}:-DEFAULT}"
26
27         Start = "INSERT INTO ${acct_table} (AcctSessionId, UserName, \
28          NASIPAddress, FramedIPAddress, AcctStartTime, AcctStopTime, \
29          AcctSessionTime, AcctTerminateCause) VALUES                 \
30          ('%{Acct-Session-Id}', '%{User-Name}', '%{NAS-IP-Address}', \
31          '%{Framed-IP-Address}', '%S', '0', '0', '');"
32         Stop = "INSERT INTO ${acct_table} (AcctSessionId, UserName,  \
33          NASIPAddress, FramedIPAddress, AcctStartTime, AcctStopTime, \
34          AcctSessionTime, AcctTerminateCause) VALUES                 \
35          ('%{Acct-Session-Id}', '%{User-Name}', '%{NAS-IP-Address}', \
36          '%{Framed-IP-Address}', '0', '%S', '%{Acct-Session-Time}',  \
37          '%{Acct-Terminate-Cause}');"
38         Alive = "INSERT INTO ${acct_table} (AcctSessionId, UserName, \
39          NASIPAddress, FramedIPAddress, AcctStartTime, AcctStopTime, \
40          AcctSessionTime, AcctTerminateCause) VALUES                 \
41          ('%{Acct-Session-Id}', '%{User-Name}', '%{NAS-IP-Address}', \
42          '%{Framed-IP-Address}', '0', '0', '%{Acct-Session-Time}','');"
43
44         Post-Auth = "INSERT INTO ${postauth_table}                   \
45          (username, pass, reply, authdate) VALUES                    \
46          ('%{User-Name}', '%{User-Password:-Chap-Password}',         \
47          '%{reply:Packet-Type}', '%S');"
48 }
49