Base SoH code for Microsoft NAP.
[freeradius.git] / doc / rlm_sqlcounter
index 97074ac..b170e89 100644 (file)
@@ -19,12 +19,13 @@ of radiusd.conf
 
 [1] Create a text file called sqlcounter.conf in the same
 directory where radiusd.conf resides (usually /usr/local/etc/raddb)
-with the following content:
+with the following content (for mysql):
 
 #-----#
 sqlcounter noresetcounter {
                 counter-name = Max-All-Session-Time
                 check-name = Max-All-Session
+                reply-name = Session-Timeout
                 sqlmod-inst = sql
                 key = User-Name
                 reset = never
@@ -38,6 +39,7 @@ sqlcounter dailycounter {
                 driver = "rlm_sqlcounter"
                 counter-name = Daily-Session-Time
                 check-name = Max-Daily-Session
+                reply-name = Session-Timeout
                 sqlmod-inst = sqlcca3
                 key = User-Name
                 reset = daily
@@ -49,6 +51,7 @@ sqlcounter dailycounter {
 sqlcounter monthlycounter {
                 counter-name = Monthly-Session-Time
                 check-name = Max-Monthly-Session
+                reply-name = Session-Timeout
                 sqlmod-inst = sqlcca3
                 key = User-Name
                 reset = monthly
@@ -59,6 +62,39 @@ sqlcounter monthlycounter {
 
 #-----#
 
+The respective lines for postgresql are:
+
+query = "SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='%{%k}'"
+query = "SELECT SUM(AcctSessionTime - GREATER((%b - AcctStartTime::ABSTIME::INT4), 0)) FROM radacct WHERE UserName='%{%k}' AND AcctStartTime::ABSTIME::INT4 + AcctSessionTime > '%b'"
+query = "SELECT SUM(AcctSessionTime - GREATER((%b - AcctStartTime::ABSTIME::INT4), 0)) FROM radacct WHERE UserName='%{%k}' AND AcctStartTime::ABSTIME::INT4 + AcctSessionTime > '%b'"
+
+If you are running postgres 7.x, you may not have a GREATER function.
+
+An example of one is:
+
+CREATE OR REPLACE FUNCTION "greater"(integer, integer) RETURNS integer AS '
+DECLARE
+  res INTEGER;
+  one INTEGER := 0;
+  two INTEGER := 0;
+BEGIN
+  one = $1;
+  two = $2;
+  IF one IS NULL THEN
+    one = 0;
+  END IF;
+  IF two IS NULL THEN
+    two = 0;
+  END IF;
+  IF one > two THEN
+    res := one;
+  ELSE
+    res := two;
+  END IF;
+  RETURN res;
+END;
+' LANGUAGE 'plpgsql';
+
 [2] Include the above file to radiusd.conf by adding a line in
 modules{ } section
 
@@ -92,7 +128,8 @@ monthlycounter: the counter that resets monthly, can be used for
 limiting monthly access time (eg. 50 hours per month)
 
 You can make your own names and directives for resetting the counter
-by following src/modules/rlm_sqlcounter/README.txt 
+by reading the sample sqlcounter configuration in
+raddb/experimental.conf