Re: Max-Monthly-Traffic

2010-02-23 Thread Fajar A. Nugraha
On Wed, Feb 24, 2010 at 1:32 AM, Alan DeKok  wrote:
> Neville wrote:
>> Anyone please, as this is driving me mad...
>
>  2^31 issues?  Check the code for unsigned int...

So you're suggesting to change the source code for rlm_sqlcounter and recompile?

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


Re: Max-Monthly-Traffic

2010-02-23 Thread Alan DeKok
Neville wrote:
> Anyone please, as this is driving me mad...

  2^31 issues?  Check the code for unsigned int...

  Alan DeKok.
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


Re: Max-Monthly-Traffic

2010-02-09 Thread Neville
Anyone please, as this is driving me mad...

Thx
Nev
  - Original Message - 
  From: Neville 
  To: freeradius-users@lists.freeradius.org 
  Sent: Sunday, February 07, 2010 1:28 PM
  Subject: Max-Monthly-Traffic


  Sorry for troubling everyone on this, but I cannot work out why 
Session-Octets-Limit is not calculating the differences between the counter and 
the check_item and setting an higher limited than the check_item?

  Log below

  Sun Feb  7 12:59:50 2010 : Debug: rlm_sqlcounter: Check item is greater than 
query result
  Sun Feb  7 12:59:50 2010 : Debug: rlm_sqlcounter: Authorized user FT-memjxa, 
check_item=26210, counter=151223038
  Sun Feb  7 12:59:50 2010 : Debug: rlm_sqlcounter: Sent Reply-Item for user 
FT-memjxa, Type=Session-Octets-Limit, value=263954010
  Sun Feb  7 12:59:50 2010 : Info: ++[monthlytraffic] returns ok


  sqlcounter monthlytraffic {
   counter-name = Monthly-Traffic
  check-name = Max-Monthly-Traffic
  reply-name = Session-Octets-Limit
  sqlmod-inst = sql
  key = User-Name
  reset = monthly
   query = "SELECT 
IFNULL((sum(acctinputoctets)+sum(acctoutputoctets)),0) FROM radacct WHERE 
username='%{%k}' AND Month(acctstoptime) =(Month(NOW())) AND Year(acctstoptime) 
= Year(NOW())"
  }


  Any pointers would help.

  Thx
  Nev-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Re: MAX-Monthly-Traffic V2 Post

2009-08-20 Thread Alexandre Chapellon
Le jeudi 20 août 2009 à 01:07 +0100, Neville a écrit :

> Hi Alex,
> 
> > You are expecting an interim update to send session-timeout to your nas
> > so it disconnect your user?
> > If so, two things seems incorrect to me.
> >
> >1- You're measuring traffic volume and want disconnection to set
> > based on time (session-timout)... a bit tricky isn't it?
> 
> So VERY True, Too many late nights and I really do appreciate your input as 
> this gave me food for thought and I now have EVERYTHING Working.
> 
> Both for Traffic & Session USAGE.
> 
> For Usage, I still had to use Max-Monthly-Traffic as a Check := and based on 
> sqlcounter calc, do a Reply = Sessions-Octets-Limit = XX on the 
> Access-Accept as this is supported by the ppp 2.4.4 NAS.


Be aware that sqlcounter were originatly designed to count time . I
remember it has a mechanism to allow user not to be disconnected when
its time left is greater than the time remaining to the 'reset period'.
as an example: if you have 2min left in your account and you connect the
31th of the month at 23h59 (supossing reset period is on the 1st of each
month at OhOO), then your session-timeout will not be 120 sec (2min) but
will be 120sec + the amount of time allowed for the next month (which
starts in 2 minutes)... this allow users not be disconnected stupidly at
end of month.

This mechanism is helpfull for time based counter but is meaningless for
volume based counter. it would means you get the next month quota addded
IF the number of the seconds untill the  end of the month is less than
the number of allowed octet at present time... weird!

Check at the source code but I am sure this code existed in 2.1.1
version.


> 
> What I would like to know now, is how I can use sqlcounter to do a Month 
> Calculation based on the date of the account being registered and NOT the 
> Calander Month?  Anyone?
> 
> >2- I think the attribute "Session-Timeout" cannot be found in
> > interim-updates packets (maybe I'm wrong), rfc 2869 specify that:  "It
> > is envisioned that an Interim Accounting record (with Acct-Status-Type =
> > Interim-Update (3)) would contain all of the attributes normally found
> > in an Accounting Stop message with the exception of the
> > Acct-Term-Cause attribute."
> >
> > What you would need is an attribute known by your nas and representing
> > remaining traffic. That attrbute should be sent at acct-start time and
> > would trigger a disconnection from the NAS when traffic limit is
> > reached. If such a attribute does not exists for your NAS, you should
> > take a look at CoA server.
> > Maybe someone have better idea...?
> >
> > Le mercredi 19 ao?t 2009 ? 15:56 +0100, Neville a ?crit :
> >
> 
> Cheers
> Nev
> 
> 
> CentOS 5.3
> pptpd 1.3.4 / ppp 2.4.4
> freeradius2 2.1.6
> radiusclient-ng 0.5.6
> daloRadius 0.9-8-SVN
> 
> 
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Re: MAX-Monthly-Traffic V2 Post.

2009-08-20 Thread goksie
Your sql should be changed.

Check any post on 24hours login. That logic will resolve this 2 days thread.

Goksie
Sent from my BlackBerry® smartphone from Etisalat

-Original Message-
From: Alexandre Chapellon 

Date: Wed, 19 Aug 2009 07:55:47 
To: FreeRadius users mailing list
Subject: Re: MAX-Monthly-Traffic V2 Post.


-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


Re: MAX-Monthly-Traffic V2 Post

2009-08-19 Thread Alexandre Chapellon
Le jeudi 20 août 2009 à 01:07 +0100, Neville a écrit :

> Hi Alex,
> 
> > You are expecting an interim update to send session-timeout to your nas
> > so it disconnect your user?
> > If so, two things seems incorrect to me.
> >
> >1- You're measuring traffic volume and want disconnection to set
> > based on time (session-timout)... a bit tricky isn't it?
> 
> So VERY True, Too many late nights and I really do appreciate your input as 
> this gave me food for thought and I now have EVERYTHING Working.
> 
> Both for Traffic & Session USAGE.
> 
> For Usage, I still had to use Max-Monthly-Traffic as a Check := and based on 
> sqlcounter calc, do a Reply = Sessions-Octets-Limit = XX on the 
> Access-Accept as this is supported by the ppp 2.4.4 NAS.


Sessions-Octets-Limit!? how lucky you are to have nas devices allowing
such a cool feature! I'd love redback NASes to have the same type of
feature! (I wil query the list.. maybe someone knows more about redback
devices)


> 
> What I would like to know now, is how I can use sqlcounter to do a Month 
> Calculation based on the date of the account being registered and NOT the 
> Calander Month?  Anyone?


More an sql query problematic i guess... I can't help here! :)


> 
> >2- I think the attribute "Session-Timeout" cannot be found in
> > interim-updates packets (maybe I'm wrong), rfc 2869 specify that:  "It
> > is envisioned that an Interim Accounting record (with Acct-Status-Type =
> > Interim-Update (3)) would contain all of the attributes normally found
> > in an Accounting Stop message with the exception of the
> > Acct-Term-Cause attribute."
> >
> > What you would need is an attribute known by your nas and representing
> > remaining traffic. That attrbute should be sent at acct-start time and
> > would trigger a disconnection from the NAS when traffic limit is
> > reached. If such a attribute does not exists for your NAS, you should
> > take a look at CoA server.
> > Maybe someone have better idea...?
> >
> > Le mercredi 19 ao?t 2009 ? 15:56 +0100, Neville a ?crit :
> >
> 
> Cheers
> Nev
> 
> 
> CentOS 5.3
> pptpd 1.3.4 / ppp 2.4.4
> freeradius2 2.1.6
> radiusclient-ng 0.5.6
> daloRadius 0.9-8-SVN
> 
> 
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
<>-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Re: Max Monthly Traffic

2009-08-19 Thread Goke Aruna

Neville wrote:

Hi everyone,
 
I'm trying to setup a new counter maxmonthlytraffic, but as soon as I 
connected, sql_counter sends reply to do a session timout and I get 
disconnected.
 
This is what I've done so far...
 
I've added to ./raddb/sql/mysql/counter.conf
 
/sqlcounter monthlytraffic {

counter-name = Monthly-Traffic
check-name = Max-Monthly-Traffic
sqlmod-inst = sql
key = User-Name
reset = monthly/
// 
/query = "SELECT 
(sum(acctinputoctets)+sum(acctoutputoctets)) \

FROM radacct WHERE username='%{%k}' AND \
Month(acctstoptime) =(Month(NOW())) AND \
Year(acctstoptime) = Year(NOW())"
}/
// 
/authorize {/
// 
/../

/monthlytraffic/
// 
/}/
// 
/instantiate {/
// 
/monthlytraffic/
// 
/}/
// 
created a dictionary entry in daloradius as..

id  
9433
Typeinteger
Attribute   Max-Monthly-Traffic
Value   /NULL/
Format  /NULL/
Vendor  dictionary.freeradius.internal
RecommendedOP   :=
RecommendedTablecheck
RecommendedHelper 	 
RecommendedTooltip 	Check Monthly Traffic Allowance


 
 
User created as "testmaxm", with the following attributes set:-
 
*Check*

Simultaneous-Use := 1
Pool-Name := tvpool
Cleartext-Password := testmaxm
Max-Monthly-Traffic := 1049   (10Mb)   (If this is removed from the 
Check, the user connects fine, so everything else is working)
 
*Reply*

Framed-MTU = 1400
Framed-Protocol = PPP
Service-Type = Framed-User
Acct-Interim-Interval := 300(Every 5 mins for testing)
 
*Some Debug...*
 
rlm_sqlcounter: Check item is greater than query result

rlm_sqlcounter: Authorized user testmaxm, check_item=1049, counter=80411
rlm_sqlcounter: Sent Reply-Item for user testmaxm, Type=Session-Timeout, 
value=11601138

++[monthlytraffic] returns ok
 
rad_recv: Accounting-Request packet from host aaa.bbb.ccc.ddd port 
53637, id=47, length=140

Acct-Session-Id = "4A8B6FA0721900"
User-Name = "testmaxm"
Acct-Status-Type = Interim-Update
Service-Type = Framed-User
Framed-Protocol = PPP
Acct-Authentic = RADIUS
Acct-Session-Time = 600
Acct-Output-Octets = 37033544
Acct-Input-Octets = 906612
Acct-Output-Packets = 27837
Acct-Input-Packets = 15791
NAS-Port-Type = Async
Framed-IP-Address = 192.168.0.29
NAS-Identifier = "aaa.bbb.ccc.ddd"
NAS-Port = 1
Acct-Delay-Time = 0
+- entering group preacct {...}
++[preprocess] returns ok
[acct_unique] Hashing 'NAS-Port = 1,Client-IP-Address = 
193.33.186.190,NAS-IP-Address = aaa.bbb.ccc.ddd,Acct-Session-Id = 
"4A8B6FA0721900",User-Name = "testmaxm"'

[acct_unique] Acct-Unique-Session-ID = "049e959019a363e4".
++[acct_unique] returns ok
[suffix] No '@'  in User-Name = "testmaxm", looking up realm 
NULL

[suffix] No such realm "NULL"
++[suffix] returns noop
+- entering group accounting {...}
[detail]expand: 
/var/log/radius/radacct/%{Client-IP-Address}/detail-%Y%m%d -> 
/var/log/radius/radacct/aaa.bbb.ccc.ddd/detail-20090819
[detail] /var/log/radius/radacct/%{Client-IP-Address}/detail-%Y%m%d 
expands to /var/log/radius/radacct/aaa.bbb.ccc.ddd/detail-20090819

[detail]expand: %t -> Wed Aug 19 03:31:04 2009
++[detail] returns ok
rlm_sql (sql): Reserving sql socket id: 1
[sqlippool] expand: %{User-Name} -> testmaxm
[sqlippool] sql_set_user escaped user --> 'testmaxm'
[sqlippool] expand: START TRANSACTION -> START TRANSACTION
rlm_sql_mysql: query:  START TRANSACTION
[sqlippool] expand: UPDATE radippool  SET expiry_time = NOW() + 
INTERVAL 3600 SECOND  WHERE nasipaddress = '%{Nas-IP-Address}' AND 
pool_key = '%{NAS-Port}'  AND username = '%{User-Name}'  AND 
callingstationid = '%{Calling-Station-Id}'  AND framedipaddress = 
'%{Framed-IP-Address}' -> UPDATE radippool  SET expiry_time = NOW() + 
INTERVAL 3600 SECOND  WHERE nasipaddress = 'aaa.bbb.ccc.ddd' AND 
pool_key = '1'  AND username = 'testmaxm'  AND callingstationid = ''  
AND framedipaddress = '192.168.0.29'
rlm_sql_mysql: query:  UPDATE radippool  SET expiry_time = NOW() + 
INTERVAL 3600 SECOND  WHERE nasipaddress = 'aaa.bbb.ccc.ddd' AND 
pool_key = '1'  AND username = 'testmaxm'  AND callingstationid = ''  
AND framedipaddress = '192.168.0.29'

[sqlippool] expand: COMMIT -> COMMIT
rlm_sql_mysql: query:  COMMIT
rlm_sql (sql): Released sql socket id: 1
++[sqlippool] returns ok
[sql]   expand: %{User-Name} -> testmaxm
[sql] sql_set_user escaped user --> 'testmaxm'
[sql]   expand: %{Acct-Input-Gigawords} ->
[sql]   expand: %{Acct-Input-Octets} -> 906612
[sql]   expand: %{Acct-Output-Gigawords} ->
[sql]   expand: %{Acct-Output-Octets} -> 37033544
[sql]   expand:UPDATE radacct   SET  
framedipaddress = '%{Framed-IP-Address}',  
acctsessiontime = '%{Acct-Session-Time}',  
acctinputoctets = '%{%{Acct-Input-Gigawords}:-0}'  << 32 
|  

Re: MAX-Monthly-Traffic V2 Post

2009-08-19 Thread Neville

Hi Alex,


You are expecting an interim update to send session-timeout to your nas
so it disconnect your user?
If so, two things seems incorrect to me.

   1- You're measuring traffic volume and want disconnection to set
based on time (session-timout)... a bit tricky isn't it?


So VERY True, Too many late nights and I really do appreciate your input as 
this gave me food for thought and I now have EVERYTHING Working.


Both for Traffic & Session USAGE.

For Usage, I still had to use Max-Monthly-Traffic as a Check := and based on 
sqlcounter calc, do a Reply = Sessions-Octets-Limit = XX on the 
Access-Accept as this is supported by the ppp 2.4.4 NAS.


What I would like to know now, is how I can use sqlcounter to do a Month 
Calculation based on the date of the account being registered and NOT the 
Calander Month?  Anyone?



   2- I think the attribute "Session-Timeout" cannot be found in
interim-updates packets (maybe I'm wrong), rfc 2869 specify that:  "It
is envisioned that an Interim Accounting record (with Acct-Status-Type =
Interim-Update (3)) would contain all of the attributes normally found
in an Accounting Stop message with the exception of the
Acct-Term-Cause attribute."

What you would need is an attribute known by your nas and representing
remaining traffic. That attrbute should be sent at acct-start time and
would trigger a disconnection from the NAS when traffic limit is
reached. If such a attribute does not exists for your NAS, you should
take a look at CoA server.
Maybe someone have better idea...?

Le mercredi 19 ao?t 2009 ? 15:56 +0100, Neville a ?crit :



Cheers
Nev


CentOS 5.3
pptpd 1.3.4 / ppp 2.4.4
freeradius2 2.1.6
radiusclient-ng 0.5.6
daloRadius 0.9-8-SVN


-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


Re: MAX-Monthly-Traffic V2 Post

2009-08-19 Thread Neville

Hi Alex,


You are expecting an interim update to send session-timeout to your nas
so it disconnect your user?
If so, two things seems incorrect to me.

   1- You're measuring traffic volume and want disconnection to set
based on time (session-timout)... a bit tricky isn't it?


So VERY True, Too many late nights and I really do appreciate your input as 
this gave me food for thought and I now have EVERYTHING Working.


Both for Traffic & Session USAGE.

For Usage, I still had to use Max-Monthly-Traffic as a Check := and based on 
sqlcounter calc, do a Reply = Sessions-Octets-Limit = XX on the 
Access-Accept as this is supported by the ppp 2.4.4 NAS.


What I would like to know now, is how I can use sqlcounter to do a Month 
Calculation based on the date of the account being registered and NOT the 
Calander Month?  Anyone?



   2- I think the attribute "Session-Timeout" cannot be found in
interim-updates packets (maybe I'm wrong), rfc 2869 specify that:  "It
is envisioned that an Interim Accounting record (with Acct-Status-Type =
Interim-Update (3)) would contain all of the attributes normally found
in an Accounting Stop message with the exception of the
Acct-Term-Cause attribute."

What you would need is an attribute known by your nas and representing
remaining traffic. That attrbute should be sent at acct-start time and
would trigger a disconnection from the NAS when traffic limit is
reached. If such a attribute does not exists for your NAS, you should
take a look at CoA server.
Maybe someone have better idea...?

Le mercredi 19 ao?t 2009 ? 15:56 +0100, Neville a ?crit :



Cheers
Nev


CentOS 5.3
pptpd 1.3.4 / ppp 2.4.4
freeradius2 2.1.6
radiusclient-ng 0.5.6
daloRadius 0.9-8-SVN


-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html


Re: MAX-Monthly-Traffic V2 Post.

2009-08-19 Thread Sajeewa Warnakulasuriya
The session counter works where it sets session-timeout value when the 
user first authenticates and NAS disconnects the user when the session 
exceeds this value and not the RADIUS.


For the below to work your NAS must be able to disconnect the USER the 
same way as above but be able to track the traffic for the session and 
initiate the disconnection from the NAS.


As Alexandre suggested CoA is a better idea.

Regards,



Sajeewa Warnakulasuriya

Systems Development Manager



ispONE is a wholesale ISP built to help internet access resellers and
independent ISPs to compete in the Australian marketplace through
ONE Brand, ONE Provider, ONE Solution.

Level 14
520 Collins Street
Melbourne 3000 VIC


Phone:  1300 663 400

Fax:  1300 665 400

E-Mail: sajee...@ispone.com.au

Web:http://www.ispone.com.au/

On Wed, 19 Aug 2009, Alexandre Chapellon wrote:


You are expecting an interim update to send session-timeout to your nas
so it disconnect your user?
If so, two things seems incorrect to me.

   1- You're measuring traffic volume and want disconnection to set
based on time (session-timout)... a bit tricky isn't it?

   2- I think the attribute "Session-Timeout" cannot be found in
interim-updates packets (maybe I'm wrong), rfc 2869 specify that:  "It
is envisioned that an Interim Accounting record (with Acct-Status-Type =
Interim-Update (3)) would contain all of the attributes normally found
in an Accounting Stop message with the exception of the
Acct-Term-Cause attribute."

What you would need is an attribute known by your nas and representing
remaining traffic. That attrbute should be sent at acct-start time and
would trigger a disconnection from the NAS when traffic limit is
reached. If such a attribute does not exists for your NAS, you should
take a look at CoA server.
Maybe someone have better idea...?

Le mercredi 19 ao??t 2009 ?? 15:56 +0100, Neville a ??crit :


Hi everyone,

I've decided to submit this question again as it was not quite worded
correctly, and to send as PLAIN TEXT.

I'm trying to setup a new counter maxmonthlytraffic, which uses the same
method to disconnect a user by sending the Session-Timout Reply Atrribute as
with MAX-ALL-Sessions.

This is what I've done so far...

I've added to ./raddb/sql/mysql/counter.conf

sqlcounter monthlytraffic {
counter-name = Monthly-Traffic
check-name = Max-Monthly-Traffic
sqlmod-inst = sql
key = User-Name
reset = monthly

query = "SELECT (sum(acctinputoctets)+sum(acctoutputoctets))
\
FROM radacct WHERE username='%{%k}' AND \
Month(acctstoptime) =(Month(NOW())) AND \
Year(acctstoptime) = Year(NOW())"
}

authorize {
.
monthlytraffic
.
}

instantiate {
.
monthlytraffic
.
}

created a dictionary entry in daloradius database of:-

id 9433
Type integer
Attribute Max-Monthly-Traffic
Value NULL
Format NULL
Vendor dictionary.freeradius.internal
RecommendedOP :=
RecommendedTable check
RecommendedHelper
RecommendedTooltip Check Monthly Traffic Allowance

User created as "testmaxm", with the following attributes set:-

Check
Simultaneous-Use := 1
Pool-Name := tvpool
Cleartext-Password := testmaxm
Max-Monthly-Traffic := 1049   (10Mb)   (If this is removed from the
Check, the user connects fine, so everything else is working)

Reply
Framed-MTU = 1400
Framed-Protocol = PPP
Service-Type = Framed-User
Acct-Interim-Interval := 300(Every 5 mins for testing)
=


Although this seems to be working on the initial Connection, it does not
send the Session Time Out Reply during the Interim Acct Updates if the Usage
has execeed.


From the Debug below, the usages is shown as "37940156"  during a Acct

Update e.g. 906612 + 3733544 and is more than the initial check value of
Max-Monthly-Traffic := 1049, so I would have expected a Session-Timout
Reply to be sent.

However this is working ok on disconnect and reconnect, as I get...

rlm_sqlcounter: (Check item - counter) is less than zero
rlm_sqlcounter: Rejected user testmaxm, check_item=1049,
counter=89021682
++[monthlytraffic] returns reject
Invalid user (rlm_sqlcounter: Maximum monthly usage time reached):
[testmaxm/] (from client VPN1-UK port 1)

rlm_sqlcounter: (Check item - counter) is less than zero
rlm_sqlcounter: Rejected user testmaxm, check_item=1049,
counter=89021682
++[monthlytraffic] returns reject
Invalid user (rlm_sqlcounter: Maximum monthly usage time reached):
[testmaxm/] (from client VPN1-UK port 1)

Any Ideas why I did not get disconnect during the original session as this
is what I'm after.


FreeRadius2 Debug

.
.
rlm_sqlcounter: Check item is greater than query result
rlm_sqlcounter: Authorized user testmaxm, check_item=1049, counter=80411
rlm_sqlcounter: Sent Reply-Item for user testmaxm, Type=Session-Timeout,
value=11601138
++[monthlytraffic] returns ok
.
.

rad_recv: Accounting-Request packet from host aaa.bbb.ccc.ddd port

Re: MAX-Monthly-Traffic V2 Post.

2009-08-19 Thread Alexandre Chapellon
You are expecting an interim update to send session-timeout to your nas
so it disconnect your user?
If so, two things seems incorrect to me.

1- You're measuring traffic volume and want disconnection to set
based on time (session-timout)... a bit tricky isn't it?

2- I think the attribute "Session-Timeout" cannot be found in
interim-updates packets (maybe I'm wrong), rfc 2869 specify that:  "It
is envisioned that an Interim Accounting record (with Acct-Status-Type =
Interim-Update (3)) would contain all of the attributes normally found
in an Accounting Stop message with the exception of the
Acct-Term-Cause attribute."

What you would need is an attribute known by your nas and representing
remaining traffic. That attrbute should be sent at acct-start time and
would trigger a disconnection from the NAS when traffic limit is
reached. If such a attribute does not exists for your NAS, you should
take a look at CoA server.
Maybe someone have better idea...?

Le mercredi 19 août 2009 à 15:56 +0100, Neville a écrit :

> Hi everyone,
> 
> I've decided to submit this question again as it was not quite worded 
> correctly, and to send as PLAIN TEXT.
> 
> I'm trying to setup a new counter maxmonthlytraffic, which uses the same 
> method to disconnect a user by sending the Session-Timout Reply Atrribute as 
> with MAX-ALL-Sessions.
> 
> This is what I've done so far...
> 
> I've added to ./raddb/sql/mysql/counter.conf
> 
> sqlcounter monthlytraffic {
> counter-name = Monthly-Traffic
> check-name = Max-Monthly-Traffic
> sqlmod-inst = sql
> key = User-Name
> reset = monthly
> 
> query = "SELECT (sum(acctinputoctets)+sum(acctoutputoctets)) 
> \
> FROM radacct WHERE username='%{%k}' AND \
> Month(acctstoptime) =(Month(NOW())) AND \
> Year(acctstoptime) = Year(NOW())"
> }
> 
> authorize {
> .
> monthlytraffic
> .
> }
> 
> instantiate {
> .
> monthlytraffic
> .
> }
> 
> created a dictionary entry in daloradius database of:-
> 
> id 9433
> Type integer
> Attribute Max-Monthly-Traffic
> Value NULL
> Format NULL
> Vendor dictionary.freeradius.internal
> RecommendedOP :=
> RecommendedTable check
> RecommendedHelper
> RecommendedTooltip Check Monthly Traffic Allowance
> 
> User created as "testmaxm", with the following attributes set:-
> 
> Check
> Simultaneous-Use := 1
> Pool-Name := tvpool
> Cleartext-Password := testmaxm
> Max-Monthly-Traffic := 1049   (10Mb)   (If this is removed from the 
> Check, the user connects fine, so everything else is working)
> 
> Reply
> Framed-MTU = 1400
> Framed-Protocol = PPP
> Service-Type = Framed-User
> Acct-Interim-Interval := 300(Every 5 mins for testing)
> =
> 
> 
> Although this seems to be working on the initial Connection, it does not 
> send the Session Time Out Reply during the Interim Acct Updates if the Usage 
> has execeed.
> 
> >From the Debug below, the usages is shown as "37940156"  during a Acct 
> Update e.g. 906612 + 3733544 and is more than the initial check value of 
> Max-Monthly-Traffic := 1049, so I would have expected a Session-Timout 
> Reply to be sent.
> 
> However this is working ok on disconnect and reconnect, as I get...
> 
> rlm_sqlcounter: (Check item - counter) is less than zero
> rlm_sqlcounter: Rejected user testmaxm, check_item=1049, 
> counter=89021682
> ++[monthlytraffic] returns reject
> Invalid user (rlm_sqlcounter: Maximum monthly usage time reached): 
> [testmaxm/] (from client VPN1-UK port 1)
> 
> rlm_sqlcounter: (Check item - counter) is less than zero
> rlm_sqlcounter: Rejected user testmaxm, check_item=1049, 
> counter=89021682
> ++[monthlytraffic] returns reject
> Invalid user (rlm_sqlcounter: Maximum monthly usage time reached): 
> [testmaxm/] (from client VPN1-UK port 1)
> 
> Any Ideas why I did not get disconnect during the original session as this 
> is what I'm after.
> 
> 
> FreeRadius2 Debug
> 
> .
> .
> rlm_sqlcounter: Check item is greater than query result
> rlm_sqlcounter: Authorized user testmaxm, check_item=1049, counter=80411
> rlm_sqlcounter: Sent Reply-Item for user testmaxm, Type=Session-Timeout, 
> value=11601138
> ++[monthlytraffic] returns ok
> .
> .
> 
> rad_recv: Accounting-Request packet from host aaa.bbb.ccc.ddd port 53637, 
> id=47, length=140
> Acct-Session-Id = "4A8B6FA0721900"
> User-Name = "testmaxm"
> Acct-Status-Type = Interim-Update
> Service-Type = Framed-User
> Framed-Protocol = PPP
> Acct-Authentic = RADIUS
> Acct-Session-Time = 600
> Acct-Output-Octets = 37033544
> Acct-Input-Octets = 906612
> Acct-Output-Packets = 27837
> Acct-Input-Packets = 15791
> NAS-Port-Type = Async
> Framed-IP-Address = 192.168.0.29
> NAS-Identifier = "aaa.bbb.ccc.ddd"
> NAS-Port = 1
> Acct-Delay-Time = 0
> +- entering group preacc