Add docs for rlm_sqlcounter module to experimental.conf
[freeradius.git] / raddb / experimental.conf
1 #
2 #  This file contains the configuration for experimental modules.
3 #
4 #  By default, it is NOT included in the build.
5 #
6 #  $Id$
7 #
8
9
10         # Configuration for the Python module.
11         #
12         # Where radiusd is a Python module, radiusd.py, and the
13         # function 'authorize' is called.  Here is a dummy piece
14         # of code:
15         # 
16         #       def authorize(params):
17         #           print params
18         #           return (5, ('Reply-Message', 'banned'))
19         #
20         # The RADIUS value-pairs are passed as a tuple of tuple
21         # pairs as the first argument, e.g. (('attribute1',
22         # 'value1'), ('attribute2', 'value2'))
23         #
24         # The function return is a tuple with the first element
25         # being the return value of the function.
26         # The 5 corresponds to RLM_MODULE_USERLOCK. I plan to
27         # write the return values as Python symbols to avoid
28         # confusion.
29         #
30         # The remaining tuple members are the string form of
31         # value-pairs which are passed on to pairmake().
32         #
33         python {
34                 mod_authorize = radiusd
35                 func_authorize = authorize
36         }
37
38         
39         # Configuration for the example module.  Uncommenting it will cause it
40         # to get loaded and initialized, but should have no real effect as long
41         # it is not referencened in one of the autz/auth/preacct/acct sections
42         example {
43                 #  Boolean variable.
44                 # allowed values: {no, yes}
45                 boolean = yes
46
47                 #  An integer, of any value.
48                 integer = 16
49
50                 #  A string.
51                 string = "This is an example configuration string"
52
53                 # An IP address, either in dotted quad (1.2.3.4) or hostname
54                 # (example.com)
55                 ipaddr = 127.0.0.1
56
57                 # A subsection
58                 mysubsection {
59                         anotherinteger = 1000
60                         # They nest
61                         deeply nested {
62                                 string = "This is a different string"
63                         }
64                 }
65         }
66
67
68         #  This module is an SQL enabled version of the counter module.
69         #  
70         #  Rather than maintaining seperate (GDBM) databases of accounting info
71         #       for each counter, this module uses the data stored in the raddacct
72         #       table by the sql modules. This module NEVER does any database 
73         #       INSERTs or UPDATEs.  It is totally dependent on the SQL module
74         #       to process Accounting packets.
75         #
76         #  The 'sqlmod_inst' parameter holds the instance of the sql module to use 
77         #       when querying the SQL database. Normally it is just "sql".
78         #       If you define more and one SQL module instance 
79         #       (usually for failover situations), you can specify which module
80         #       has access to the Accounting Data (radacct table).
81         #
82         #  The 'reset' parameter defines when the counters are all reset to
83         #       zero.  It can be hourly, daily, weekly, monthly or never.
84         #       It can also be user defined. It should be of the form:
85         #       num[hdwm] where:
86         #       h: hours, d: days, w: weeks, m: months
87         #       If the letter is ommited days will be assumed. In example:
88         #       reset = 10h (reset every 10 hours)
89         #       reset = 12  (reset every 12 days)
90         #
91         #  The 'key' parameter specifies the unique identifier for the counters
92         #       records (usually 'User-Name'). 
93         #
94         # The 'query' parameter specifies the SQL query used to get the 
95         #       current Counter value from the database. There are 3 parameters
96         #       that can be used in the query:
97         #               %k      'key' parameter
98         #               %b      unix time value of beginning of reset period 
99         #               %e      unix time value of end of reset period
100         #
101         #  The 'check-name' parameter is the name of the 'check' attribute to use to access
102         #       the counter in the 'users' file or SQL radcheck or radcheckgroup 
103         #       tables.
104         #
105         #  DEFAULT  Max-Daily-Session > 3600, Auth-Type = Reject
106         #      Reply-Message = "You've used up more than one hour today"
107         #1
108
109         sqlcounter dailycounter {
110                 counter-name = Daily-Session-Time
111                 check-name = Max-Daily-Session
112                 sqlmod-inst = sqlcca3
113                 key = User-Name
114                 reset = daily
115
116                 # This query properly handles calls that span from the previous reset period
117                 # into the current period but involves more work for the SQL server than those below
118                 query = "SELECT SUM(AcctSessionTime - GREATEST((%b - UNIX_TIMESTAMP(AcctStartTime)), 0)) FROM radacct WHERE UserName='%{%k}' AND UNIX_TIMESTAMP(AcctStartTime) + AcctSessionTime > '%b'"
119
120                 # This query ignores calls that started in a previous reset period and 
121                 # continue into into this one. But it is a little easier on the SQL server 
122                 # query = "SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='%{%k}' AND AcctStartTime > FROM_UNIXTIME('%b')"
123
124                 # This query is the same as above, but demonstrates an additional 
125                 # counter parameter '%e' which is the timestamp for the end of the period
126                 # query = "SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='%{%k}' AND AcctStartTime BETWEEN FROM_UNIXTIME('%b') AND FROM_UNIXTIME('%e')"               
127         }
128
129         sqlcounter monthlycounter {
130                 counter-name = Monthly-Session-Time
131                 check-name = Max-Monthly-Session
132                 sqlmod-inst = sqlcca3
133                 key = User-Name
134                 reset = monthly
135
136                 # This query properly handles calls that span from the previous reset period
137                 # into the current period but involves more work for the SQL server than those below
138                 query = "SELECT SUM(AcctSessionTime - GREATEST((%b - UNIX_TIMESTAMP(AcctStartTime)), 0)) FROM radacct WHERE UserName='%{%k}' AND UNIX_TIMESTAMP(AcctStartTime) + AcctSessionTime > '%b'"
139
140                 # This query ignores calls that started in a previous reset period and 
141                 # continue into into this one. But it is a little easier on the SQL server 
142                 # query = "SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='%{%k}' AND AcctStartTime > FROM_UNIXTIME('%b')"
143
144                 # This query is the same as above, but demonstrates an additional 
145                 # counter parameter '%e' which is the timestamp for the end of the period
146                 # query = "SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='%{%k}' AND AcctStartTime BETWEEN FROM_UNIXTIME('%b') AND FROM_UNIXTIME('%e')"               
147         }
148
149