Move sqlcounter config into sql/mysql-sqlcounter.conf and sql/postgresql-sqlcounter...
authorpnixon <pnixon>
Tue, 17 Jul 2007 20:42:34 +0000 (20:42 +0000)
committerpnixon <pnixon>
Tue, 17 Jul 2007 20:42:34 +0000 (20:42 +0000)
raddb/radiusd.conf.in
raddb/sql/mysql-sqlcounter.conf [new file with mode: 0644]
raddb/sql/postgresql-sqlcounter.conf [new file with mode: 0644]

index b24f872..82753e2 100644 (file)
@@ -1452,121 +1452,8 @@ $INCLUDE ${confdir}/eap.conf
        #  totally dependent on the SQL module to process Accounting
        #  packets.
        #
-       #  The 'sqlmod_inst' parameter holds the instance of the sql
-       #  module to use when querying the SQL database. Normally it
-       #  is just "sql".  If you define more and one SQL module
-       #  instance (usually for failover situations), you can
-       #  specify which module has access to the Accounting Data
-       #  (radacct table).
-       #
-       #  The 'reset' parameter defines when the counters are all
-       #  reset to zero.  It can be hourly, daily, weekly, monthly or
-       #  never.  It can also be user defined. It should be of the
-       #  form:
-       #       num[hdwm] where:
-       #       h: hours, d: days, w: weeks, m: months
-       #       If the letter is ommited days will be assumed. In example:
-       #       reset = 10h (reset every 10 hours)
-       #       reset = 12  (reset every 12 days)
-       #
-       #  The 'key' parameter specifies the unique identifier for the
-       #  counter records (usually 'User-Name').
-       #
-       #  The 'query' parameter specifies the SQL query used to get
-       #  the current Counter value from the database. There are 3
-       #  parameters that can be used in the query:
-       #               %k      'key' parameter
-       #               %b      unix time value of beginning of reset period
-       #               %e      unix time value of end of reset period
-       #
-       #  The 'check-name' parameter is the name of the 'check'
-       #  attribute to use to access the counter in the 'users' file
-       #  or SQL radcheck or radcheckgroup tables.
-       #
-       #  DEFAULT  Max-Daily-Session > 3600, Auth-Type = Reject
-       #      Reply-Message = "You've used up more than one hour today"
-       #
-       sqlcounter dailycounter {
-               counter-name = Daily-Session-Time
-               check-name = Max-Daily-Session
-               reply-name = Session-Timeout
-               sqlmod-inst = sql
-               key = User-Name
-               reset = daily
-
-               # This query properly handles calls that span from the
-               # previous reset period into the current period but
-               # involves more work for the SQL server than those
-               # below
-               # For mysql:
-               query = "SELECT SUM(AcctSessionTime - \
-                 GREATEST((%b - UNIX_TIMESTAMP(AcctStartTime)), 0)) \
-                 FROM radacct WHERE UserName='%{%k}' AND \
-                 UNIX_TIMESTAMP(AcctStartTime) + AcctSessionTime > '%b'"
-
-               # For postgresql:
-#              query = "SELECT SUM(AcctSessionTime - \
-#                GREATER((%b - AcctStartTime::ABSTIME::INT4), 0)) \
-#                FROM radacct WHERE UserName='%{%k}' AND \
-#                AcctStartTime::ABSTIME::INT4 + AcctSessionTime > '%b'"
-
-               # This query ignores calls that started in a previous
-               # reset period and continue into into this one. But it
-               # is a little easier on the SQL server
-               # For mysql:
-#              query = "SELECT SUM(AcctSessionTime) FROM radacct WHERE \
-#                UserName='%{%k}' AND AcctStartTime > FROM_UNIXTIME('%b')"
-
-               # For postgresql:
-#              query = "SELECT SUM(AcctSessionTime) FROM radacct WHERE \
-#                UserName='%{%k}' AND AND AcctStartTime::ABSTIME::INT4 > '%b'"
-
-               # This query is the same as above, but demonstrates an
-               # additional counter parameter '%e' which is the
-               # timestamp for the end of the period
-               # For mysql:
-#              query = "SELECT SUM(AcctSessionTime) FROM radacct \
-#                WHERE UserName='%{%k}' AND AcctStartTime BETWEEN \
-#                FROM_UNIXTIME('%b') AND FROM_UNIXTIME('%e')"
-
-               # For postgresql:
-#              query = "SELECT SUM(AcctSessionTime) FROM radacct \
-#                WHERE UserName='%{%k}' AND AcctStartTime::ABSTIME::INT4 \
-#                BETWEEN '%b' AND '%e'"
-       }
-
-       sqlcounter monthlycounter {
-               counter-name = Monthly-Session-Time
-               check-name = Max-Monthly-Session
-               reply-name = Session-Timeout
-               sqlmod-inst = sql
-               key = User-Name
-               reset = monthly
-
-               # This query properly handles calls that span from the
-               # previous reset period into the current period but
-               # involves more work for the SQL server than those
-               # below
-               # The same notes above about the differences between mysql
-               # versus postgres queries apply here.
-               query = "SELECT SUM(AcctSessionTime - \
-                 GREATEST((%b - UNIX_TIMESTAMP(AcctStartTime)), 0)) \
-                 FROM radacct WHERE UserName='%{%k}' AND \
-                 UNIX_TIMESTAMP(AcctStartTime) + AcctSessionTime > '%b'"
-
-               # This query ignores calls that started in a previous
-               # reset period and continue into into this one. But it
-               # is a little easier on the SQL server
-#              query = "SELECT SUM(AcctSessionTime) FROM radacct WHERE \
-#                UserName='%{%k}' AND AcctStartTime > FROM_UNIXTIME('%b')"
-
-               # This query is the same as above, but demonstrates an
-               # additional counter parameter '%e' which is the
-               # timestamp for the end of the period
-#              query = "SELECT SUM(AcctSessionTime) FROM radacct \
-#                WHERE UserName='%{%k}' AND AcctStartTime BETWEEN \
-#                FROM_UNIXTIME('%b') AND FROM_UNIXTIME('%e')"
-       }
+       $INCLUDE  ${confdir}/sql/mysql-sqlcounter.conf
+       #$INCLUDE  ${confdir}/sql/postgresql-sqlcounter.conf
 
        #
        # The "always" module is here for debugging purposes. Each
diff --git a/raddb/sql/mysql-sqlcounter.conf b/raddb/sql/mysql-sqlcounter.conf
new file mode 100644 (file)
index 0000000..dca182b
--- /dev/null
@@ -0,0 +1,108 @@
+##     $Id$
+##
+##  This module is an SQL enabled version of the counter module.
+##  The queries are MySQL specific
+
+#  Rather than maintaining seperate (GDBM) databases of
+#  accounting info for each counter, this module uses the data
+#  stored in the raddacct table by the sql modules. This
+#  module NEVER does any database INSERTs or UPDATEs.  It is
+#  totally dependent on the SQL module to process Accounting
+#  packets.
+#
+#  The 'sqlmod_inst' parameter holds the instance of the sql
+#  module to use when querying the SQL database. Normally it
+#  is just "sql".  If you define more and one SQL module
+#  instance (usually for failover situations), you can
+#  specify which module has access to the Accounting Data
+#  (radacct table).
+#
+#  The 'reset' parameter defines when the counters are all
+#  reset to zero.  It can be hourly, daily, weekly, monthly or
+#  never.  It can also be user defined. It should be of the
+#  form:
+#      num[hdwm] where:
+#      h: hours, d: days, w: weeks, m: months
+#      If the letter is ommited days will be assumed. In example:
+#      reset = 10h (reset every 10 hours)
+#      reset = 12  (reset every 12 days)
+#
+#  The 'key' parameter specifies the unique identifier for the
+#  counter records (usually 'User-Name').
+#
+#  The 'query' parameter specifies the SQL query used to get
+#  the current Counter value from the database. There are 3
+#  parameters that can be used in the query:
+#              %k      'key' parameter
+#              %b      unix time value of beginning of reset period
+#              %e      unix time value of end of reset period
+#
+#  The 'check-name' parameter is the name of the 'check'
+#  attribute to use to access the counter in the 'users' file
+#  or SQL radcheck or radcheckgroup tables.
+#
+#  DEFAULT  Max-Daily-Session > 3600, Auth-Type = Reject
+#      Reply-Message = "You've used up more than one hour today"
+#
+sqlcounter dailycounter {
+       counter-name = Daily-Session-Time
+       check-name = Max-Daily-Session
+       reply-name = Session-Timeout
+       sqlmod-inst = sql
+       key = User-Name
+       reset = daily
+
+       # This query properly handles calls that span from the
+       # previous reset period into the current period but
+       # involves more work for the SQL server than those
+       # below
+       query = "SELECT SUM(AcctSessionTime - \
+                 GREATEST((%b - UNIX_TIMESTAMP(AcctStartTime)), 0)) \
+                 FROM radacct WHERE UserName='%{%k}' AND \
+                 UNIX_TIMESTAMP(AcctStartTime) + AcctSessionTime > '%b'"
+
+       # This query ignores calls that started in a previous
+       # reset period and continue into into this one. But it
+       # is a little easier on the SQL server
+#      query = "SELECT SUM(AcctSessionTime) FROM radacct WHERE \
+#                UserName='%{%k}' AND AcctStartTime > FROM_UNIXTIME('%b')"
+
+       # This query is the same as above, but demonstrates an
+       # additional counter parameter '%e' which is the
+       # timestamp for the end of the period
+#      query = "SELECT SUM(AcctSessionTime) FROM radacct \
+#                WHERE UserName='%{%k}' AND AcctStartTime BETWEEN \
+#                FROM_UNIXTIME('%b') AND FROM_UNIXTIME('%e')"
+}
+
+sqlcounter monthlycounter {
+       counter-name = Monthly-Session-Time
+               check-name = Max-Monthly-Session
+               reply-name = Session-Timeout
+               sqlmod-inst = sql
+               key = User-Name
+               reset = monthly
+
+       # This query properly handles calls that span from the
+       # previous reset period into the current period but
+       # involves more work for the SQL server than those
+       # below
+       query = "SELECT SUM(AcctSessionTime - \
+                 GREATEST((%b - UNIX_TIMESTAMP(AcctStartTime)), 0)) \
+                 FROM radacct WHERE UserName='%{%k}' AND \
+                 UNIX_TIMESTAMP(AcctStartTime) + AcctSessionTime > '%b'"
+
+       # This query ignores calls that started in a previous
+       # reset period and continue into into this one. But it
+       # is a little easier on the SQL server
+#      query = "SELECT SUM(AcctSessionTime) FROM radacct WHERE \
+#                UserName='%{%k}' AND AcctStartTime > FROM_UNIXTIME('%b')"
+
+       # This query is the same as above, but demonstrates an
+       # additional counter parameter '%e' which is the
+       # timestamp for the end of the period
+#      query = "SELECT SUM(AcctSessionTime) FROM radacct \
+#                WHERE UserName='%{%k}' AND AcctStartTime BETWEEN \
+#                FROM_UNIXTIME('%b') AND FROM_UNIXTIME('%e')"
+}
+
diff --git a/raddb/sql/postgresql-sqlcounter.conf b/raddb/sql/postgresql-sqlcounter.conf
new file mode 100644 (file)
index 0000000..43c2e1c
--- /dev/null
@@ -0,0 +1,109 @@
+##     $Id$
+##
+##  This module is an SQL enabled version of the counter module
+##  The queries are PostgreSQL specific
+
+#  Rather than maintaining seperate (GDBM) databases of
+#  accounting info for each counter, this module uses the data
+#  stored in the raddacct table by the sql modules. This
+#  module NEVER does any database INSERTs or UPDATEs.  It is
+#  totally dependent on the SQL module to process Accounting
+#  packets.
+#
+#  The 'sqlmod_inst' parameter holds the instance of the sql
+#  module to use when querying the SQL database. Normally it
+#  is just "sql".  If you define more and one SQL module
+#  instance (usually for failover situations), you can
+#  specify which module has access to the Accounting Data
+#  (radacct table).
+#
+#  The 'reset' parameter defines when the counters are all
+#  reset to zero.  It can be hourly, daily, weekly, monthly or
+#  never.  It can also be user defined. It should be of the
+#  form:
+#      num[hdwm] where:
+#      h: hours, d: days, w: weeks, m: months
+#      If the letter is ommited days will be assumed. In example:
+#      reset = 10h (reset every 10 hours)
+#      reset = 12  (reset every 12 days)
+#
+#  The 'key' parameter specifies the unique identifier for the
+#  counter records (usually 'User-Name').
+#
+#  The 'query' parameter specifies the SQL query used to get
+#  the current Counter value from the database. There are 3
+#  parameters that can be used in the query:
+#              %k      'key' parameter
+#              %b      unix time value of beginning of reset period
+#              %e      unix time value of end of reset period
+#
+#  The 'check-name' parameter is the name of the 'check'
+#  attribute to use to access the counter in the 'users' file
+#  or SQL radcheck or radcheckgroup tables.
+#
+#  DEFAULT  Max-Daily-Session > 3600, Auth-Type = Reject
+#      Reply-Message = "You've used up more than one hour today"
+#
+sqlcounter dailycounter {
+       counter-name = Daily-Session-Time
+       check-name = Max-Daily-Session
+       reply-name = Session-Timeout
+       sqlmod-inst = sql
+       key = User-Name
+       reset = daily
+
+       # This query properly handles calls that span from the
+       # previous reset period into the current period but
+       # involves more work for the SQL server than those
+       # below
+#      query = "SELECT SUM(AcctSessionTime - \
+#                GREATER((%b - AcctStartTime::ABSTIME::INT4), 0)) \
+#                FROM radacct WHERE UserName='%{%k}' AND \
+#                AcctStartTime::ABSTIME::INT4 + AcctSessionTime > '%b'"
+
+       # This query ignores calls that started in a previous
+       # reset period and continue into into this one. But it
+       # is a little easier on the SQL server
+#      query = "SELECT SUM(AcctSessionTime) FROM radacct WHERE \
+#                UserName='%{%k}' AND AND AcctStartTime::ABSTIME::INT4 > '%b'"
+
+       # This query is the same as above, but demonstrates an
+       # additional counter parameter '%e' which is the
+       # timestamp for the end of the period
+#      query = "SELECT SUM(AcctSessionTime) FROM radacct \
+#                WHERE UserName='%{%k}' AND AcctStartTime::ABSTIME::INT4 \
+#                BETWEEN '%b' AND '%e'"
+}
+
+sqlcounter monthlycounter {
+       counter-name = Monthly-Session-Time
+               check-name = Max-Monthly-Session
+               reply-name = Session-Timeout
+               sqlmod-inst = sql
+               key = User-Name
+               reset = monthly
+
+       # This query properly handles calls that span from the
+       # previous reset period into the current period but
+       # involves more work for the SQL server than those
+       # below
+       query = "SELECT SUM(AcctSessionTime - \
+                GREATER((%b - AcctStartTime::ABSTIME::INT4), 0)) \
+                FROM radacct WHERE UserName='%{%k}' AND \
+                AcctStartTime::ABSTIME::INT4 + AcctSessionTime > '%b'"
+
+
+       # This query ignores calls that started in a previous
+       # reset period and continue into into this one. But it
+       # is a little easier on the SQL server
+#      query = "SELECT SUM(AcctSessionTime) FROM radacct WHERE \
+#                UserName='%{%k}' AND AND AcctStartTime::ABSTIME::INT4 > '%b'"
+
+       # This query is the same as above, but demonstrates an
+       # additional counter parameter '%e' which is the
+       # timestamp for the end of the period
+#      query = "SELECT SUM(AcctSessionTime) FROM radacct \
+#                WHERE UserName='%{%k}' AND AcctStartTime::ABSTIME::INT4 \
+#                BETWEEN '%b' AND '%e'"
+}
+